Exemple #1
0
        public void TestMethod()
        {
            Delegate test = EHandler.CreateMethod <ulong>((il) =>
            {
                EModel modelHandler = EModel.CreateModel <MethodStruct>().UseDefaultConstructor();
                EMethod.Load(modelHandler).ExecuteMethod("GetULongMax");
            }).Compile();
            Func <ulong> action = (Func <ulong>)test;

            Assert.Equal(ulong.MaxValue, action());

            test = EHandler.CreateMethod <ulong>((il) =>
            {
                EModel modelHandler = EModel.CreateModel <MethodStruct>().UseDefaultConstructor();
                EMethod.Load(modelHandler).ExecuteMethod("GetULongMin");
            }).Compile();
            action = (Func <ulong>)test;
            Assert.Equal(ulong.MinValue, action());

            test = EHandler.CreateMethod <string>((il) =>
            {
                EModel modelHandler = EModel.CreateModel <MethodStruct>().UseDefaultConstructor();
                EVar param1         = "Hello";
                EMethod.Load(modelHandler).ExecuteMethod <string, string>("GetString", param1, " World");
            }).Compile();
            Func <string> action1 = (Func <string>)test;

            Assert.Equal("Hello World", action1());
        }
Exemple #2
0
        public List <EModel> GetMyTeamEmployee(int emp_id)
        {
            List <EModel> employeeli = new List <EModel>();

            using (SqlConnection con = new SqlConnection(connection()))
            {
                using (SqlCommand cmd = new SqlCommand("Prc_GetMyTeamEmployee", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@emp_id", emp_id);
                    con.Open();
                    SqlDataReader dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        EModel employee = new EModel();
                        employee.Empcode       = dr["EMPLOYEE_CODE"].ToString();
                        employee.Name          = dr["FULL_NAME"].ToString();
                        employee.FirstName     = dr["FIRST_NAME"].ToString();
                        employee.Dob           = dr["DOB"].ToString();
                        employee.Doj           = dr["DOJ"].ToString();
                        employee.DepartmentID  = dr["DEPARTMENTID"].ToString();
                        employee.DesignationID = dr["DESIGNATIONID"].ToString();
                        employee.Location      = dr["LOCATION"].ToString();
                        employee.Email         = dr["EMAIL"].ToString();
                        employee.Status        = dr["STATUS"].ToString();
                        employee.Person_id     = Convert.ToInt32(dr["PERSON_ID"].ToString());
                        employee.Sr_No         = Convert.ToInt32(dr["SR_NO"].ToString());
                        employee.Profile_Img   = dr["PROFILE_IMG"].ToString();
                        employeeli.Add(employee);
                    }
                    con.Close();
                }
            }
            return(employeeli);
        }
Exemple #3
0
        public void TestProperty()
        {
            PropertyStruct model = new PropertyStruct();

            model.ValueProperty = 100;
            model.RefProperty   = "Test";
            PropertyStruct.StaticRefProeprty   = "Static";
            PropertyStruct.StaticValueProperty = 200;
            Delegate test = EHandler.CreateMethod <PropertyStruct>((il) =>
            {
                EModel modelHandler = EModel.CreateModelFromObject(model);
                modelHandler.Set("ValueProperty", modelHandler.DLoad("ValueProperty").Operator + modelHandler.DLoad("StaticValueProperty").DelayAction);
                modelHandler.Set("StaticValueProperty", modelHandler.DLoad("ValueProperty").Operator + modelHandler.DLoad("StaticValueProperty").DelayAction);
                modelHandler.Set("RefProperty", modelHandler.DLoad("RefProperty").Operator + modelHandler.DLoad("StaticRefProeprty").DelayAction);
                modelHandler.Load();
            }).Compile();
            Func <PropertyStruct> action = (Func <PropertyStruct>)test;

            PropertyStruct.StaticValueProperty = 200;
            PropertyStruct result = action();

            Assert.Equal((ulong)300, result.ValueProperty);
            Assert.Equal((ulong)500, PropertyStruct.StaticValueProperty);
            Assert.Equal("TestStatic", result.RefProperty);
        }
Exemple #4
0
        public static SetterDelegate SetterFunc(ClassStruction model, PropertyInfo info)
        {
            if (info.GetSetMethod(true) == null || info.GetSetMethod(true).IsPrivate)
            {
                return(null);
            }
            return((SetterDelegate)(EHandler.CreateMethod <object, object, ENull>((til) =>
            {
                LocalBuilder builder = null;
                if (!info.GetSetMethod(true).IsStatic)
                {
                    builder = til.DeclareLocal(model.TypeHandler);
                    til.REmit(OpCodes.Ldarg_0);
                    til.UnPacket(model.TypeHandler);
                    til.REmit(OpCodes.Stloc_S, builder.LocalIndex);
                }

                EModel localModel = EModel.CreateModelFromBuilder(builder, model.TypeHandler);
                localModel.SProperty(info.Name, () =>
                {
                    til.REmit(OpCodes.Ldarg_1);
                    til.UnPacket(info.PropertyType);
                });
            }, "Setter " + info.DeclaringType.Name + " " + info.Name).Compile(typeof(SetterDelegate))));
        }
Exemple #5
0
        public void TestClass()
        {
            ComplexClassModel model = new ComplexClassModel();

            model.FieldModel        = new FieldStruct();
            model.PropertyModel     = new PropertyStruct();
            model.MethodModel       = new MethodStruct();
            ComplexClassModel.Model = model;

            Delegate test = EHandler.CreateMethod <ComplexClassModel>((il) =>
            {
                EVar ulongMinHandler = ulong.MinValue;
                EModel modelHandler  = EModel.CreateModelFromObject(model);
                modelHandler.Load("FieldModel").Set("RefField", "Hello");
                modelHandler.Load("PropertyModel").Set("RefProperty", "Hello");
                modelHandler.Load("PropertyModel").Set("ValueProperty", ulongMinHandler);
                modelHandler.Load("Model").Load("FieldModel").Set("RefField", "Hello1");
                modelHandler.Load("Model").Load("FieldModel").Set("ValueField", () => { EMethod.Load(modelHandler.DLoad("MethodModel").Operator).ExecuteMethod("GetULongMax"); });
                modelHandler.Load();
            }).Compile();
            Func <ComplexClassModel> action = (Func <ComplexClassModel>)test;
            ComplexClassModel        result = action();

            Assert.Equal((ulong)0, result.FieldModel.ValueField);
            Assert.Equal(ulong.MinValue, result.PropertyModel.ValueProperty);
            Assert.Equal("Hello", result.FieldModel.RefField);
            Assert.Equal("Hello", result.PropertyModel.RefProperty);
            Assert.Equal(ulong.MaxValue, ComplexClassModel.Model.FieldModel.ValueField);
            Assert.Equal("Hello1", ComplexClassModel.Model.FieldModel.RefField);
            //Assert.Equal("Hello1", model.FieldModel.RefField);
        }
Exemple #6
0
        public static void Create(Type type)
        {
            ClassStruction model = EModel.CreateModelFromAction(null, type).Struction;

            #region GetMethod
            Dictionary <string, GetterDelegate> GetDict = new Dictionary <string, GetterDelegate>();
            foreach (var item in model.Properties)
            {
                GetDict[item.Key] = GetterFunc(model, item.Value);
            }
            foreach (var item in model.Fields)
            {
                GetDict[item.Key] = GetterFunc(model, item.Value);
            }
            GetMethodDict[type] = GetDict;
            #endregion

            #region SetMethod
            Dictionary <string, SetterDelegate> SetDict = new Dictionary <string, SetterDelegate>();
            foreach (var item in model.Properties)
            {
                SetDict[item.Key] = SetterFunc(model, item.Value);
            }
            foreach (var item in model.Fields)
            {
                SetDict[item.Key] = SetterFunc(model, item.Value);
            }
            SetMethodDict[type] = SetDict;
            #endregion
        }
Exemple #7
0
        public static void TestCreateModel()
        {
            ClassBuilder builder = ClassBuilder.CreateModel("Hello");

            builder.CreateDefaultConstructor();
            builder.CreateField <string>("Age", FieldAttributes.Public);
            builder.CreateProperty <string>("Name");
            builder.CreateMethod <ENull>("Show", MethodAttributes.Public, (classModel) =>
            {
                classModel.SField("Age", "This is Age.");
                classModel.SProperty("Name", "This is name.");
                classModel.LPropertyValue("Name");
                classModel.il.REmit(OpCodes.Call, typeof(Console).GetMethod("WriteLine", new Type[] { typeof(string) }));
                classModel.il.REmit(OpCodes.Ret);
            });
            builder.EndBuilder();
            Delegate ShowDelegate = EHandler.CreateMethod <ENull>((il) =>
            {
                EModel Model = EModel.CreateDynamicClass("Hello").UseDefaultConstructor();
                EMethod.Load(Model).ExecuteMethod("Show");
                Model.LFieldValue("Age");
                Model.il.REmit(OpCodes.Call, typeof(Console).GetMethod("WriteLine", new Type[] { typeof(string) }));
            }).Compile();

            ((Action)ShowDelegate)();
        }
Exemple #8
0
 //各种数据给我就能入栈
 public static void NoErrorLoad(this ILGenerator il, object value, Type type)
 {
     if (il.IsNullable(type))
     {
         if (value == null)
         {
             EModel model = EModel.CreateModel(type).UseDefaultConstructor();
             model.Load();
         }
         else
         {
             Action action = value as Action;
             if (action == null)
             {
                 il.NoErrorLoad(value, type.GenericTypeArguments[0]);
                 ConstructorInfo ctor = type.GetConstructor(new Type[] { type.GenericTypeArguments[0] });
                 il.REmit(OpCodes.Newobj, ctor);
             }
             else
             {
                 action();
                 ConstructorInfo ctor = type.GetConstructor(new Type[] { type.GenericTypeArguments[0] });
                 il.REmit(OpCodes.Newobj, ctor);
             }
         }
     }
     else
     {
         il.NoErrorLoad(value);
     }
 }
Exemple #9
0
        public void TestProperty()
        {
            ClassWithNullableModel model = new ClassWithNullableModel();

            model.ValueField    = 100;
            model.ValueProperty = null;
            ClassWithNullableModel.StaticValueField    = null;
            ClassWithNullableModel.StaticValueProperty = 200;
            Delegate test = EHandler.CreateMethod <ClassWithNullableModel>((il) =>
            {
                EModel modelHandler = EModel.CreateModelFromObject(model);

                modelHandler.Set("ValueProperty", modelHandler.DLoad("PrivateProperty").DLoad("Value").Operator + modelHandler.DLoad("StaticValueProperty").DLoad("Value").Operator);
                modelHandler.Set("ValueProperty", modelHandler.DLoad("PrivateProperty").DLoad("Value").Operator + modelHandler.DLoad("StaticValueProperty").DLoad("Value").Operator);
                modelHandler.Set("StaticValueProperty", modelHandler.DLoad("ValueProperty").DLoad("Value").Operator + modelHandler.DLoad("StaticValueProperty").DLoad("Value").Operator);
                modelHandler.Set("ValueField", modelHandler.DLoad("StaticValueProperty").DLoad("Value").Operator + modelHandler.DLoad("ValueField").DLoad("Value").Operator);
                modelHandler.Load();
            }).Compile();
            Func <ClassWithNullableModel> action = (Func <ClassWithNullableModel>)test;
            ClassWithNullableModel        result = action();

            Assert.Equal((ulong)201, result.ValueProperty);
            Assert.Equal((ulong)401, ClassWithNullableModel.StaticValueProperty);
            Assert.Equal((ulong)501, result.ValueField);
        }
Exemple #10
0
        public static void StaticClass()
        {
            Delegate ShowDelegate = EHandler.CreateMethod <ENull>((il) =>
            {
                EMethod methodInfoHelper = typeof(Console);
                EModel test = EModel.CreateModel <TestClass>().UseDefaultConstructor();

                test.SField("NormalField", 10);
                methodInfoHelper.ExecuteMethod <int>("WriteLine", test.LoadValue("NormalField"));

                test.SField("StaticField", 10);
                methodInfoHelper.ExecuteMethod <int>("WriteLine", test.LoadValue("StaticField"));
                test.SField("Ref_StaticField", "10");
                methodInfoHelper.ExecuteMethod <string>("WriteLine", test.LoadValue("Ref_StaticField"));

                test.SProperty("NormalProperty", 10);
                methodInfoHelper.ExecuteMethod <int>("WriteLine", test.LoadValue("NormalProperty"));
                test.SProperty("Ref_NormalProperty", "10");
                methodInfoHelper.ExecuteMethod <string>("WriteLine", test.LoadValue("Ref_NormalProperty"));

                test.SProperty("StaticProperty", 10);
                methodInfoHelper.ExecuteMethod <int>("WriteLine", test.LoadValue("StaticProperty"));
                test.SProperty("Ref_StaticProperty", "10");
                methodInfoHelper.ExecuteMethod <string>("WriteLine", test.LoadValue("Ref_StaticProperty"));
            }).Compile();

            ((Action)ShowDelegate)();
        }
Exemple #11
0
        public static void TestClassAndStruct()
        {
            //动态创建Action委托
            Delegate newMethod = EHandler.CreateMethod <ENull>((il) =>
            {
                EModel model = null;
                //测试类的字段
                //model = EModel.CreateModel<ClassField>().UseDefaultConstructor();
                //测试类的属性
                //model = EModel.CreateModel<ClassProperty>().UseDefaultConstructor();
                //测试结构体的字段
                model = EModel.CreateModel <StructField>();
                //测试结构体的属性
                //model = EModel.CreateModel<StructProperty>();
                model.Set("PublicName", "This is Public-Name");
                model.Set("PrivateName", "This is Private-Name");
                model.Set("PublicAge", 666);
                model.Set("PrivateAge", 666);

                EMethod method = typeof(Console);
                method.ExecuteMethod <string>("WriteLine", model.DLoadValue("PrivateName").DelayAction);
                method.ExecuteMethod <string>("WriteLine", model.LoadValue("PublicName"));
                method.ExecuteMethod <int>("WriteLine", model.LoadValue("PublicAge"));
                method.ExecuteMethod <int>("WriteLine", model.LoadValue("PrivateAge"));
            }).Compile();

            ((Action)newMethod)();
        }
Exemple #12
0
        public static void TestStructClone()
        {
            EReflector.Create(typeof(SingleModel));
            TestStruct t = new TestStruct();

            t.TEnum = TestEnum.Address;
            t.Set();
            t.Name  = "小明";
            t.Name1 = "小明1";
            t.Age   = 10;
            t.Age1  = 101;

            Delegate ShowDelegate = EHandler.CreateMethod <TestStruct>((il) =>
            {
                EMethod methodInfoHelper = typeof(Console);
                EModel model             = EModel.CreateModelFromObject(t);
                model.SField("PrivateFAge", 10);
                model.LFieldValue("PrivateFAge");
                methodInfoHelper.ExecuteMethod <int>("WriteLine");
                model.Load();
            }).Compile();
            TestStruct t2 = ((Func <TestStruct>)ShowDelegate)();

            Console.WriteLine(t2.Name);
            Console.WriteLine(t2.Age);
            Console.WriteLine(t2.Name1);
            Console.WriteLine(t2.Age1);
            t2.Show();
            Console.WriteLine(t.TEnum);
            Console.WriteLine(t2.TEnum);
        }
Exemple #13
0
        public static void TestClassClone()
        {
            SingleModel t = new SingleModel();

            t.TestStructArray    = new TestStruct[5];
            t.TestStructArray[3] = new TestStruct {
                Age = 666
            };
            t.TestClassArray     = new TestClass[15];
            t.TestClassArray[10] = new TestClass()
            {
                Name = "xxxx"
            };
            t.TestEnumArray     = new TestEnum[16];
            t.TestEnumArray[15] = TestEnum.Address;
            t.Name = "小明";
            t.Age  = 10;
            t.Set();
            Delegate ShowDelegate = EHandler.CreateMethod <SingleModel>((il) =>
            {
                EModel model = EModel.CreateModelFromObject(t);
                model.Load();
            }).Compile();
            SingleModel t2 = ((Func <SingleModel>)ShowDelegate)();

            Console.WriteLine(t2.Name);
            Console.WriteLine(t2.Age);
            t2.Show();
            Console.WriteLine(t2.TestStructArray[3].Age);
            Console.WriteLine(t2.TestClassArray[10].Name);
            Console.WriteLine(t2.TestEnumArray[15]);
        }
Exemple #14
0
        /// <summary>
        /// Factoryに登録されているModelを取得する.
        /// </summary>
        /// <param name="eModel">モデルに紐づく列挙値</param>
        /// <returns>
        /// Modelのインスタンス.
        /// </returns>
        /// <remarks>
        /// インスタンスの取得に失敗した場合、nullを返却する.
        /// </remarks>
        public AModel GetModel(EModel eModel)
        {
            AModel ret = null;

            modelTable.TryGetValue(eModel, out ret);

            return(ret);
        }
Exemple #15
0
        public static void T <T>()
        {
            ClassWithNullableModel model = new ClassWithNullableModel();

            model.ValueField    = 100;
            model.ValueProperty = null;
            ClassWithNullableModel.StaticValueField    = 100;
            ClassWithNullableModel.StaticValueProperty = 200;
            Delegate test = EHandler.CreateMethod <ClassWithNullableModel>((il) =>
            {
                EModel modelHandler = EModel.CreateModelFromObject(model);
                //EModel modelHandler = EModel.CreateModel<ClassWithNullableModel>().UseDefaultConstructor();
                //modelHandler.Set("<ValueProperty>k__BackingField", (ulong)100);
                //modelHandler.Set("ValueField", (ulong)100);
                //modelHandler.Set("StaticValueField", (ulong)100);
                //modelHandler.Set("ValueProperty", (ulong)100);
                //modelHandler.Set("<StaticValueProperty>k__BackingField", (ulong)300);
                //modelHandler.LoadValue("<ValueProperty>k__BackingField").Packet();
                //FieldInfo info = typeof(ClassWithNullableModel).GetField("<PrivateProperty>k__BackingField", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
                //il.REmit(OpCodes.Ldtoken, typeof(ClassWithNullableModel));
                //il.REmit(OpCodes.Call, ClassCache.ClassHandle);
                //il.REmit(OpCodes.Ldstr, "<PrivateProperty>k__BackingField");
                //il.REmit(OpCodes.Ldc_I4_S, 60);
                //il.REmit(OpCodes.Callvirt, ClassCache.FieldInfoGetter);
                //LocalBuilder field = il.DeclareLocal(typeof(FieldInfo));
                //il.REmit(OpCodes.Stloc_S, field.LocalIndex);
                //il.LoadBuilder(field);
                ////il.REmit(OpCodes.Callvirt, ClassCache.FieldInfoGetter);
                //modelHandler.InStackAndPacket();
                //il.REmit(OpCodes.Callvirt, ClassCache.FieldValueGetter);
                //, modelHandler.DLoad("PrivateProperty").DLoad("Value").DelayAction
                //modelHandler.Load("<PrivateProperty>k__BackingField").LoadValue("value");
                //EMethod.Load(typeof(Console)).ExecuteMethod<ulong>("WriteLine");
                //modelHandler.Set("ValueProperty", modelHandler.DLoad("PrivateProperty").DLoad("Value").DelayAction);
                //EMethod.Load(typeof(Console)).ExecuteMethod<ulong>("WriteLine", modelHandler.DLoad("ValueProperty").DLoad("Value").DelayAction);
                //EMethod.Load(typeof(Console)).ExecuteMethod<ulong>("WriteLine", modelHandler.DLoad("PrivateProperty").DLoad("Value").DelayAction);
                //modelHandler.LoadValue("ValueField").Packet();
                //EMethod.Load(typeof(Console)).ExecuteMethod<object>("WriteLine");
                //modelHandler.LoadValue("ValueProperty").Packet();
                //EMethod.Load(typeof(Console)).ExecuteMethod<object>("WriteLine");
                //modelHandler.LoadValue("StaticValueField").Packet();
                //EMethod.Load(typeof(Console)).ExecuteMethod<object>("WriteLine");
                //modelHandler.LoadValue("StaticValueProperty").Packet();
                //EMethod.Load(typeof(Console)).ExecuteMethod<object>("WriteLine");

                //EMethod.Load(typeof(Console)).ExecuteMethod<ulong>("WriteLine", modelHandler.DLoad("ValueField").DelayAction);
                //EMethod.Load(typeof(Console)).ExecuteMethod<object>("WriteLine", modelHandler.DLoad("StaticValueProperty").DelayAction);
                //modelHandler.Set("ValueProperty", modelHandler.DLoad("ValueProperty").Operator + modelHandler.DLoad("StaticValueProperty").DelayAction);
                //modelHandler.Set("StaticValueProperty", modelHandler.DLoad("ValueProperty").Operator + modelHandler.DLoad("StaticValueProperty").DelayAction);
                // modelHandler.Set("RefProperty", modelHandler.DLoad("RefProperty").Operator + modelHandler.DLoad("StaticRefProeprty").DelayAction);
                modelHandler.Load();
            }).Compile();
            Func <ClassWithNullableModel> action1 = (Func <ClassWithNullableModel>)test;
            ClassWithNullableModel        t       = action1();
        }
Exemple #16
0
	// Use this for initialization
    void Start()
    {
        Global.Instance.battle = this;
        _eModel = (EModel)Global.Instance.PVPMsg.result; 

        if (Global.Instance.PVPMsg != null)
        {
            _pvpModel = new PVPModel();
            _pvpModel.LoadAssetbundle();            
        }            
    }
Exemple #17
0
        public int DeleteUserById(int Id)
        {
            var        db = new EModel();
            userdetail ud = new userdetail();

            ud.UserID          = Id;
            db.Entry(ud).State = EntityState.Deleted;
            int retVal = db.SaveChanges();

            return(retVal);
        }
Exemple #18
0
        //获取链式调用model
        public static EModel GetLink(this ILGenerator il, EModel model, Type type)
        {
            EModel returnModel = EModel.CreateModelFromAction(null, type);

            returnModel._currentMemeberName = model._currentMemeberName;
            returnModel._currentPrivateType = model._currentPrivateType;
            model._currentPrivateType       = null;
            returnModel.CompareType         = model.CompareType;

            returnModel.PrewCallOption = model.TempOption;
            returnModel.PreCallType    = model.PreCallType;
            return(returnModel);
        }
 public ActionResult Edit(int id, EModel emodel)
 {
     try
     {
         EmployeeDBHandle edb = new EmployeeDBHandle();
         edb.UpdateDetails(emodel);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Exemple #20
0
        public ActionResult profile()
        {
            EModel data = new EModel();

            if (Session["emp_id"] != null)
            {
                data = dllemployee.GetEmployeeDetails(Session["emp_id"].ToString());
            }



            return(View(data));
        }
 public ActionResult Action(int id, EModel emodel)
 {
     try
     {
         EmployeeDBHandle edb = new EmployeeDBHandle();
         edb.Search(emodel);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Exemple #22
0
 public EModel GetAttributeModel(string attributeName)
 {
     attributeName += "Attribute";
     if (Struction.AttributeTree.ContainsKey(MemberName))
     {
         if (Struction.AttributeTree[MemberName].ContainsKey(attributeName))
         {
             object value = Struction.AttributeTree[MemberName][attributeName];
             return(EModel.CreateModelFromObject(value, value.GetType()));
         }
     }
     return(null);
 }
Exemple #23
0
        public int AddUser(string name, string email, int deptID)
        {
            var db = new EModel();
            var ud = new userdetail();

            ud.Name   = name;
            ud.email  = email;
            ud.Deptid = deptID;
            db.userdetail.Add(ud);
            int retval = db.SaveChanges();

            return(retval);
        }
Exemple #24
0
        /// <summary>
        /// 使用Natasha根据参数数组信息生成Command高速构建缓存
        /// </summary>
        /// <typeparam name="T">实际执行函数返回的类型</typeparam>
        /// <param name="sql">SQL语句</param>
        /// <param name="values">object参数数组</param>
        /// <returns>动态方法</returns>
        private static SqlDelegate <T> .GetCommandByObject GetEmitCommandCache <T>(string sql, object[] values)
        {
            Type returnType = typeof(T);

            if (!Cache.SqlCache.ContainsKey(returnType))
            {
                ModelAnalyser.Initialization(returnType);
            }

            Delegate newMethod = EHandler.CreateMethod <ERef <IDbCommand>, object[], ENull>((il) =>
            {
                EModel idbCommand = EModel.CreateModelFromParameter <IDbCommand>(0);
                idbCommand.UseRef();
                idbCommand.Set("CommandText", sql);

                EArray arrayArg       = EArray.CreateArrayFromParameter(1, typeof(object));
                EModel copyParameters = idbCommand.Load("Parameters");

                MatchCollection collection = ParameterRegex.Matches(sql);
                int length = collection.Count;
                for (int i = 0; i < length; i += 1)
                {
                    Type type = values[i].GetType();

                    string memberName = collection[i].Groups[1].Value;
                    copyParameters.Dup();
                    EModel copyParameter = EMethod.Load(idbCommand).ExecuteMethod("CreateParameter").Dup();
                    copyParameter.Set("ParameterName", "@".Append(memberName));
                    copyParameter.Dup().Set("DbType", (int)SqlTypes[type]);

                    if (type.IsPrimitive)
                    {
                        copyParameter.Dup().Set("Value", () => { arrayArg.LoadArray(i); });
                    }
                    else
                    {
                        EJudge.If(ENull.IsNull(() => { arrayArg.LoadArray(i); }))(() =>
                        {
                            copyParameter.Dup().Set("Value", EDBNull.LoadValue);
                        }).Else(() =>
                        {
                            copyParameter.Dup().Set("Value", () => { arrayArg.LoadArray(i); });
                        });
                    }
                    EMethod.Load <IList>().ExecuteMethod <object>("Add").Pop();
                }
                copyParameters.Pop();
            }).Compile(typeof(SqlDelegate <T> .GetCommandByObject));

            return((SqlDelegate <T> .GetCommandByObject)newMethod);
        }
Exemple #25
0
        public int UpdateUser(int id, string name, string email)
        {
            var db = new EModel();
            var ud = new userdetail();

            ud.UserID          = id;
            ud.email           = email;
            ud.Name            = name;
            db.Entry(ud).State = EntityState.Modified;

            int retVal = db.SaveChanges();

            return(retVal);
        }
Exemple #26
0
        public userdetail GetUserdetailbyId(int id)
        {
            var db   = new EModel();
            var usr  = from k in db.userdetail where k.UserID == id select k;
            var user = new userdetail();

            foreach (var item in usr)
            {
                user.Name   = item.Name;
                user.email  = item.email;
                user.Deptid = item.Deptid;
            }
            return(user);
        }
Exemple #27
0
        public static void ForeachClassArray()
        {
            TestClass[] testArray = new TestClass[5];
            for (int i = 0; i < testArray.Length; i += 1)
            {
                TestClass t = new TestClass();
                t.Name       = "T" + i;
                testArray[i] = t;
            }
            testArray[0].FieldNext = new TestStruct()
            {
                Name = "1", Age = 10
            };
            Delegate ShowDelegate = EHandler.CreateMethod <TestClass[]>((il) =>
            {
                EArray model = testArray;
                ELoop.For(model, (loadCurrentElement) =>
                {
                    EModel modelHandler = EModel.CreateModelFromAction <TestClass>(loadCurrentElement);
                    modelHandler.LField("FieldNext").LFieldValue("Age");
                    modelHandler.il.REmit(OpCodes.Call, typeof(Console).GetMethod("WriteLine", new Type[] { typeof(int) }));
                });
                model.Load();
            }).Compile();

            if (ShowDelegate != null)
            {
                TestClass[] result = ((Func <TestClass[]>)ShowDelegate)();
                for (int i = 0; i < result.Length; i += 1)
                {
                    result[i].Name = "T" + (i + 5);
                }
                Console.WriteLine(result[0].FieldNext.Age);
                Console.WriteLine("旧对象:");
                for (int i = 0; i < testArray.Length; i += 1)
                {
                    Console.WriteLine(testArray[i].Name);
                }
                Console.WriteLine("深度复制新对象:");
                for (int i = 0; i < result.Length; i += 1)
                {
                    Console.WriteLine(result[i].Name);
                }
            }
            else
            {
                Console.WriteLine("??");
            }
        }
Exemple #28
0
 public void OnModelChange()
 {
     UIToggle utCur = UIToggle.current;
     if(utCur != null && (utCur.value == true)){
         if(utCur.name.Equals("tg_create")){
             model = EModel.Create;
         }else if(utCur.name.Equals("tg_move")){
             model = EModel.Move;
         }else if(utCur.name.Equals("tg_rotate")){
             model = EModel.Rotate;
         }else if(utCur.name.Equals("tg_destroy")){
             model = EModel.Destroy;
         }else if(utCur.name.Equals("tg_create_player")){
             model = EModel.CreatePlayer;
         }
     }
 }
Exemple #29
0
        public List <userdetail> GetAllUser()
        {
            List <userdetail> userList = new List <userdetail>();
            EModel            db       = new EModel();
            var urList = from k in db.userdetail select k;

            foreach (var item in urList)
            {
                var usr = new userdetail();
                usr.Name   = item.Name;
                usr.email  = item.email;
                usr.Deptid = item.Deptid;
                userList.Add(usr);
            }

            return(userList);
        }
Exemple #30
0
        public static GetterDelegate GetterFunc(ClassStruction model, FieldInfo info)
        {
            return((GetterDelegate)(EHandler.CreateMethod <object, object>((til) =>
            {
                LocalBuilder builder = null;
                if (!info.IsStatic)
                {
                    builder = til.DeclareLocal(model.TypeHandler);
                    til.REmit(OpCodes.Ldarg_0);
                    til.UnPacket(model.TypeHandler);
                    til.REmit(OpCodes.Stloc_S, builder.LocalIndex);
                }

                EModel localModel = EModel.CreateModelFromBuilder(builder, model.TypeHandler);
                localModel.LFieldValue(info.Name).Packet();
            }, "Getter " + info.DeclaringType.Name + " " + info.Name).Compile(typeof(GetterDelegate))));
        }
Exemple #31
0
        public static void TestIf()
        {
            Delegate showResult = EHandler.CreateMethod <ENull>((il) =>
            {
                EMethod method = typeof(Console);

                EVar emit_A = EVar.CreateWithoutTempVar(10);
                EVar emit_B = EVar.CreateVarFromObject(20);

                TestClass t = new TestClass()
                {
                    Field = 10
                };
                t.PropertyName = "3";
                EModel model   = EModel.CreateModelFromObject(t);

                EJudge.If(emit_A == model.DLoadValue("Field").Operator)(() =>
                {
                    method.ExecuteMethod <string>("WriteLine", "相等");
                }).ElseIf(emit_A > emit_B)(() =>
                {
                    method.ExecuteMethod <int>("WriteLine", emit_A);
                }).Else(() =>
                {
                    method.ExecuteMethod <int>("WriteLine", emit_B);
                });



                EVar string_A = "6";
                EVar string_B = "2";

                EJudge.If(string_A == "1")(() =>
                {
                    method.ExecuteMethod <string>("WriteLine", string_A);
                }).ElseIf(string_A == model.DLoadValue("PropertyName").Operator)(() =>
                {
                    method.ExecuteMethod <string>("WriteLine", string_A);
                }).Else(() =>
                {
                    method.ExecuteMethod <string>("WriteLine", string_B);
                });
            }).Compile();

            ((Action)showResult)();
        }
Exemple #32
0
        public void TestProperty()
        {
            Delegate test = EHandler.CreateMethod <PropertyStruct>((il) =>
            {
                EModel modelHandler = EModel.CreateModel <PropertyStruct>().UseDefaultConstructor();
                modelHandler.Set("ValueProperty", ulong.MinValue);
                modelHandler.Set("StaticValueProperty", ulong.MaxValue);
                modelHandler.Set("RefProperty", "Hello World");
                modelHandler.Load();
            }).Compile();
            Func <PropertyStruct> action = (Func <PropertyStruct>)test;
            PropertyStruct        result = action();

            Assert.Equal(ulong.MinValue, result.ValueProperty);
            Assert.Equal(ulong.MaxValue, PropertyStruct.StaticValueProperty);
            Assert.Equal("Hello World", result.RefProperty);
        }
Exemple #33
0
 public void OnModelChange()
 {
     UIToggle utCur = UIToggle.current;
     if(utCur != null && (utCur.value == true)){
         if(utCur.name.Contains("tg_create")){
             model = EModel.Create;
             DataCache dc = utCur.gameObject.GetComponent<DataCache>();
             CurBuildItem = dc.data as BuildItem;
         }else if(utCur.name.Equals("tg_move")){
             model = EModel.Move;
         }else if(utCur.name.Equals("tg_rotate")){
             model = EModel.Rotate;
         }else if(utCur.name.Equals("tg_destroy")){
             model = EModel.Destroy;
         }
     }
 }