[SOLVED] Representing Metadata
-
I'd like to have non C# metadata about some of my classes stored with those classes. I tried creating static virtual methods that would return the metadata, but alas, C# doesn't support static virtual methods. So it got me thinking...What's the best way to store metadata about classes inside those classes so that you can retrieve it from an instance or from a static method? Or is there another better way to store metadata about the classes? SOLUTION: I'll just create virtual instance methods. But I'd still like to hear your thoughts on the matter. SECOND SOLUTION: Due to Gerry's suggestion, I am now using Attributes for this purpose. It's working out better than instance methods would have.
The difficult we do right away... ...the impossible takes slightly longer.
-
I'd like to have non C# metadata about some of my classes stored with those classes. I tried creating static virtual methods that would return the metadata, but alas, C# doesn't support static virtual methods. So it got me thinking...What's the best way to store metadata about classes inside those classes so that you can retrieve it from an instance or from a static method? Or is there another better way to store metadata about the classes? SOLUTION: I'll just create virtual instance methods. But I'd still like to hear your thoughts on the matter. SECOND SOLUTION: Due to Gerry's suggestion, I am now using Attributes for this purpose. It's working out better than instance methods would have.
The difficult we do right away... ...the impossible takes slightly longer.
I was going to suggest "attributes" ... or is that "C# metadata"? ... which you don't want. [Extending Metadata Using Attributes - .NET | Microsoft Learn](https://learn.microsoft.com/en-us/dotnet/standard/attributes/)
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
-
I was going to suggest "attributes" ... or is that "C# metadata"? ... which you don't want. [Extending Metadata Using Attributes - .NET | Microsoft Learn](https://learn.microsoft.com/en-us/dotnet/standard/attributes/)
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
I need to store information that one cannot get from .net reflection. That's all I meant by non C#. But I think that attributes might be what I'm looking for. Thanks for the idea!
The difficult we do right away... ...the impossible takes slightly longer.