예제 #1
0
        internal static int RegisterField(Type type, string fieldName)
        {
            int key = AccessorKey.Make(type, fieldName);
            Func <object, object> accessor;

            if (!keyAccessors.TryGetValue(key, out accessor))
            {
                var field = type.GetField(fieldName, BF.Public | BF.NonPublic | BF.Instance);
                accessor = (field != null) ? FieldAccessor.EmitFieldAccesssor(field, type) : defaultAccessor;
                keyAccessors.Add(key, accessor);
            }
            return(key);
        }
예제 #2
0
 public static object GetDefaultValue <T>(this T instance)
 {
     return(FieldAccessor <T> .GetFieldValue(instance));
 }
예제 #3
0
 public static object GetValue <T>(this T instance, int fieldKey)
 {
     return(FieldAccessor <T> .GetFieldValue(instance, fieldKey));
 }
예제 #4
0
 public static object GetValue(object instance, Type type, string fieldName)
 {
     return(FieldAccessor.GetFieldValue(instance, type, fieldName));
 }
예제 #5
0
 public static int Register <T>(string fieldName, bool defaultField = false)
 {
     return(FieldAccessor <T> .RegisterField(fieldName, defaultField));
 }
예제 #6
0
 public static object GetValue <T>(this T instance, string fieldName)
 {
     return(FieldAccessor <T> .GetFieldValue(instance, fieldName));
 }
예제 #7
0
 public static object GetValue(object instance, int key)
 {
     return(FieldAccessor.GetFieldValue(instance, key));
 }
예제 #8
0
 public static int Register(string fieldName, Type type)
 {
     return(FieldAccessor.RegisterField(type, fieldName));
 }