Exemplo n.º 1
0
 public PropAccessor(PropertyInfo prop)
 {
     Property      = prop;
     SetterInvoker = DynamicMethodHelper.BuildSetterInvoker(prop.GetSetMethod(true));
     GetterInvoker = DynamicMethodHelper.BuildGetterInvoker(prop.GetGetMethod(true));
     CanInvoker    = true;
 }
Exemplo n.º 2
0
        public TypeCachedInfo(Type type)
        {
            var properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public);

            PropInvokerDict = new Dictionary <string, PropAccessor>(properties.Length, StringComparer.OrdinalIgnoreCase);
            foreach (var prop in properties)
            {
                PropAccessor accessor = new PropAccessor(prop);
                PropInvokerDict[prop.Name] = accessor;
            }

            NewInvoker = DynamicMethodHelper.BuildConstructorInvoker(type);
        }
Exemplo n.º 3
0
        public TypeCachedInfo(Type modelType)
        {
            //构造委托
            NewInvoker = DynamicMethodHelper.BuildConstructorInvoker <TObject>(modelType);
            var Properties = modelType.GetProperties(BindingFlags.Instance | BindingFlags.Public);

            accessorDict = new Dictionary <string, Accessor>(Properties.Length);

            //var Fields = modelType.GetFields(BindingFlags.Instance | BindingFlags.Public);

            foreach (var prop in Properties)
            {
                string propName = prop.Name.ToUpper();
                accessorDict[propName] = new Accessor(prop);
            }
        }
Exemplo n.º 4
0
 public Accessor(PropertyInfo prop)
 {
     this.prop = prop;
     //自定义属性
     if (prop != null)
     {
         // var setMethod = prop.GetSetMethod(true);
         // if (setMethod != null)
         // {
         //     CanSet = true;
         //     setter = DynamicMethodHelper.BuildSetterInvoker(setMethod);
         // }
         var getMethod = prop.GetGetMethod(true);
         if (getMethod != null)
         {
             CanGet = true;
             getter = DynamicMethodHelper.BuildGetterInvoker(getMethod);
         }
     }
 }
Exemplo n.º 5
0
 private PropAccessor()
 {
     SetterInvoker = DynamicMethodHelper.BuildSetterInvoker(null);
     GetterInvoker = DynamicMethodHelper.BuildGetterInvoker(null);
     CanInvoker    = false;
 }