コード例 #1
0
 private static void ShouldBehaveSimilar(IMemberAccessor<TestA, string> ma, TestA a1)
 {
     Assert.That(ma.GetValue(a1), Is.EqualTo(a1.PropString));
     ma.SetValue(a1, "updated " + a1.PropString);
     Assert.That(ma.GetValue(a1), Is.EqualTo(a1.PropString));
     a1.PropString = "new " + a1.PropString;
     Assert.That(ma.GetValue(a1), Is.EqualTo(a1.PropString));
 }
コード例 #2
0
 private static void ShouldBehaveSimilar(IObjectMemberAccessor<double> oma, TestA a1)
 {
     Assert.That(oma.Value, Is.EqualTo(a1.Field1));
     oma.Value += 12.56;
     Assert.That(oma.Value, Is.EqualTo(a1.Field1));
     a1.Field1 -= 345;
     Assert.That(oma.Value, Is.EqualTo(a1.Field1));
 }
コード例 #3
0
        public void ExpressionEvaluator_Standalone_Valid_MethodResult()
        {
            var viewModel = new TestA() { TestProp = new TestA() };

            var evaluator = new ExpressionEvaluator() { AllowMethods = true };
            Assert.AreEqual(viewModel.GetType().GetMethod("Test"), evaluator.Evaluate("Test", viewModel));
            Assert.AreEqual(viewModel.GetType().GetMethod("Test"), evaluator.Evaluate("_root.Test", viewModel));
            Assert.AreEqual(viewModel.GetType().GetMethod("Test2"), evaluator.Evaluate("_root.TestProp.Test2", viewModel));
        }
コード例 #4
0
        public void TestPrivateProperty()
        {
            var a = new TestA();

            Assert.AreEqual(0, a.PrivateSetter);

            a.SetProtectedPropertyValue("PrivateSetter", 123);

            Assert.AreEqual(123, a.PrivateSetter);
        }
コード例 #5
0
ファイル: CacheTestClass.cs プロジェクト: EmilyEdna/XExten
        public void RedisCache_Test()
        {
            Caches.RedisConnectionString = "127.0.0.1:6379";
            TestA A = new TestA {
                Id = 1, Name = "123", PassWord = "******"
            };

            Caches.RedisCacheSet("key", A);
            Caches.RedisCacheGet <TestA>("key");
            Caches.RedisCacheRemove("key");
        }
コード例 #6
0
 public void ToClasses()
 {
     var Object1 = new TestA() { A = 10, B = "ASDF" };
     var Object2 = new TestB() { A = 20, B = "ZXCV" };
     TestB Result1 = Utilities.DataTypes.Conversion.Manager.To<TestA, TestB>(Object1, null);
     Assert.Equal(10, Result1.A);
     Assert.Equal("ASDF", Result1.B);
     TestA Result2 = Utilities.DataTypes.Conversion.Manager.To<TestB, TestA>(Object2, null);
     Assert.Equal(20, Result2.A);
     Assert.Equal("ZXCV", Result2.B);
 }
コード例 #7
0
ファイル: XExpTestClass.cs プロジェクト: zhangbo27/XExten
        public void SetProptertiesValue_Test()
        {
            Dictionary <string, Object> keyValues = new Dictionary <string, Object>
            {
                { "Id", 1 },
                { "Name", "李四" }
            };
            TestA A = new TestA();

            XExp.SetProptertiesValue <TestA>(keyValues, A);
        }
        public void Serialize_DoesNotSerializeSinceNotConfigured(string propName)
        {
            TestA ta = new TestA();
            ContractConfiguration <TestA> cc = new ContractConfiguration <TestA>();

            var json = JsonConvert.SerializeObject(ta, GetSettings(cc));

            JsonStringValidator jsAssert = new JsonStringValidator(json);

            Assert.IsFalse(jsAssert.HasProperty(propName));
        }
コード例 #9
0
        public void SetWithExistingType()
        {
            var context   = new BuildContext();
            var instance1 = new TestA();
            var instance2 = new TestA();

            context.Set(instance1);
            Assert.That(context.Get <TestA>(), Is.EqualTo(instance1));
            context.Set(instance2);
            Assert.That(context.Get <TestA>(), Is.EqualTo(instance2));
        }
コード例 #10
0
ファイル: EntityBaseTest.cs プロジェクト: ostat/Beef
 private Task CreateValueUpdateTask(TestA a)
 {
     return(new Task(() =>
     {
         var now = Cleaner.Clean(DateTime.Now);
         a.Id = now.Ticks;
         a.Text = now.ToLongDateString();
         a.Now = now;
         a.Time = now;
     }));
 }
コード例 #11
0
        public void Add_TwoDifferentObjectTypesWithSameId_Ok()
        {
            // arrange
            var objectToSave1 = new TestA();
            var objectToSave2 = new TestB();
            Guid id = Guid.NewGuid();

            this.database.Add(id, objectToSave1);

            // act / assert
            Assert.DoesNotThrow(() => this.database.Add(id, objectToSave2));
        }
コード例 #12
0
        public void Byte_Array_In_Test_Class_Is_Mapped_Correctly()
        {
            string testString = "this is a string that will later be converted to a byte array and other text blah blah blah I'm not sure what else to put here...";

            var testA = new TestA{Bytes = Encoding.ASCII.GetBytes(testString)};

            var testB = TypeAdapter.Adapt<TestA, TestB>(testA);

            var resultString = Encoding.ASCII.GetString(testB.Bytes);

            testString.ShouldEqual(resultString);
        }
コード例 #13
0
ファイル: CompareTest.cs プロジェクト: xu405049495/JMGF
 public void Test()
 {
     TestA a = new TestA()
     {
         Name = null
     };
     TestA b = new TestA()
     {
         Name = "",
     };
     var list = ComparerHelper.GetFieldModityRecords <TestA>(a, b);
 }
コード例 #14
0
        public void Add_TwoDifferentObjectTypesWithSameId_Ok()
        {
            // arrange
            var  objectToSave1 = new TestA();
            var  objectToSave2 = new TestB();
            Guid id            = Guid.NewGuid();

            this.database.Add(id, objectToSave1);

            // act / assert
            Assert.DoesNotThrow(() => this.database.Add(id, objectToSave2));
        }
コード例 #15
0
        public void SetValue_WhenValueExist_OverrideValue()
        {
            var context   = new BuildContext();
            var instance1 = new TestA();
            var instance2 = new TestA();

            context.SetValue(instance1);
            Assert.That(context.Values, Is.EqualTo(new[] { instance1 }));

            context.SetValue(instance2);
            Assert.That(context.Values, Is.EqualTo(new[] { instance2 }));
        }
コード例 #16
0
        public void Byte_Array_In_Test_Class_Is_Mapped_Correctly()
        {
            string testString = "this is a string that will later be converted to a byte array and other text blah blah blah I'm not sure what else to put here...";

            var testA = new TestA {
                Bytes = Encoding.ASCII.GetBytes(testString)
            };
            var testB        = Mapper.Map <TestA, TestB>(testA);
            var resultString = Encoding.ASCII.GetString(testB.Bytes);

            Assert.Equal(testString, resultString);
        }
コード例 #17
0
        static void Main(string[] args)
        {
            TestA a = new TestA();

            Console.WriteLine(a.Add(1, 2));

            TestB b = new TestB();

            Console.WriteLine(b.Minus(4, 2));

            Console.ReadKey();
        }
コード例 #18
0
ファイル: CacheTestClass.cs プロジェクト: EmilyEdna/XExten
        public void MongoDbCache_Test()
        {
            Caches.MongoDBConnectionString = "mongodb://*****:*****@127.0.0.1";
            Caches.DbName = "Test";
            TestA A = new TestA {
                Id = 1, Name = "123", PassWord = "******"
            };

            Caches.MongoDBCacheSet <TestA>(A);
            Caches.MongoDBCacheGet <TestA>(t => t.Id == 1);
            Caches.MongoDBCacheRemove <TestA>(t => t.Id == 1);
        }
コード例 #19
0
ファイル: LinqXTestClass.cs プロジェクト: EmilyEdna/XExten
 public void ToAutoMaps_Test()
 {
     TestA A = new TestA()
     {
         Id = 1, Name = "admin"
     };
     List <TestA> LA = new List <TestA>()
     {
         A
     };
     var res = LA.ToAutoMapper <TestA, TestB>();
 }
コード例 #20
0
ファイル: TestFactory.cs プロジェクト: ondister/Recog
        public static ITest CreateTest(EnumPTests test, pBaseEntities ge, fBaseEntities fe, bool isAlone)
        {
            ITest _gentest = null;

            switch (test)
            {
            case EnumPTests.KettellC:
                _gentest = new TestKettellC(ge, fe, isAlone);
                break;

            case EnumPTests.PNN:
                _gentest = new TestPnn(ge, fe, isAlone);
                break;

            case EnumPTests.Adaptability:
                _gentest = new TestD(ge, fe, isAlone);
                break;

            case EnumPTests.FPI:
                _gentest = new TestFPI(ge, fe, isAlone);
                break;

            case EnumPTests.KettellA:
                _gentest = new TestKettellA(ge, fe, isAlone);
                break;

            case EnumPTests.Modul2:
                _gentest = new TestMD(ge, fe, isAlone);
                break;

            case EnumPTests.Contrasts:
                _gentest = new TestContrasts(fe);
                break;

            case EnumPTests.Prognoz:
                _gentest = new TestP(ge, fe, isAlone);
                break;

            case EnumPTests.Addictive:
                _gentest = new TestA(ge, fe, isAlone);
                break;

            case EnumPTests.NPNA:
                _gentest = new TestNPN(ge, fe, isAlone);
                break;

            case EnumPTests.Leongard:
                _gentest = new TestL(ge, fe, isAlone);
                break;
            }
            return(_gentest);
        }
コード例 #21
0
ファイル: 方法.cs プロジェクト: Super0415/Csharp
    static void Main()
    {
        TestA A = new TestA();

        A.Addi();
        TestA B = new TestA();

        B.Addi();

        Console.WriteLine(A.i);

        Console.ReadLine();
    }
コード例 #22
0
        public void Test_Json()
        {
            TestA a = new TestA(Guid.NewGuid());

            var result = a.ToJson();

            Console.WriteLine(result);

            var temp    = result.ToObject <TestA>();
            var result1 = temp.ToJson();

            Console.WriteLine(result1);
        }
コード例 #23
0
        static void Main(string[] args)
        {
            /*
             *          TestA testa = new TestA();
             *          WriteLine(testa.Sum(1, 100));
             *
             *          TestB testb = new TestB();
             *          WriteLine(testb.Multifly(1, 20));
             */

            WriteLine(TestA.Sum(1, 100));
            WriteLine(TestB.Multifly(1, 20));
        }
        public void SetReferenceToNewObject()
        {
            int nullReferenceId;

            using (var populateSession = Domain.OpenSession())
                using (var transaction = populateSession.OpenTransaction()) {
                    var testA = new TestA {
                        Text = "Test A without Reference"
                    };
                    nullReferenceId = testA.Id;
                    transaction.Complete();
                }

            int anotherTestBTemporaryId;
            int anotherTestBRealId;

            using (var session = Domain.OpenSession(new SessionConfiguration(SessionOptions.ClientProfile)))
                using (session.Activate()) {
                    var nullReferenceEntity = session.Query.All <TestA>().FirstOrDefault(el => el.Id == nullReferenceId);
                    Assert.That(nullReferenceEntity, Is.Not.Null);
                    Assert.That(nullReferenceEntity.TestB, Is.Null);

                    var newTestB = new TestB {
                        Text = "Another test B"
                    };
                    Assert.That(newTestB.Id, Is.LessThan(0));
                    Assert.That(newTestB.Key.IsTemporary(Domain), Is.True);

                    anotherTestBTemporaryId   = newTestB.Id;
                    nullReferenceEntity.TestB = newTestB;

                    Assert.DoesNotThrow(() => session.SaveChanges());
                    Assert.That(nullReferenceEntity.TestB, Is.Not.Null);
                    Assert.That(nullReferenceEntity.TestB.Key.IsTemporary(Domain), Is.False);
                    anotherTestBRealId = nullReferenceEntity.TestB.Id;
                }

            using (var session = Domain.OpenSession(new SessionConfiguration(SessionOptions.ClientProfile)))
                using (session.Activate()) {
                    var testA = session.Query.All <TestA>().FirstOrDefault(el => el.Id == nullReferenceId);
                    Assert.That(testA, Is.Not.Null);

                    var testBTemporary = session.Query.All <TestB>().FirstOrDefault(el => el.Id == anotherTestBTemporaryId);
                    Assert.That(testBTemporary, Is.Null);

                    var testBReal = session.Query.All <TestB>().FirstOrDefault(el => el.Id == anotherTestBRealId);
                    Assert.That(testBReal, Is.Not.Null);

                    Assert.That(testA.TestB, Is.EqualTo(testBReal));
                }
        }
コード例 #25
0
        static void Main(string[] args)
        {
            List <TestA> list = new List <TestA>();

            for (int i = 0; i < 5; i++)
            {
                TestA a = new TestA()
                {
                    Id    = 12313213 + i,
                    Ids   = new int[] { 1213, 11, 1 },
                    Name  = "哈哈哈",
                    Names = new string[] { "嘿嘿", "AAA" },
                    B     = new TestB()
                    {
                        isSuccess = true,
                        Id        = 12132132 + i,
                        Data      = new byte[] { 1, 2, 255 }
                    },
                    As   = new TestA[] { },
                    Time = DateTime.Now
                };
                list.Add(a);
            }
            TestA A = new TestA()
            {
                Id    = 123,
                Ids   = null,
                Name  = null,
                Names = null,
                B     = null,
                As    = list.ToArray(),
                //Time = DateTime.Now,
                MyEnum = MyEnum.B
            };

            Stopwatch sw = new Stopwatch();

            sw.Start();
            var bytes = PacketSerializeHelper.SerializePacket(A);

            sw.Stop();
            Console.WriteLine("序列化耗时:" + sw.Elapsed.TotalSeconds);
            sw.Reset();
            sw.Start();
            TestA pack = PacketSerializeHelper.DeserializePacket <TestA>(bytes);

            sw.Stop();
            Console.WriteLine("反序列化耗时:" + sw.Elapsed.TotalSeconds);

            Console.Read();
        }
コード例 #26
0
ファイル: LinqXTestClass.cs プロジェクト: zhangbo27/XExten
 public void ToTable_Test()
 {
     TestA A = new TestA {
         Id = 1, Name = "张三"
     };
     List <TestA> Li = new List <TestA>
     {
         A
     };
     var dt  = A.ToTable();
     var dts = Li.ToTables();
     var A1  = dt.ToEntity <TestA>();
     var As  = dts.ToEntities <TestA>();
 }
コード例 #27
0
        public void Clone_test()
        {
            TestA a = new TestA
            {
                B = new TestB()
            };

            for (int i = 0; i < 1; i++)
            {
                var cloneA = a.Clone();
                ReferenceEquals(a, cloneA).ShouldBeFalse();
                ReferenceEquals(a.B, cloneA.B).ShouldBeFalse();
            }
        }
        public void Serialize_OverridePrivatePropertyName()
        {
            TestA ta = new TestA();

            ta.SetPrivateProp(1);
            ContractConfiguration <TestA> cc = new ContractConfiguration <TestA>();

            cc.Property("PrivateProp").HasName("private_prop");

            var json = JsonConvert.SerializeObject(ta, GetSettings(cc));

            JsonStringValidator jsAssert = new JsonStringValidator(json);

            Assert.IsTrue(jsAssert.HasPropertyWithValue("private_prop", 1));
        }
        public void Serialize_UnIgnorePrivateField()
        {
            TestA ta = new TestA();

            ta.SetIgnoredPrivateField(1);
            ContractConfiguration <TestA> cc = new ContractConfiguration <TestA>();

            cc.Field("ignoredPrivateField").Ignore(false).HasName("unignored_private_field");

            var json = JsonConvert.SerializeObject(ta, GetSettings(cc));

            JsonStringValidator jsAssert = new JsonStringValidator(json);

            Assert.IsTrue(jsAssert.HasPropertyWithValue("unignored_private_field", 1));
        }
コード例 #30
0
        public async Task Serialize_Happy_Path()
        {
            // ARRANGE
            var obj = new TestA()
            {
                Message = "Hello World"
            };
            var serializer = new JsonLogObjectSerializer();

            // ACT
            var result = await serializer.Serialize(obj);

            // ASSERT
            Assert.AreEqual("{\"message\":\"Hello World\"}", result);
        }
 public void MainTest()
 {
     using (var session = Domain.OpenSession(new SessionConfiguration(SessionOptions.ClientProfile | SessionOptions.AutoActivation))) {
         var NewTestA = new TestA {
             Text = "TestA"
         };
         new TestB {
             TestA = NewTestA, Text = "TestB"
         };
         // Wrong ReferencingEntity "TestB" instead of "TestC" with Association "TestC-TestA-TestA"
         var references = ReferenceFinder.GetReferencesTo(NewTestA).ToList();
         // Exception
         Assert.DoesNotThrow(() => NewTestA.Remove());
     }
 }
コード例 #32
0
ファイル: Program.cs プロジェクト: sonny6310/csharpGit
        // 코드 6-6: Main() 메서드는 클래스 메서드
        static void Main(string[] args)
        {
            // 코드 6-2 호출
            TestA testA = new TestA();

            Console.WriteLine(testA.Multi(52, 273));
            Console.WriteLine(testA.Multi(103, 32));
            Console.WriteLine();

            // 코드 6-3 호출
            TestB testB = new TestB();

            testB.Print();
            testB.Print();
            testB.Print();
        }
コード例 #33
0
        private List <TestA> GetTestData()
        {
            var result = new List <TestA>();

            for (int i = 0; i < 5; i++)
            {
                var temp = new TestA
                {
                    Name       = "Test" + i.ToString(),
                    SortNumber = i,
                    Remarks    = "Remarks" + i.ToString()
                };
                result.Add(temp);
            }
            return(result);
        }
        public void Serialize_UnnamedProperty()
        {
            TestA ta = new TestA()
            {
                UnnamedProperty = 1
            };
            ContractConfiguration <TestA> cc = new ContractConfiguration <TestA>();

            cc.Property(ta => ta.UnnamedProperty).HasName("unnamed_property");

            var json = JsonConvert.SerializeObject(ta, GetSettings(cc));

            JsonStringValidator jsAssert = new JsonStringValidator(json);

            Assert.IsTrue(jsAssert.HasPropertyWithValue("unnamed_property", 1));
        }
        public void Serialize_OverridePropertyName()
        {
            TestA ta = new TestA()
            {
                IdA = 1
            };
            ContractConfiguration <TestA> cc = new ContractConfiguration <TestA>();

            cc.Property(ta => ta.IdA).HasName("id_a");

            var json = JsonConvert.SerializeObject(ta, GetSettings(cc));

            JsonStringValidator jsAssert = new JsonStringValidator(json);

            Assert.IsTrue(jsAssert.HasPropertyWithValue("id_a", 1));
        }
コード例 #36
0
        public void RemoveUnsavedReferenceClientTest()
        {
            using (var session = Domain.OpenSession(new SessionConfiguration(SessionOptions.ClientProfile))) {
                var testA = new TestA(session)
                {
                    Text = "A"
                };
                var testB = new TestB(session)
                {
                    Text = "B", TestA = testA
                };

                testB.Remove();
                testA.Remove();
            }
        }
コード例 #37
0
        public void TestFromAtoB()
        {
            var mapper = new ExpressionMapper<TestA, TestB>()
                .Map(x => x.AValue1, x => x.BValue1)
                .Map(x => x.AValue2, x => x.BValue2);

            var testA = new TestA()
                        {
                            AValue1 = "TestValue",
                            AValue2 = 42
                        };
            var testB = mapper.MapAtoB(testA);

            Assert.AreEqual("TestValue", testB.BValue1);
            Assert.AreEqual(42, testB.BValue2);
        }
コード例 #38
0
        public void TestMemberValueAccessorsPerfomance()
        {
            const int total = 1000000;
            TestA a = new TestA { PropString = "test", PropInt = 48 };

            var sw = Stopwatch.StartNew();
            for (int i = 0; i < total; i++)
            {
                string v = a.PropString;
                a.PropString = "new data";
                int i1 = a.PropInt;
                a.PropInt = i;
            }
            sw.Stop();

            Console.WriteLine("Native C# time: " + sw.ElapsedMilliseconds);

            var mva = new MemberValueAccessor(typeof(TestA).GetProperties());
            sw.Restart();
            for (int i = 0; i < total; i++)
            {
                object v = mva.GetValue("PropString", a);
                mva.SetValue("PropString", a, "new data");

                object i1 = mva.GetValue("PropInt", a);
                mva.SetValue("PropInt", a, i);
            }
            sw.Stop();

            Console.WriteLine("FastRT time: " + sw.ElapsedMilliseconds);

            PropertyInfo pStr = a.GetType().GetProperty("PropString");
            PropertyInfo pInt = a.GetType().GetProperty("PropInt");

            sw.Restart();
            for (int i = 0; i < total; i++)
            {
                object v = pStr.GetValue(a, null);
                pStr.SetValue(a, "new data", null);

                object i1 = pInt.GetValue(a, null);
                pInt.SetValue(a, i);
            }
            sw.Stop();

            Console.WriteLine("Reflection time: " + sw.ElapsedMilliseconds);
        }
コード例 #39
0
    // Start is called before the first frame update
    void Start()
    {
        TestA testA = new TestA();

        testA.AAA = "asd";
        testA.BBB = 111;
        Vect3 vect3 = new Vect3();

        vect3.X     = 1.1f;
        vect3.Y     = 1.2f;
        vect3.Z     = 1.4f;
        testA.vect3 = vect3;

        var json = JsonUtility.ToJson(testA);

        Debug.Log(json);
    }
コード例 #40
0
        public void CommandResolver_CannotCallSetter()
        {
            var testObject = new TestA()
            {
                StringToPass = "******"
            };
            var viewRoot = new RedwoodView() { DataContext = testObject };
            viewRoot.SetBinding(Validate.TargetProperty, new ValueBindingExpression("_root"));
            viewRoot.SetBinding(RedwoodProperty.Register<Action, RedwoodView>("Test"), new CommandBindingExpression("set_StringToPass(StringToPass)"));

            var path = new string[] { };
            var command = "set_StringToPass(StringToPass)";

            var resolver = new CommandResolver();
            var context = new RedwoodRequestContext() { ViewModel = testObject };
            resolver.GetFunction(viewRoot, context, path, command).GetAction()();
        }
コード例 #41
0
ファイル: TestFactory.cs プロジェクト: ondister/Recog
        public static ITest CreateTest(EnumPTests test, pBaseEntities ge, fBaseEntities fe, bool isAlone)
        {
            ITest _gentest=null;
              switch (test)
              {
              case EnumPTests.KettellC:
                  _gentest = new TestKettellC(ge, fe, isAlone);
                  break;
              case EnumPTests.PNN:
                  _gentest = new TestPnn(ge, fe, isAlone);
                  break;
              case EnumPTests.Adaptability:
                  _gentest = new TestD(ge,fe, isAlone);
                  break;
              case EnumPTests.FPI:
                  _gentest = new TestFPI(ge, fe, isAlone);
                  break;
              case EnumPTests.KettellA:
                  _gentest = new TestKettellA(ge, fe, isAlone);
                  break;
              case EnumPTests.Modul2:
                  _gentest = new TestMD(ge, fe, isAlone);
                  break;
              case EnumPTests.Contrasts:
                  _gentest = new TestContrasts(fe);
                  break;
              case EnumPTests.Prognoz:
                  _gentest = new TestP(ge,fe,isAlone);
                  break;
              case EnumPTests.Addictive:
                  _gentest = new TestA(ge, fe, isAlone);
                  break;
              case EnumPTests.NPNA:
                  _gentest = new TestNPN(ge, fe, isAlone);
                  break;
              case EnumPTests.Leongard:
                  _gentest = new TestL(ge, fe, isAlone);
                  break;

              }
              return _gentest;
        }
コード例 #42
0
        public void TestMemberAccessorsPerfomance()
        {
            const int total = 1000000;
            TestA a = new TestA{PropString = "test"};

            var sw = Stopwatch.StartNew();
            for (int i = 0; i < total; i++)
            {
                string v = a.PropString;
                a.PropString = "new data";
            }
            sw.Stop();

            Console.WriteLine("Native C# time: " + sw.ElapsedMilliseconds);

            IObjectMemberAccessor<string> oma = a.GetObjectMemberAccessor(x => x.PropString);
            sw.Restart();
            for (int i = 0; i < total; i++)
            {
                string v = oma.Value;
                oma.Value = "new data";
            }
            sw.Stop();

            Console.WriteLine("FastRT time: " + sw.ElapsedMilliseconds);

            PropertyInfo pi = a.GetType().GetProperty("PropString");

            sw.Restart();
            for (int i = 0; i < total; i++)
            {
                string v = (string) pi.GetValue(a, null);
                pi.SetValue(a, "new data", null);
            }
            sw.Stop();

            Console.WriteLine("Reflection time: " + sw.ElapsedMilliseconds);
        }
コード例 #43
0
 public void TestSetValueUsingReflection()
 {
     var testA = new TestA();
     testA.SetValueOf<TestA, int>("testInt", 3);
     Assert.AreEqual(3, testA.TestInt);
 }
コード例 #44
0
ファイル: cs1501-7.cs プロジェクト: nlhepler/mono
	static void Main ()
	{
		var v = new TestA ("Oh yes");
		string foo = from a in v select a;
	}
コード例 #45
0
 public void TestGetValueFromReflection()
 {
     var testA = new TestA();
     var result = testA.GetValueOf<TestA, int>("testInt");
     Assert.AreEqual(5, result);
 }
コード例 #46
0
 private static TestA CreateTestObject()
 {
     TestA a1 = new TestA {PropString = "test", Field1 = 23.34, PropInt = 48};
     return a1;
 }