예제 #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
        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());
        }