System.Reflection.FieldInfo.GetRawConstantValue C# (CSharp) Method

GetRawConstantValue() public method

public GetRawConstantValue ( ) : Object
return Object
        public virtual Object GetRawConstantValue() { throw new NotSupportedException(Environment.GetResourceString("NotSupported_AbstractNonCLS")); }

Usage Example

Esempio n. 1
0
 private static void PopulateField(System.Reflection.FieldInfo field, string value, T target)
 {
     if (field.FieldType == typeof(int))
     {
         field.SetValue(target, ParseInt(value));
     }
     else if (field.FieldType == typeof(string))
     {
         field.SetValue(target, value);
     }
     else if (field.FieldType == typeof(float))
     {
         field.SetValue(target, ParseFloat(value));
     }
     else if (field.FieldType == typeof(bool))
     {
         field.SetValue(target, value == "true");
     }
     else if (field.FieldType.IsEnum)
     {
         System.Reflection.FieldInfo val = field.FieldType.GetField(value.Replace(' ', '_'));
         if (val != null)
         {
             field.SetValue(target, val.GetRawConstantValue());
         }
         else
         {
             field.SetValue(target, field.FieldType.GetField("nil").GetRawConstantValue());
         }
     }
 }
All Usage Examples Of System.Reflection.FieldInfo::GetRawConstantValue