c# Programming Glossary: memberinfo
C# object dumper http://stackoverflow.com/questions/1347375/c-sharp-object-dumper item level else WriteObject prefix item else MemberInfo members element.GetType .GetMembers BindingFlags.Public BindingFlags.Instance.. WriteIndent Write prefix bool propWritten false foreach MemberInfo m in members FieldInfo f m as FieldInfo PropertyInfo p m as.. if propWritten WriteLine if level depth foreach MemberInfo m in members FieldInfo f m as FieldInfo PropertyInfo p m as..
Exclude property from serialization via custom attribute (json.net) http://stackoverflow.com/questions/13588022/exclude-property-from-serialization-via-custom-attribute-json-net protected override JsonProperty CreateProperty MemberInfo member MemberSerialization memberSerialization JsonProperty..
Why XML-Serializable class need a parameterless constructor http://stackoverflow.com/questions/267724/why-xml-serializable-class-need-a-parameterless-constructor System.Xml.Serialization.TypeScope.GetTypeDesc Type type MemberInfo sourc e Boolean directReference Boolean throwOnError at System.Xml.Serialization.ModelScope.GetTypeModel..
Get property name and type using lambda expression http://stackoverflow.com/questions/273941/get-property-name-and-type-using-lambda-expression of a property or field to get you started public static MemberInfo GetMemberInfo T U Expression Func T U expression var member.. or field to get you started public static MemberInfo GetMemberInfo T U Expression Func T U expression var member expression.Body.. string Name get return My Program static void Main MemberInfo member ReflectionUtility.GetMemberInfo Program p p.Name Console.WriteLine..
Mutating the expression tree of a predicate to target another type http://stackoverflow.com/questions/2797261/mutating-the-expression-tree-of-a-predicate-to-target-another-type instance which has a property of type MemberInfo that describes DataContract.Widget.Id . There are also ParameterExpression..
Data Conflict in LINQ http://stackoverflow.com/questions/32649/data-conflict-in-linq mcc.OriginalValue object databaseVal mcc.DatabaseValue MemberInfo mi mcc.Member Console.WriteLine Member 0 mi.Name Console.WriteLine..
How do I get the name of a property from a property in C# (2.0) http://stackoverflow.com/questions/388775/how-do-i-get-the-name-of-a-property-from-a-property-in-c-sharp-2-0 What you want is the mythical infoof operator I wish... MemberInfo member infoof whotsit.TestProp As it is you can only use reflection..
Enum ToString http://stackoverflow.com/questions/479410/enum-tostring for a potential friendly name for the enum MemberInfo memberInfo type.GetMember enumerationValue.ToString if memberInfo..
Lambda expression not returning expected MemberInfo http://stackoverflow.com/questions/6658669/lambda-expression-not-returning-expected-memberinfo expression not returning expected MemberInfo I'm running into a problem that I did not expect. An example.. the base class. What I'm looking for is a way to get the MemberInfo from a lambda expression as if I had used reflection on the.. used reflection on the type of the parameter to get the MemberInfo. My project essentially stores MemberInfos in a dictionary of..
c# - How to iterate through classes fields and set properties http://stackoverflow.com/questions/721441/c-sharp-how-to-iterate-through-classes-fields-and-set-properties new Person public void DynamicallySetPersonProperty MemberInfo members this.GetType .GetMembers foreach MemberInfo member in.. MemberInfo members this.GetType .GetMembers foreach MemberInfo member in members.Where a a.Name _person get the _person field..
Implement IDispatch::Invoke to be called by a WebBrowser control http://stackoverflow.com/questions/7608550/implement-idispatchinvoke-to-be-called-by-a-webbrowser-control bindingAttr throw new NotImplementedException MemberInfo IReflect.GetMember string name BindingFlags bindingAttr throw.. bindingAttr throw new NotImplementedException MemberInfo IReflect.GetMembers BindingFlags bindingAttr throw new NotImplementedException..
Hows to quick check if data transfer two objects have equal properties in C#? http://stackoverflow.com/questions/986572/hows-to-quick-check-if-data-transfer-two-objects-have-equal-properties-in-c BindingFlags.Instance BindingFlags.Public .Cast MemberInfo .Concat typeof T .GetFields BindingFlags.Instance BindingFlags.Public.. BindingFlags.Instance BindingFlags.Public .Cast MemberInfo var x Expression.Parameter typeof T x var y Expression.Parameter..
C# Dynamic Event Subscription http://stackoverflow.com/questions/45779/c-sharp-dynamic-event-subscription ExampleEventArgs handlerArgType typeof int x1.IntArg var memberInfo eventArgs.Type.GetMember IntArg 0 return Expression.MakeMemberAccess.. IntArg 0 return Expression.MakeMemberAccess eventArgs memberInfo throw new NotSupportedException eventArgs handlerArgType static..
Enum ToString http://stackoverflow.com/questions/479410/enum-tostring for a potential friendly name for the enum MemberInfo memberInfo type.GetMember enumerationValue.ToString if memberInfo null.. memberInfo type.GetMember enumerationValue.ToString if memberInfo null memberInfo.Length 0 object attrs memberInfo 0 .GetCustomAttributes.. enumerationValue.ToString if memberInfo null memberInfo.Length 0 object attrs memberInfo 0 .GetCustomAttributes typeof..
get the value of DisplayName attribute http://stackoverflow.com/questions/5015830/get-the-value-of-displayname-attribute T Expression Func T object propertyExpression var memberInfo GetPropertyInformation propertyExpression.Body if memberInfo.. GetPropertyInformation propertyExpression.Body if memberInfo null throw new ArgumentException No property reference expression.. expression was found. propertyExpression var attr memberInfo.GetAttribute DisplayNameAttribute false if attr null return..
How to inject an attribute using a PostSharp attribute? http://stackoverflow.com/questions/7851365/how-to-inject-an-attribute-using-a-postsharp-attribute ProvideAspects object targetElement LocationInfo memberInfo LocationInfo targetElement if memberInfo.PropertyInfo.IsDefined.. LocationInfo memberInfo LocationInfo targetElement if memberInfo.PropertyInfo.IsDefined typeof XmlElementAttribute false memberInfo.PropertyInfo.IsDefined.. typeof XmlElementAttribute false memberInfo.PropertyInfo.IsDefined typeof XmlAttributeAttribute false yield..
Serializing null in JSON.NET http://stackoverflow.com/questions/8833961/serializing-null-in-json-net public NullableValueProvider MemberInfo memberInfo Type underlyingType _underlyingValueProvider new DynamicValueProvider.. _underlyingValueProvider new DynamicValueProvider memberInfo _defaultValue Activator.CreateInstance underlyingType public..
|