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); }
public static object GetDefaultValue <T>(this T instance) { return(FieldAccessor <T> .GetFieldValue(instance)); }
public static object GetValue <T>(this T instance, int fieldKey) { return(FieldAccessor <T> .GetFieldValue(instance, fieldKey)); }
public static object GetValue(object instance, Type type, string fieldName) { return(FieldAccessor.GetFieldValue(instance, type, fieldName)); }
public static int Register <T>(string fieldName, bool defaultField = false) { return(FieldAccessor <T> .RegisterField(fieldName, defaultField)); }
public static object GetValue <T>(this T instance, string fieldName) { return(FieldAccessor <T> .GetFieldValue(instance, fieldName)); }
public static object GetValue(object instance, int key) { return(FieldAccessor.GetFieldValue(instance, key)); }
public static int Register(string fieldName, Type type) { return(FieldAccessor.RegisterField(type, fieldName)); }