Exemplo n.º 1
0
        /// <summary>
        /// 初始化必要的构造参数。
        /// </summary>
        public SqlBuilder()
        {
            AliasCache = new ReferenceCache <string>();
            Builder    = new StringBuilder();

            XTypeInfo = XTypeInfo.Create(GetType(), XBindingFlags.Default | XBindingFlags.NonPublic);

            aliasIndex = 0;
        }
Exemplo n.º 2
0
    static AspNetJsonExecutor()
    {
        var xTypeInfo = XTypeInfo.Create <TJsonResult>(
            XBindingFlags.Public |
            XBindingFlags.Instance |
            XBindingFlags.Property);

        valueProperty       = xTypeInfo.GetProperty("Value") ?? xTypeInfo.GetProperty("Data") ?? throw new NotSupportedException("Value");
        settingsProperty    = xTypeInfo.GetProperty("SerializerSettings") ?? throw new NotSupportedException("SerializerSettings");
        statusProperty      = xTypeInfo.GetProperty("StatusCode") ?? throw new NotSupportedException("StatusCode");
        contentTypeProperty = xTypeInfo.GetProperty("ContentType") ?? throw new NotSupportedException("ContentType");
    }
Exemplo n.º 3
0
        public void TypeTest()
        {
            var xTypeInfo = XTypeInfo.Create <Tester>(XBindingFlags.Default | XBindingFlags.Static | XBindingFlags.NonPublic);

            var obj = new Tester();

            obj.public_event_action += null;

            xTypeInfo.GetEvent("public_event_func").AddEventHandler(obj, null);
            xTypeInfo.GetEvent("public_event_func").AddEventHandler(obj, null);

            Assert.AreEqual(2, obj.public_event_func_count);

            xTypeInfo.GetEvent("public_event_func").RemoveEventHandler(obj, null);

            Assert.AreEqual(1, obj.public_event_func_count);

            xTypeInfo.GetField("private_field_string").SetValue(obj, "F**k");

            Assert.AreEqual("F**k", xTypeInfo.GetField("private_field_string").GetValue(obj));


            xTypeInfo.GetField("public_field_int").SetValue(obj, 999);

            Assert.AreEqual(999, xTypeInfo.GetField("public_field_int").GetValue(obj));



            xTypeInfo.GetProperty("public_property_int").SetValue(obj, 123);

            Assert.AreEqual(123, xTypeInfo.GetProperty("public_property_int").GetValue(obj));


            xTypeInfo.GetProperty("private_property_string").SetValue(obj, "Dogwei");

            Assert.AreEqual("Dogwei", xTypeInfo.GetProperty("private_property_string").GetValue(obj));