Exemple #1
0
        public static EModel CreateModelFromObject(object value, Type type)
        {
            EModel model = CreateModelFromBuilder(EClone.GetCloneBuilder(value, type), type);

            model.Value = value;
            return(model);
        }
Exemple #2
0
        public ComplexType LField(string fieldName)
        {
            FieldInfo info = Struction.Fields[fieldName];
            Type type = info.FieldType;

            //静态字段
            if (info.IsStatic)
            {
                if (type.IsValueType && !type.IsPrimitive)
                {
                    il.REmit(OpCodes.Ldsflda, info);
                }
                else
                {
                    il.REmit(OpCodes.Ldsfld, info);
                }
            }
            else
            {
                //加载地址
                This();
                if (type.IsValueType && !type.IsPrimitive)
                {
                    il.REmit(OpCodes.Ldflda, info);
                }
                else
                {
                    il.REmit(OpCodes.Ldfld, info);
                }
            }
            //如果单独加载了bool类型的值
            il.BoolInStack(type);
            return EModel.CreateModelFromAction(null, type);
        }
Exemple #3
0
        public EModel Dup()
        {
            ILGenerator il = ThreadCache.GetIL();

            il.Dup();
            return(EModel.CreateModelFromAction(null, _typeHandler));
        }
Exemple #4
0
        public static EModel CreateDynamicClass(string classKey, int parameterIndex)
        {
            EModel instance = null;

            if (ClassCache.DynamicClassDict.ContainsKey(classKey))
            {
                Type type = ClassCache.DynamicClassDict[classKey];
                instance = new EModel(parameterIndex, type);
            }
            return(instance);
        }
Exemple #5
0
        public static EModel CreateDynamicClass(string classKey, LocalBuilder builder)
        {
            EModel instance = null;

            if (ClassCache.DynamicClassDict.ContainsKey(classKey))
            {
                Type type = ClassCache.DynamicClassDict[classKey];
                instance = new EModel(builder, type);
            }
            return(instance);
        }
Exemple #6
0
        //操作动态类
        public static EModel CreateDynamicClass(string classKey)
        {
            EModel model = null;

            if (ClassCache.DynamicClassDict.ContainsKey(classKey))
            {
                Type type = ClassCache.DynamicClassDict[classKey];
                model = new EModel(type);
            }
            return(model);
        }
Exemple #7
0
 public ComplexType EMethod(string methodName, Action<ILGenerator> actionLoadValue)
 {
     MethodInfo info = Struction.Methods[methodName];
     if (info.IsStatic)
     {
         actionLoadValue(il);
         il.REmit(OpCodes.Call, info);
     }
     else
     {
         This();
         actionLoadValue(il);
         il.REmit(OpCodes.Callvirt, info);
     }
     il.BoolInStack(info.ReturnType);
     return EModel.CreateModelFromAction(null, Struction.TypeHandler);
 }
Exemple #8
0
        public static EMethod Load(EModel value)
        {
            EMethod instance;

            if (value.DelayAction != null)
            {
                instance = value.CompareType;
                value.DelayAction();
            }
            else
            {
                instance = value.TypeHandler;
                value.This();
            }

            return(instance);
        }
Exemple #9
0
        public ComplexType LPropertyValue(string propertyName)
        {
            PropertyInfo info = Struction.Properties[propertyName];
            Type type = info.PropertyType;
            MethodInfo method = info.GetGetMethod(true);

            //静态属性
            if (method.IsStatic)
            {
                il.REmit(OpCodes.Call, method);
            }
            else
            {
                This();
                il.REmit(OpCodes.Callvirt, method);
            }
            il.BoolInStack(type);
            return EModel.CreateModelFromAction(null, type);
        }
Exemple #10
0
        public ComplexType LFieldValue(string fieldName)
        {
            FieldInfo info = Struction.Fields[fieldName];
            Type type = info.FieldType;

            //静态字段
            if (info.IsStatic)
            {
                il.REmit(OpCodes.Ldsfld, info);
            }
            else
            {
                This();
                il.REmit(OpCodes.Ldfld, info);
            }
            //如果单独加载了bool类型的值
            if (type == typeof(bool))
            {
                ThreadCache.SetJudgeCode(OpCodes.Brfalse_S);
            }
            return EModel.CreateModelFromAction(null, type);
        }
Exemple #11
0
        public static EModel CreateModelFromAction(Action action, Type type)
        {
            EModel model = new EModel(type, action);

            return(model);
        }
Exemple #12
0
        public static EModel CreateModelFromBuilder(LocalBuilder builder, Type type)
        {
            EModel model = new EModel(builder, type);

            return(model);
        }
Exemple #13
0
        public static EModel CreateModelFromParameter(int parametersIndex, Type type)
        {
            EModel model = new EModel(parametersIndex, type);

            return(model);
        }