Click here to Skip to main content
15,898,134 members
Home / Discussions / C#
   

C#

 
Generalaccessing selected text in a foreground window Pin
Gene Yu14-Jan-03 9:37
Gene Yu14-Jan-03 9:37 
GeneralDirectory Drilling/Recursion Pin
MrEyes14-Jan-03 7:57
MrEyes14-Jan-03 7:57 
GeneralRe: Directory Drilling/Recursion Pin
Hesham Amin14-Jan-03 9:12
Hesham Amin14-Jan-03 9:12 
GeneralRe: Directory Drilling/Recursion Pin
leppie14-Jan-03 9:51
leppie14-Jan-03 9:51 
Generalcompilation date / time in c# Pin
mleonhartsberger14-Jan-03 7:27
mleonhartsberger14-Jan-03 7:27 
GeneralRe: compilation date / time in c# Pin
Paul Ingles14-Jan-03 7:29
Paul Ingles14-Jan-03 7:29 
GeneralRe: compilation date / time in c# Pin
mleonhartsberger14-Jan-03 7:38
mleonhartsberger14-Jan-03 7:38 
GeneralRe: compilation date / time in c# Pin
Paul Ingles14-Jan-03 10:49
Paul Ingles14-Jan-03 10:49 
Attributes are a way to add bits to the metadata for types. For example, when you're developing an ASP.NET Web Service you use the attribute [WebMethod] to effectively mark it to be used.

So, you could develop a class like so (taken from code by Jeff Prosise):
[AttributeUsage (AttributeTargets.All, AllowMultiple=false)]
class BuildDateAttribute : Attribute
{
    public string BuildTime;
    public string BuildDate;

    public BuildDateAttribute (string BuildDate, string BuildTime)
    {
        this.BuildDate = BuildDate;
        this.BuildTime = BuildTime;
    }
}


This allows you to include a BuildDateAttribute to the metadata (the example this is taken from is for code revisions). I'm not sure, but you may be able to include code to automatically determine the date and time.

Then you can use it as follows:
[BuildDate ("12:01","13/03/2002")]
class TestClass
{
    .
}


Then you can obtain the metadata as follows:
MemberInfo info = typeof(TestClass);
object[] attributes = info.GetCustomAttributes(false);

if (attributes.Length > 0)
    Console.WriteLine( attribute.BuildDate );


I've not tried the code myself but it ought to work. If you do give it a go and get it to automatically insert the current time at build then it'd be great to put as an article on CP (in my opinion).

Hope that helps, let me know how it goes.

--
Paul
"If you can keep your head when all around you have lost theirs, then you probably haven't understood the seriousness of the situation."
- David Brent, from "The Office"

MS Messenger: paul@oobaloo.co.uk
Sonork: 100.22446

GeneralRe: compilation date / time in c# Pin
James T. Johnson14-Jan-03 8:31
James T. Johnson14-Jan-03 8:31 
GeneralRe: compilation date / time in c# Pin
David Stone14-Jan-03 17:42
sitebuilderDavid Stone14-Jan-03 17:42 
GeneralDeploying a dot NET app Pin
antoine@orchus-tech14-Jan-03 5:10
antoine@orchus-tech14-Jan-03 5:10 
GeneralRe: Deploying a dot NET app Pin
Stephane Rodriguez.14-Jan-03 5:37
Stephane Rodriguez.14-Jan-03 5:37 
GeneralRe: Deploying a dot NET app Pin
Stephane Rodriguez.16-Jan-03 2:41
Stephane Rodriguez.16-Jan-03 2:41 
QuestionNetworkStream? Pin
gekoscan13-Jan-03 19:59
gekoscan13-Jan-03 19:59 
QuestionRuntime Compilation - Worth It? Pin
Eric Astor13-Jan-03 15:14
Eric Astor13-Jan-03 15:14 
AnswerRe: Runtime Compilation - Worth It? Pin
Frank Hileman8-Apr-03 10:23
Frank Hileman8-Apr-03 10:23 
GeneralRe: Runtime Compilation - Worth It? Pin
Eric Astor8-Apr-03 11:41
Eric Astor8-Apr-03 11:41 
GeneralRe: Runtime Compilation - Worth It? Pin
Frank Hileman10-Apr-03 6:06
Frank Hileman10-Apr-03 6:06 
GeneralRe: Runtime Compilation - Worth It? Pin
Eric Astor10-Apr-03 6:51
Eric Astor10-Apr-03 6:51 
GeneralRe: Runtime Compilation - Worth It? Pin
Frank Hileman10-Apr-03 8:28
Frank Hileman10-Apr-03 8:28 
GeneralRe: Runtime Compilation - Worth It? Pin
Eric Astor10-Apr-03 10:01
Eric Astor10-Apr-03 10:01 
GeneralRe: Runtime Compilation - Worth It? Pin
Frank Hileman10-Apr-03 11:18
Frank Hileman10-Apr-03 11:18 
QuestionSockets with Server but what event? Pin
gekoscan13-Jan-03 11:28
gekoscan13-Jan-03 11:28 
GeneralRemoting (events/delegates) Pin
leppie13-Jan-03 9:40
leppie13-Jan-03 9:40 
GeneralRe: Remoting (events/delegates) Pin
James T. Johnson14-Jan-03 8:19
James T. Johnson14-Jan-03 8:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.