예제 #1
0
파일: EModel.cs 프로젝트: wcfylcf/Natasha
        public static EModel CreateModelFromObject(object value, Type type)
        {
            EModel model = CreateModelFromBuilder(EClone.GetCloneBuilder(value, type), type);

            model.Value = value;
            return(model);
        }
예제 #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);
        }
예제 #3
0
        public EModel Dup()
        {
            ILGenerator il = ThreadCache.GetIL();

            il.Dup();
            return(EModel.CreateModelFromAction(null, _typeHandler));
        }
예제 #4
0
파일: EModel.cs 프로젝트: wcfylcf/Natasha
        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);
        }
예제 #5
0
파일: EModel.cs 프로젝트: wcfylcf/Natasha
        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);
        }
예제 #6
0
파일: EModel.cs 프로젝트: wcfylcf/Natasha
        //操作动态类
        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);
        }
예제 #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);
 }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #11
0
파일: EModel.cs 프로젝트: wcfylcf/Natasha
        public static EModel CreateModelFromAction(Action action, Type type)
        {
            EModel model = new EModel(type, action);

            return(model);
        }
예제 #12
0
파일: EModel.cs 프로젝트: wcfylcf/Natasha
        public static EModel CreateModelFromBuilder(LocalBuilder builder, Type type)
        {
            EModel model = new EModel(builder, type);

            return(model);
        }
예제 #13
0
파일: EModel.cs 프로젝트: wcfylcf/Natasha
        public static EModel CreateModelFromParameter(int parametersIndex, Type type)
        {
            EModel model = new EModel(parametersIndex, type);

            return(model);
        }