Пример #1
0
        public override void Cache(ConstructorInfo info)
        {
            if (_keyMap.TryAdd(info, new Constructor()))
            {
                _keyMap[info].ConstructorInfo = info;
                _nameMap.TryAdd(_keyMap[info].FullName, _keyMap[info]);
                _keyMap[info].ParamerTypies = info.GetParameterTypes();

                if (_keyMap[info].ParamerTypies.Length == 0)
                {
                    _keyMap[info].DefaultInvoker = DynamicMethodDelegateFatory.CreateDefaultConstructor(info.DeclaringType);
                    _defaultContructor           = _keyMap[info];
                }
                else
                {
                    _keyMap[info].Invoker = DynamicMethodDelegateFatory.CreateParameterizedConstructor(info);
                }

                var i = 0;

                _keyMap[info].ParameterNames = new string[info.GetParameters().Length];

                foreach (var item in info.GetParameters())
                {
                    _keyMap[info].Parameters.Cache(item);
                    _keyMap[info].ParameterNames[i] = item.Name;
                    i++;
                }

                foreach (var item in info.GetCustomAttributes(true))
                {
                    _keyMap[info].Attributes.Cache((Attribute)item);
                }
            }
        }
Пример #2
0
        public override void Cache(FieldInfo info)
        {
            if (_keyMap.TryAdd(info, new Field()))
            {
                _nameMap.TryAdd(info.Name, _keyMap[info]);
                _keyMap[info].FieldInfo = info;
                _keyMap[info].Getter    = DynamicMethodDelegateFatory.CreateFieldGetter(info);
                _keyMap[info].Setter    = DynamicMethodDelegateFatory.CreateFiledSetter(info);

                foreach (var item in info.GetCustomAttributes())
                {
                    _keyMap[info].Attributes.Cache(item);
                }
            }
        }
Пример #3
0
        public void Cache(MethodInfo info)
        {
            if (_keyMap.TryAdd(info, new Method()))
            {
                _keyMap[info].MethodInfo = info;
                _keyMap[info].FullName   = info.GetMethodName();

                _nameMap.TryAdd(_keyMap[info].Name, new List <Method>());
                _nameMap[info.Name].Add(_keyMap[info]);

                _keyMap[info].ParamerTypies = info.GetParameterTypes();
                _keyMap[info].Invoker       = DynamicMethodDelegateFatory.CreateMethodCall(info);

                foreach (var item in info.GetParameters())
                {
                    _keyMap[info].Parameters.Cache(item);
                }

                foreach (var item in info.GetCustomAttributes(true))
                {
                    _keyMap[info].Attributes.Cache((Attribute)item);
                }
            }
        }