c# Programming Glossary: fieldinfo
C# Using Reflection to copy base class properties http://stackoverflow.com/questions/1198886/c-sharp-using-reflection-to-copy-base-class-properties public void Update MyObject o MyObject copyObject ... FieldInfo myObjectFields o.GetType .GetFields BindingFlags.NonPublic BindingFlags.Public.. BindingFlags.Public BindingFlags.Instance foreach FieldInfo fi in myObjectFields fi.SetValue copyObject fi.GetValue o .. Type type MyObject source MyObject destination FieldInfo myObjectFields type.GetFields BindingFlags.NonPublic BindingFlags.Public..
C# object dumper http://stackoverflow.com/questions/1347375/c-sharp-object-dumper bool propWritten false foreach MemberInfo m in members FieldInfo f m as FieldInfo PropertyInfo p m as PropertyInfo if f null.. false foreach MemberInfo m in members FieldInfo f m as FieldInfo PropertyInfo p m as PropertyInfo if f null p null if propWritten.. if level depth foreach MemberInfo m in members FieldInfo f m as FieldInfo PropertyInfo p m as PropertyInfo if f null..
How to get C# Enum description from value? [duplicate] http://stackoverflow.com/questions/2650080/how-to-get-c-sharp-enum-description-from-value an Enum public static string GetEnumDescription Enum value FieldInfo fi value.GetType .GetField value.ToString DescriptionAttribute..
Get enum from enum attribute http://stackoverflow.com/questions/2787506/get-enum-from-enum-attribute typeof Als foreach Enum val in Enum.GetValues enumType FieldInfo fi enumType.GetField val.ToString StringValueAttribute attributes..
Is it possible to “steal” an event handler from one control and give it to another? http://stackoverflow.com/questions/293007/is-it-possible-to-steal-an-event-handler-from-one-control-and-give-it-to-anoth new EventHandler button1_Click Get secret click event key FieldInfo eventClick typeof Control .GetField EventClick BindingFlags.NonPublic..
C# String enums http://stackoverflow.com/questions/424366/c-sharp-string-enums 'StringValueAttribute' in the field's custom attributes FieldInfo fi type.GetField value.ToString StringValue attrs fi.GetCustomAttributes..
Get Enum from Description attribute [duplicate] http://stackoverflow.com/questions/4367723/get-enum-from-description-attribute 2 public static string GetDescription this Enum value FieldInfo field value.GetType .GetField value.ToString DescriptionAttribute..
MVC3 Razor DropDownListFor Enums http://stackoverflow.com/questions/4656758/mvc3-razor-dropdownlistfor-enums foreach var item in Enum.GetValues enumType FieldInfo fi enumType.GetField item.ToString var attribute fi.GetCustomAttributes..
c# - How do you get a variable's name as it was physically typed in its declaration? [duplicate] http://stackoverflow.com/questions/716399/c-sharp-how-do-you-get-a-variables-name-as-it-was-physically-typed-in-its-dec city MyCustomAttribute attr Type t typeof Person foreach FieldInfo field in t.GetFields if field.Name city do stuff when we find.. Name is 0 body.Member.Name Console.WriteLine Value is 0 FieldInfo body.Member .GetValue ConstantExpression body.Expression .Value..
How to remove all event handlers from a control http://stackoverflow.com/questions/91778/how-to-remove-all-event-handlers-from-a-control button1 private void RemoveClickEvent Button b FieldInfo f1 typeof Control .GetField EventClick BindingFlags.Static..
Find a private field with Reflection? http://stackoverflow.com/questions/95910/find-a-private-field-with-reflection Use BindingFlags.NonPublic and BindingFlags.Instance flags FieldInfo fields myType.GetFields BindingFlags.NonPublic BindingFlags.Instance..
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 memberEqual Expression.Equal Expression.Field x FieldInfo member Expression.Field y FieldInfo member break case MemberTypes.Property.. Expression.Field x FieldInfo member Expression.Field y FieldInfo member break case MemberTypes.Property memberEqual Expression.Equal..
Getting the object out of a MemberExpression? http://stackoverflow.com/questions/1613239/getting-the-object-out-of-a-memberexpression .Expression var ce ConstantExpression me.Expression var fieldInfo ce.Value.GetType .GetField me.Member.Name BindingFlags.Instance..
Reflection. What can we achieve using it? http://stackoverflow.com/questions/1897712/reflection-what-can-we-achieve-using-it ShapeName shapeName Type type shapeName.GetType FieldInfo fieldInfo type.GetField shapeName.ToString ShapeDescriptionAttribute attribs.. shapeName.ToString ShapeDescriptionAttribute attribs fieldInfo.GetCustomAttributes typeof ShapeDescriptionAttribute false as..
Get the Enum<T> value Description http://stackoverflow.com/questions/297299/get-the-enumt-value-description value string description value.ToString FieldInfo fieldInfo value.GetType .GetField description EnumDescriptionAttribute.. attributes EnumDescriptionAttribute fieldInfo.GetCustomAttributes typeof EnumDescriptionAttribute false if..
Extending Enums, Overkill? http://stackoverflow.com/questions/3015893/extending-enums-overkill type value.GetType Get fieldinfo for this type FieldInfo fieldInfo type.GetField value.ToString Get the stringvalue attributes.. the stringvalue attributes StringValueAttribute attribs fieldInfo.GetCustomAttributes typeof StringValueAttribute false as StringValueAttribute.. type value.GetType Get fieldinfo for this type FieldInfo fieldInfo type.GetField value.ToString Get the DisplayText attributes..
How to check if an object is nullable? http://stackoverflow.com/questions/374651/how-to-check-if-an-object-is-nullable object obj object o object bc foreach var fieldInfo in o.GetType .GetFields bindingFlags obj object fieldInfo.GetValue.. fieldInfo in o.GetType .GetFields bindingFlags obj object fieldInfo.GetValue o obj now refers to an object of type bool System.Boolean..
Sortable JqGrid using LINQ to MySQL (DbLinq) and Dynamic LINQ - Orderby doesn't work http://stackoverflow.com/questions/4078592/sortable-jqgrid-using-linq-to-mysql-dblinq-and-dynamic-linq-orderby-doesnt code above to the following System.Reflection.FieldInfo fieldInfo typeof Ticket .GetField sidx if fieldInfo null orderdData String.Compare.. fieldInfo typeof Ticket .GetField sidx if fieldInfo null orderdData String.Compare sord desc StringComparison.Ordinal.. StringComparison.Ordinal 0 from x in repository orderby fieldInfo.GetValue x null descending select x from x in repository orderby..
How to access the Description attribute on either a property or a const in C#? http://stackoverflow.com/questions/695730/how-to-access-the-description-attribute-on-either-a-property-or-a-const-in-c this Enum obj try System.Reflection.FieldInfo fieldInfo obj.GetType .GetField obj.ToString object attribArray fieldInfo.GetCustomAttributes.. obj.GetType .GetField obj.ToString object attribArray fieldInfo.GetCustomAttributes false if attribArray.Length 0 var attrib..
How do you copy a file into SharePoint using a WebService? http://stackoverflow.com/questions/787610/how-do-you-copy-a-file-into-sharepoint-using-a-webservice site Doclib UploadedDocument.xml FieldInformation fieldInfo new FieldInformation FieldInformation fields fieldInfo CopyResult.. fieldInfo new FieldInformation FieldInformation fields fieldInfo CopyResult resultsArray using Copy copyService new Copy copyService.Credentials..
|