コード例 #1
0
ファイル: ClassHelperTest.cs プロジェクト: zyj0021/DbEntry
        public void TestIt()
        {
            var o = new ClassHelperTest();

            ClassHelper.CallFunction(o, "TestPublic", (byte)18);
            Assert.AreEqual(CallType.Public, ct);
            Assert.AreEqual(18, o.bn);

            ClassHelper.CallFunction(o, "TestPrivate", 23);
            Assert.AreEqual(CallType.Private, ct);
            Assert.AreEqual(23, o.num);

            ClassHelper.CallFunction(o, "TestStatic", "OK");
            Assert.AreEqual(CallType.Static, ct);
            Assert.AreEqual("OK", str);
        }
コード例 #2
0
        public virtual string Update(long n)
        {
            var ctx = ModelContext.GetInstance(typeof(T));
            var obj = DbEntry.GetObject <T>(n);

            foreach (MemberHandler m in ctx.Info.Members)
            {
                if (m.Is.RelationField)
                {
                    continue;
                }
                if (!m.Is.AutoSavedValue && !m.Is.DbGenerate)
                {
                    string s = HttpContextHandler.Instance[ControllerName + "[" + m.Name.ToLower() + "]"];
                    if (m.Is.LazyLoad)
                    {
                        object       ll = m.MemberInfo.GetValue(obj);
                        PropertyInfo pi = m.MemberInfo.MemberType.GetProperty("Value");
                        object       v  = ControllerHelper.ChangeType(s, m.MemberType.GetGenericArguments()[0]);
                        pi.SetValue(ll, v, null);
                        // TODO: get rid of use such method.
                        ClassHelper.CallFunction(obj, "m_ColumnUpdated", m.Name);
                    }
                    else
                    {
                        m.MemberInfo.SetValue(obj, ControllerHelper.ChangeType(s, m.MemberType));
                    }
                }
            }
            if (obj is DbObjectSmartUpdate)
            {
                (obj as DbObjectSmartUpdate).Save();
            }
            else
            {
                DbEntry.Save(obj);
            }
            Flash.Notice = string.Format("{0} was successfully updated", ControllerName);
            return(UrlTo().Action("show").Parameters(n));
        }
コード例 #3
0
ファイル: DebugLogRecorder.cs プロジェクト: zyj0021/DbEntry
 private static void DebugPrint(string msg, params object[] os)
 {
     ClassHelper.CallFunction(typeof(Debug), "Print", msg, os);
 }
コード例 #4
0
ファイル: CommonTest.cs プロジェクト: zyj0021/DbEntry
        public void TestConvertType8()
        {
            var i = (DateTime?)ClassHelper.CallFunction(typeof(SmartPageBase), "GetValue", "2008-9-10", true, "test", typeof(DateTime?));

            Assert.IsTrue(new DateTime(2008, 9, 10) == i);
        }
コード例 #5
0
ファイル: CommonTest.cs プロジェクト: zyj0021/DbEntry
        public void TestConvertType7()
        {
            var i = (int?)ClassHelper.CallFunction(typeof(SmartPageBase), "GetValue", "12", false, "test", typeof(int));

            Assert.IsTrue(12 == i);
        }
コード例 #6
0
ファイル: CommonTest.cs プロジェクト: zyj0021/DbEntry
        public void TestConvertType5()
        {
            var i = ClassHelper.CallFunction(typeof(SmartPageBase), "GetValue", "aa", true, "test", typeof(int?));

            Assert.IsTrue(null == i);
        }
コード例 #7
0
ファイル: CommonTest.cs プロジェクト: zyj0021/DbEntry
 public void TestConvertType4()
 {
     ClassHelper.CallFunction(typeof(SmartPageBase), "GetValue", "", false, "test", typeof(int?));
 }
コード例 #8
0
ファイル: CommonTest.cs プロジェクト: zyj0021/DbEntry
        public void TestConvertType3()
        {
            var i = (string)ClassHelper.CallFunction(typeof(SmartPageBase), "GetValue", "", true, "test", typeof(string));

            Assert.IsTrue("" == i); //??
        }
コード例 #9
0
        protected override void DeriveParameters(IDbCommand e)
        {
            var type = Type.GetType("System.Data.OleDb.OleDbCommandBuilder, System.Data.OleDb");

            ClassHelper.CallFunction(type, "DeriveParameters", e);
        }