¡@

Home 

c# Programming Glossary: myattribute

When is a custom attribute's constructor run?

http://stackoverflow.com/questions/1168535/when-is-a-custom-attributes-constructor-run

true AttributeUsage AttributeTargets.All public class MyAttribute Attribute public MyAttribute Console.WriteLine Running constructor.. public class MyAttribute Attribute public MyAttribute Console.WriteLine Running constructor MyAttribute class MyClass.. public MyAttribute Console.WriteLine Running constructor MyAttribute class MyClass public int Value get set And what is the output..

Exclude property from serialization via custom attribute (json.net)

http://stackoverflow.com/questions/13588022/exclude-property-from-serialization-via-custom-attribute-json-net

get in the way. So my thought is to use a custom attribute MyAttribute on the properties and initialize the specific instance of JsonSerializer..

Generating a custom compile time warning C#

http://stackoverflow.com/questions/1420143/generating-a-custom-compile-time-warning-c-sharp

possible . There are two cases which interest me currently MyAttribute typeof MyClass Where MyClass has to implement an interface... to track down due to the nature of the stack trace public MyAttribute Type MyClassType System.Diagnostics.Debug.Assert typeof MyInterface.. SomeInterface Exists SomeAttibute Generate Warning MyAttribute typeof MyClass Comment next line to generate warning Foo Bar..

Custom Compiler Warnings

http://stackoverflow.com/questions/154109/custom-compiler-warnings

that give messages that I write. Something like this MyAttribute This code sux and should be looked at public sub DoEverything..

Attribute.IsDefined doesn't see attributes applied with MetadataType class

http://stackoverflow.com/questions/1910532/attribute-isdefined-doesnt-see-attributes-applied-with-metadatatype-class

Console.WriteLine Attribute.IsDefined propertyInfo typeof MyAttribute Console.WriteLine propertyInfo.IsDefined typeof MyAttribute.. Console.WriteLine propertyInfo.IsDefined typeof MyAttribute true Console.WriteLine propertyInfo.GetCustomAttributes true.. public string MyField get set public class MyMeta MyAttribute public string MyField get set AttributeUsage AttributeTargets.All..

How to get a list of properties with a given attribute?

http://stackoverflow.com/questions/2281972/how-to-get-a-list-of-properties-with-a-given-attribute

a list of the public properties that have the attribute MyAttribute . The attribute is marked with AllowMultiple false like this.. object attributes prop.GetCustomAttributes typeof MyAttribute true if attributes.Length 1 Property with my custom attribute.. .Where prop Attribute.IsDefined prop typeof MyAttribute This avoids having to materialize any attribute instances i.e...

XmlSerialize a custom collection with an Attribute

http://stackoverflow.com/questions/377486/xmlserialize-a-custom-collection-with-an-attribute

MyCollection Collection string XmlAttribute public string MyAttribute get set public MyCollection this.MyAttribute SerializeThis.. string MyAttribute get set public MyCollection this.MyAttribute SerializeThis This outputs the following XML note MyAttribute.. SerializeThis This outputs the following XML note MyAttribute is missing in the MyCollection element xml version 1.0 encoding..

When a class is inherited from List<>, XmlSerializer doesn't serialize other attributes

http://stackoverflow.com/questions/5069099/when-a-class-is-inherited-from-list-xmlserializer-doesnt-serialize-other-att

MyClass int myAttribute 2011 XmlAttribute public int MyAttribute get return myAttribute set myAttribute value the resulting..