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); }
internal static object GetFieldValue(Type type, string fieldName) { Func <object> accessor; string key = AccessorKey.GetKey(type, fieldName); if (!accessors.TryGetValue(key, out accessor)) { var field = type.GetField(fieldName, BF.Public | BF.NonPublic | BF.Static); accessor = (field != null) ? EmitFieldAccesssor(field, type) : defaultAccessor; accessors.Add(key, accessor); } return(accessor()); }