public void InnerClass()
        {
            TypeAdapterConfig <ClassB, MyClassB> .ForType();

            var classD = new ClassD
            {
                Id     = 1,
                ClassB = new ClassB
                {
                    Id    = 2,
                    Name  = "Test",
                    Price = 23m
                }
            };
            var myClassA = classD.Adapt <MyClassA>();

            myClassA.Should().BeEquivalentTo(new MyClassA()
            {
                Id     = 1,
                ClassB = new MyClassB()
                {
                    Id   = 2,
                    Name = "Test"
                }
            });
        }
Esempio n. 2
0
 static void Main(string[] args)
 {
     Checker check = new Checker(); 
     ClassA try1 = new ClassA();
     ClassB try2 = new ClassB();
     ClassC try3 = new ClassC();
     ClassD try4 = new ClassD();
     MyStruct try5 = new MyStruct();
     object try6 = try5;
     Console.WriteLine("Analyzing ClassA type variable:");
                       // Анализ переменной типа ClassA 
     check.Check(try1);
     Console.WriteLine("\nAnalyzing ClassB type variable:"); 
                       // Анализ переменной типа ClassB 
     check.Check(try2);
     Console.WriteLine("\nAnalyzing ClassC type variable:");
                       // Анализ переменной типа ClassC 
     check.Check(try3);
     Console.WriteLine("\nAnalyzing ClassD type variable:");
                       // Анализ переменной типа ClassD  
     check.Check(try4);
     Console.WriteLine("\nAnalyzing MyStruct type variable:");
                       // Анализ переменной типа MyStruct  
     check.Check(try5);
     Console.WriteLine("\nAnalyzing boxed MyStruct type variable:"); 
                       // Анализ упакованной 
     check.Check(try6); 
     Console.ReadKey(); 
 }
Esempio n. 3
0
        public Genericitycs2()
        {
            this.Method1 <ClassA>(new ClassA());
            Console.WriteLine((new ClassA()).ToString());

            this.Method1 <ClassA>(new ClassD());
            Console.WriteLine((new ClassD()).ToString());

            ClassA b = new ClassA();

            b.Field1 = 1;
            b.Field2 = "hi";
            this.Method2(b as T);

            ClassC c = new ClassC();

            c.Field1 = 1;
            c.Field2 = "hi";
            c.Field3 = "you";
            c.Field4 = 2;
            this.Method2(c as T);

            ClassC c1 = this.Method3(2) as ClassC;

            ClassA a1 = this.Method3(2);

            ClassA a = new ClassA();

            a.Field1 = 10;
            a.Field2 = "plop";
            a.Field3 = "plip";
            ClassE e = this.Method4 <ClassE, ClassA, ClassC>(a, c);
            ClassD d = this.Method4 <ClassD, ClassA, ClassB>(a, c);
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            Checker  check = new Checker();
            ClassA   try1  = new ClassA();
            ClassB   try2  = new ClassB();
            ClassC   try3  = new ClassC();
            ClassD   try4  = new ClassD();
            MyStruct try5  = new MyStruct();
            object   try6  = try5;

            Console.WriteLine("Analyzing ClassA type variable:");
            check.Check(try1);

            Console.WriteLine("\nAnalyzing ClassB type variable:");
            check.Check(try2);
            Console.WriteLine("\nAnalyzing ClassC type variable:");
            check.Check(try3);
            Console.WriteLine("\nAnalyzing ClassD type variable:");
            check.Check(try4);
            Console.WriteLine("\nAnalyzing MyStruct type variable:");
            check.Check(try5);
            Console.WriteLine("\nAnalyzing boxed MyStruct type variable:");
            check.Check(try6);
            Console.ReadKey();
        }
Esempio n. 5
0
        //ISA stands for inherits i.e. A ISA B

        static void Main(string[] args)
        {
            // Call the defalut constructor
            // theChecker is the name of the instance
            // The check() method is not static, it must be referenced by instance name

            Checker  theChecker   = new Checker(); // Created a new instance of the checker class that takes an object as an argument
            ClassA   a            = new ClassA();  // New instances (objects) of each class/ structure
            ClassB   b            = new ClassB();
            ClassC   c            = new ClassC();
            ClassD   d            = new ClassD();
            MyStruct theStructure = new MyStruct(); //Structs cannot inherit from other structs or classes, it can implement an interface
            object   o            = theStructure;   // Boxing - Initialize a variable type object with the value (the value is now stored in heap)

            // Static methods do not have to be instatiated3

            Console.WriteLine("Analyzing ClassA type variable:");
            Console.WriteLine($"{theChecker.check(a)} \n"); //The object "theChecker" is able to use the check method that takes an object as an argument

            Console.WriteLine("Analyzing ClassB type variable:");
            Console.WriteLine($"{theChecker.check(b)} \n");

            Console.WriteLine("Analyzing ClassC type variable:");
            Console.WriteLine($"{theChecker.check(c)} \n");

            Console.WriteLine("Analyzing ClassD type variable:");
            Console.WriteLine($"{theChecker.check(d)} \n");

            Console.WriteLine("Analyzing MyStruct type variable:");
            Console.WriteLine($"{theChecker.check(theStructure)} \n");

            Console.WriteLine("Analyzing boxed MyStruct type variable:");
            Console.WriteLine($"{theChecker.check(o)} \n");
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            Checker check  = new Checker();
            ClassA  classA = new ClassA();
            ClassB  classB = new ClassB();
            ClassC  classC = new ClassC();
            ClassD  classD = new ClassD();

            MyStruct myStruct = new MyStruct();
            object   obj      = myStruct;

            WriteLine("Analyzing ClassA type variable");
            check.Check(classA);
            WriteLine("\nAnalyzing ClassB type variable");
            check.Check(classB);
            WriteLine("\nAnalyzing ClassC type variable");
            check.Check(classC);
            WriteLine("\nAnalyzing ClassD type variable");
            check.Check(classD);
            WriteLine("\nAnalzying MyStruct type variable");
            check.Check(myStruct);
            WriteLine("\nAnalyzing boxed myStruct type variable");
            check.Check(obj);
            ReadKey();
        }
Esempio n. 7
0
        public void InitLocalMySQL()
        {
            if (this.Database.CreateIfNotExists())
            {
                //Setup base datas to load
                for (int j = 0; j < 20; j++)
                {
                    Class1 c1 = new Class1();
                    EntityGenerator <Class1> generatorClass1 = new EntityGenerator <Class1>();
                    c1 = generatorClass1.GenerateItem();

                    EntityGenerator <Class2> generatorClass2 = new EntityGenerator <Class2>();
                    for (int i = 0; i < 10; i++)
                    {
                        c1.Addresses.Add(generatorClass2.GenerateItem());
                    }

                    MySQLManager <Class1> managerClass1 = new MySQLManager <Class1>(DataConnectionResource.LOCALMYSQL);
                    managerClass1.Insert(c1);


                    ClassD d1 = new ClassD();
                    EntityGenerator <ClassD> generatorClassD = new EntityGenerator <ClassD>();
                    d1 = generatorClassD.GenerateItem();

                    MySQLManager <ClassD> managerClassD = new MySQLManager <ClassD>(DataConnectionResource.LOCALMYSQL);
                    managerClassD.Insert(d1);
                }
            }
        }
Esempio n. 8
0
        public void WriteAndReadBack()
        {
            var sw = new Stopwatch();

            sw.Start();
            using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;"))
            {
                Console.WriteLine("Init " + sw.Elapsed);
                sw.Restart();

                var guid      = Guid.NewGuid();
                var newEntity = new ClassD
                {
                    EntityId          = guid,
                    Name              = "Lorem ipsum",
                    NumberOfSomething = 5
                };
                context.TestTable.Add(newEntity);
                Console.WriteLine("Add " + sw.Elapsed);
                sw.Restart();
                context.SaveChanges();
                Console.WriteLine("Persist " + sw.Elapsed);
                sw.Restart();

                var storedEntity = context.TestTable.SingleOrDefault(e => e.EntityId == guid);
                Console.WriteLine("Select " + sw.Elapsed);

                Assert.IsInstanceOfType(storedEntity, typeof(ClassD));

                var classD = (ClassD)storedEntity;
                Assert.AreEqual(classD.Name, newEntity.Name);
                Assert.AreEqual(classD.NumberOfSomething, newEntity.NumberOfSomething);
                Assert.AreNotEqual(classD.Id, 0);
            }
        }
Esempio n. 9
0
 public void InsertNotInTransactionSpeed()
 {
     using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;"))
     {
         var sum = new Stopwatch();
         sum.Start();
         var sw = new Stopwatch();
         sw.Start();
         for (var i = 0; i < 100; i++)
         {
             var guid      = Guid.NewGuid();
             var newEntity = new ClassD
             {
                 EntityId          = guid,
                 Name              = "Lorem ipsum",
                 NumberOfSomething = 5
             };
             context.TestTable.Add(newEntity);
             Console.WriteLine("Add " + sw.Elapsed);
             sw.Restart();
             context.SaveChanges();
             Console.WriteLine("Persist " + sw.Elapsed);
             sw.Restart();
         }
         Console.WriteLine("-----");
         Console.WriteLine(sum.Elapsed);
     }
 }
Esempio n. 10
0
        static void Main(string[] args)
        {
            Checker  check = new Checker();
            ClassA   try1  = new ClassA();
            ClassB   try2  = new ClassB();
            ClassC   try3  = new ClassC();
            ClassD   try4  = new ClassD();
            MyStruct try5  = new MyStruct();
            //Box the struct value, getting a reference to a new instance of the try5 struct.
            object try6 = try5;

            WriteLine("Analyzing ClassA type variable:");
            check.Check(try1);

            WriteLine("\nAnalyzing ClassB type variable:");
            check.Check(try2);

            WriteLine("\nAnalyzing ClassC type variable:");
            check.Check(try3);

            WriteLine("\nAnalyzing ClassD type variable:");
            check.Check(try4);

            WriteLine("\nAnalyzing MyStruct type variable:");
            check.Check(try5);

            WriteLine("\nAnalyzing boxed MyStruct type variable:");
            check.Check(try6);
            ReadKey();
        }
Esempio n. 11
0
        // создание объектов
        private static void CreateObjects(IFaker faker)
        {
            ClassA a = faker.Create <ClassA>();

            objectList.Add(a);
            ClassB b = faker.Create <ClassB>();

            objectList.Add(b);
            ClassC c = faker.Create <ClassC>();

            objectList.Add(c);
            ClassD d = faker.Create <ClassD>();

            objectList.Add(d);
            ClassE e = faker.Create <ClassE>();

            objectList.Add(e);
            ClassF f = faker.Create <ClassF>();

            objectList.Add(f);
            ClassG g = faker.Create <ClassG>();

            objectList.Add(g);
            ClassH h = faker.Create <ClassH>();

            objectList.Add(h);
            ClassI i = faker.Create <ClassI>();

            objectList.Add(i);
        }
        static void main()
        {
            ClassD d = new ClassD();

            d.Print(); //here which overriden method will be called ??
            //will it call Print of ClassB/ClassC
            //This ambiguity is called diamond Problem
        }
Esempio n. 13
0
    public unsafe void TestFieldRef()
    {
        var classD   = new ClassD(10);
        var fieldRef = classD.Field;

        fieldRef.Value = 20;
        Assert.AreEqual(20, classD.Field.Value);
    }
Esempio n. 14
0
        public void ActivatorFunc_InstanceParams()
        {
            var classC    = new ClassC();
            var classD    = new ClassD();
            var container = ContainerBuilder
                            .New()
                            .Register <A>(() => new ClassA(new ClassB(classC, classD)))
                            .Build();

            var resolvedService = container.Resolve <A>();

            Assert.AreEqual(typeof(ClassA), resolvedService.GetType());
        }
Esempio n. 15
0
//        [TestMethod]
        public void ClassDJson()
        {
            SimplTypesScope.EnableGraphSerialization();

            ClassC classC = new ClassC();
            ClassD test   = new ClassD(new ClassA(classC), new ClassB(classC));

            SimplTypesScope tScope = SimplTypesScope.Get("classD", typeof(ClassA), typeof(ClassB),
                                                         typeof(ClassC), typeof(ClassD), typeof(ClassX));

            TestMethods.TestSimplObject(test, tScope, Format.Json);

            SimplTypesScope.DisableGraphSerialization();
        }
Esempio n. 16
0
        public InheritanceAndPolymorphismV2_3()
        {
            ClassA a = new ClassD();
            ClassB b = new ClassD();
            ClassC c = new ClassD();
            ClassD d = new ClassD();

            a.XXX();
            // ClassB XXX
            b.XXX();
            // ClassB XXX
            c.XXX();
            // ClassD XXX
            d.XXX();
            // ClassD XXX
            Console.ReadKey();
        }
Esempio n. 17
0
        public void SingletonClassDTest()
        {
            ClassD ins1 = ClassD.Instance;

            ClassD ins2 = ClassD.Instance;

            Assert.AreEqual(ins1.Num, 0);
            Assert.AreEqual(ins1.Num, ins2.Num);

            ins1.Num = 123;

            Assert.AreEqual(ins2.Num, 123);

            ins2.Num = 456;

            Assert.AreEqual(ins1.Num, 456);
        }
Esempio n. 18
0
        public RoundEndEvent(RoundSummary.SumInfo_ClassList list_start, RoundSummary.SumInfo_ClassList list_finish, RoundSummary.LeadingTeam leadingTeam, int e_ds, int e_sc, int scp_kills, int round_cd, string Roundtime)
        {
            SCP = new SCPs {
                SCP_Kills = scp_kills, Starting_SCPs = list_start.scps_except_zombies, Ending_SCPs = list_finish.scps_except_zombies, Terminated_SCPs = list_start.scps_except_zombies - list_finish.scps_except_zombies
            };
            Class_D = new ClassD {
                Starting_ClassD = list_start.class_ds, Escaped_ClassD = e_ds
            };
            Scientist = new Scientists {
                Starting_Scientists = list_start.scientists, Escaped_Scientists = e_sc
            };

            TimeSpan tspan = TimeSpan.FromSeconds(list_finish.time - list_start.time);

            Roundtime   = string.Format("{0} minutes and {1} seconds", (int)tspan.TotalMinutes, tspan.Seconds);
            LeadingTeam = leadingTeam;
        }
Esempio n. 19
0
        static void Main(string[] args)
        {
            /*MyClass myObj = new MyClass("chs");
             * WriteLine(myObj.ToString());
             * WriteLine(myObj.GetType());
             * WriteLine(typeof(MyClass));*/

            /*
             * MyStruct valType1 = new MyStruct();
             * valType1.val = 5;
             * object refType = valType1;//封箱
             * valType1.val = 6;
             * MyStruct valType2 = (MyStruct)refType;//拆箱
             * WriteLine("valType2.val = "+valType2.val);
             */

            //is 运算符  测试
            Checker  check = new Checker();
            ClassA   try1  = new ClassA();
            ClassB   try2  = new ClassB();
            ClassC   try3  = new ClassC();
            ClassD   try4  = new ClassD();
            MyStruct try5  = new MyStruct();
            object   try6  = try5;

            WriteLine("Analyzing ClassA type variable:");
            check.Check(try1);
            WriteLine();
            WriteLine("Analyzing ClassB type variable:");
            check.Check(try2);
            WriteLine();
            WriteLine("Analyzing ClassC type variable:");
            check.Check(try3);
            WriteLine();
            WriteLine("Analyzing ClassD type variable:");
            check.Check(try4);
            WriteLine();
            WriteLine("Analyzing MyStruct type variable:");
            check.Check(try5);
            WriteLine();
            WriteLine("Analyzing boxed MyStruct type variable:");
            check.Check(try6);
            ReadKey();
        }
Esempio n. 20
0
        public void GivenListWithinClass_WhenGetProperties_ShouldSuccess()
        {
            var subject = new ClassD
            {
                S1 = "string value 1",
                I1 = 100,
                Cs = Enumerable.Range(0, 3)
                     .Select(x => new ClassC
                {
                    C_S1 = $"S1({x})",
                    C_I1 = x
                })
                     .ToList(),
            };

            IReadOnlyList <string> configValues = subject.GetConfigValues();

            var expected = new string[]
            {
                "S1=string value 1",
                "I1=100",
                "Cs:0:C_S1=S1(0)",
                "Cs:0:C_I1=0",
                "Cs:1:C_S1=S1(1)",
                "Cs:1:C_I1=1",
                "Cs:2:C_S1=S1(2)",
                "Cs:2:C_I1=2",
            };

            configValues.Count.Should().Be(expected.Length);

            configValues.OrderBy(x => x)
            .Zip(expected.OrderBy(x => x), (o, i) => (o, i))
            .All(x => x.o == x.i)
            .Should().BeTrue();
        }
Esempio n. 21
0
        public void TestA()
        {
            Checker  checker  = new Checker();
            ClassA   classA   = new ClassA();
            ClassB   classB   = new ClassB();
            ClassC   classC   = new ClassC();
            ClassD   classD   = new ClassD();
            MyStruct myStruct = new MyStruct();
            object   o        = myStruct;

            WriteLine("Analyzing ClassA type variable:");
            checker.Check(classA);
            WriteLine("\nAnalyzing ClassB type variable:");
            checker.Check(classB);
            WriteLine("\nAnalyzing ClassC type variable:");
            checker.Check(classC);
            WriteLine("\nAnalyzing ClassD type variable:");
            checker.Check(classD);
            WriteLine("\nAnalyzing MyStruct type variable:");
            checker.Check(myStruct);
            WriteLine("\nAnalyzing boxed MyStruct type variable:");
            checker.Check(o);
            ReadKey();
        }
Esempio n. 22
0
    private DisplayerSignal _onClassCDisplayedNMB;                                             // non-monobehaviour signal

    public ClassC(ClassD classD, DisplayerSignal onClassCDisplayed)                            // non-monobehaviour constructor injection
    {
        classD.DisplayDInfo();
        _onClassCDisplayedNMB = onClassCDisplayed;
    }
 public abstract void Method1(ClassD parameter);
Esempio n. 24
0
 record ClassC(ClassD d) : IInterface;
Esempio n. 25
0
 public ClassD()
 {
     ClassD _Cla = new ClassD(30, "Sydney");
 }
Esempio n. 26
0
 public ClassC(ClassD dd)
 {
     logger.Info("Hi there C");
 }
Esempio n. 27
0
            public ClassC(ClassD dd)
            {
                logger.Info("Hi there C");

            }
Esempio n. 28
0
        static void Main(string[] args)
        {
            //======================== Structure Basic ========================

            /* chuong trinh in dong chu Hello World trong C# */
            Console.WriteLine("Hello World!");

            Console.WriteLine("Chuong trinh minh hoa tinh huong doi tuong trong C#");
            Console.WriteLine("--------------------------------------------------\n");
            //tao doi tuong Rectangle
            Rectangle r = new Rectangle();

            //goi cac phuong thuc cua doi tuong nay
            r.Acceptdetails();
            r.Display();

            //======================== Structure Basic ========================

            /* Kieu du lieu */
            object obj;

            obj = 100;

            dynamic dem = 20;

            String str = "Hi, I am Tuan";

            Console.WriteLine("\n Kieu object: " + obj + "\n Kieu dynamic: " + dem + "\n Kieu string: " + str + "\n");

            /* Ep kieu */
            int    x     = 75;
            float  y     = 53.005f;
            double z     = 2345.7652;
            bool   check = true;

            //su dung phuong thuc ToString()
            Console.WriteLine(x + "\t\t to string \t" + x.ToString());
            Console.WriteLine(y + "\t\t to string \t" + y.ToString());
            Console.WriteLine(z + "\t to int \t" + (int)z);
            Console.WriteLine(check + "\t\t to string \t" + check.ToString());

            //khai bao bien
            Console.WriteLine("\nKhai bao va khoi tao bien trong C#");
            short  a;
            int    b;
            double c;
            int    d = 3, e = 5;

            /* khoi tao bien */
            a = 10;
            b = 20;
            c = a + b;
            Console.WriteLine("a = {0}, b = {1}, c = {2}", a, b, c);
            Console.WriteLine("d = {0}, e = {1}", d, e);

            /* Nhap gia tri */
            String giatri;

            Console.Write("\n Input gia tri: ");
            giatri = Convert.ToString(Console.ReadLine());
            Console.WriteLine("\n Gia tri la: {0}", giatri);

            //Hang
            Console.WriteLine("Hang so trong C#");
            Console.WriteLine("-------------------");

            //khai bao hang so pi
            const double pi = 3.14159;

            double bk;

            Console.Write("Nhap ban kinh: ");
            bk = Convert.ToDouble(Console.ReadLine());
            double dien_tich = pi * bk * bk;

            Console.WriteLine("\nBan kinh: {0}, Dien tich: {1}", bk, dien_tich);


            //List<string>
            List <string> list = new List <string>();

            list.Add("abc");
            list.Add("123");
            //IEnumerable<object> en = list;


            //Ke thua
            ClassA classa = new ClassA();
            ClassB classb = new ClassB();
            ClassC classc = new ClassC();
            ClassD classd = new ClassD();

            classa.Height = 20 > 10 ? (classa.Height - 10) : (classc.methodA(8, 10));
            classb.Height = 10;
            classb.methodA();

            Console.WriteLine("Width = {0}", classc.Width);
            Console.WriteLine("MethodA = {0}", classc.methodA());
            Console.WriteLine("MethodA Dien tich = {0}", classc.methodA(5, 10));

            //Mang
            Console.WriteLine("\n ======== IN gia tri trong mang C1 ");
            int[] marks = new int[] { 99, 98, 92, 97, 95 };
            for (int i = 0; i < marks.Length; i++)
            {
                Console.WriteLine("Gia tri phan tu {0} = {1}", i, marks[i]);
            }

            Console.WriteLine("\n ======== IN gia tri trong mang C2 ");
            foreach (int mark in marks)
            {
                Console.WriteLine("\t Gia tri phan tu la : {0}", mark);
            }

            Console.WriteLine("\n ======== IN gia tri trong mang Key - Value ");
            IDictionary <string, string> openWith = new Dictionary <string, string>()
            {
                { "txt", "notepad.exe" },
                { "bmp", "paint.exe" },
                { "rtf", "wordpad.exe" }
            };

            foreach (KeyValuePair <string, string> de in openWith)
            {
                Console.WriteLine("Key = {0}, Value = {1}", de.Key, de.Value);
            }

            //Find MIN - MAX
            Console.Write("\n ======== Find MIN - MAX | num_array = ");

            int[] num_array = new int[] { -8, -98, 12, 97, 55, 22 };
            int   N         = 4;

            foreach (int num in num_array)
            {
                Console.Write("{0} \t", num);
            }

            MathApp MinMax = new MathApp();

            Console.WriteLine("\n Min = {0}", MinMax.FindMin(num_array));
            Console.WriteLine(" Max = {0}", MinMax.FindMax(num_array));
            Console.WriteLine(" {0}! = {1}", N, MinMax.GiaiThua(N));



            //=================================================================
            //=================================================================

            Console.ReadLine();
            /* ngan can chuong trinh run, close 1 cach nhanh chong cho den khi push 1 char */
            //Console.ReadKey();

            if (Console.ReadKey().Key == ConsoleKey.Escape)
            {
                Environment.Exit(0);
            }
        }
Esempio n. 29
0
 public ClassE(ClassD classD)
 {
     _classD = classD;
 }
Esempio n. 30
0
        public void TestEnumableProperties()
        {
            // ²âÊÔÊý×éµÄ¿½±´
            ClassD d = new ClassD
            {
                VuleTypeArray   = new [] { 1, 2, 3 },
                ClassATypeArray = new []
                {
                    new ClassA
                    {
                        ValueTypeProp = 1,
                        StringProp    = "string1"
                    },
                    new ClassA
                    {
                        ValueTypeProp = 2,
                        StringProp    = "string2"
                    }
                }
            };

            ClassE e = Copier.Copy <ClassD, ClassE>(d);

            Assert.Equal(d.VuleTypeArray, e.VuleTypeArray);
            Assert.NotSame(d.VuleTypeArray, e.VuleTypeArray);

            Assert.Equal(d.ClassATypeArray.Select(x => x.ValueTypeProp),
                         e.ClassATypeArray.Select(x => x.ValueTypeProp));

            Assert.Equal(d.ClassATypeArray.Select(x => x.StringProp),
                         e.ClassATypeArray.Select(x => x.StringProp));

            Assert.NotEqual(d.ClassATypeArray.AsEnumerable(), e.ClassATypeArray.AsEnumerable());

            Assert.NotSame(d.ClassATypeArray, e.ClassATypeArray);

            // ²âÊÔListµÄ¿½±´
            ClassD d2 = new ClassD
            {
                VuleTypeList = new List <int> {
                    1, 2, 3
                },
                ClassATypeList = new List <ClassA>
                {
                    new ClassA
                    {
                        ValueTypeProp = 1,
                        StringProp    = "string1"
                    },
                    new ClassA
                    {
                        ValueTypeProp = 2,
                        StringProp    = "string2"
                    }
                }
            };

            ClassE e2 = Copier.Copy <ClassD, ClassE>(d2);

            Assert.Equal(d2.VuleTypeList, e2.VuleTypeList);
            Assert.NotSame(d2.VuleTypeList, e2.VuleTypeList);

            Assert.Equal(d2.ClassATypeList.Select(x => x.ValueTypeProp),
                         e2.ClassATypeList.Select(x => x.ValueTypeProp));

            Assert.Equal(d2.ClassATypeList.Select(x => x.StringProp),
                         e2.ClassATypeList.Select(x => x.StringProp));

            Assert.NotEqual(d2.ClassATypeList.AsEnumerable(), e2.ClassATypeList.AsEnumerable());

            Assert.NotSame(d2.ClassATypeList, e2.ClassATypeList);
        }
 public ControllerB(ClassD classD, ILogger <ControllerB> logger)
 {
     this.classD = classD;
     this.logger = logger;
 }
Esempio n. 32
0
        static void Main(string[] args)
        {
            IKernel kernel = new StandardKernel(new ModuleBinding());

            ClassA a = new ClassA();

            a.Method1();
            a.Method2(); // hello world
            a.Method3();

            ClassB b = new ClassB();

            b.Method1();
            b.Method2();
            b.Method3();

            ClassD d = new ClassD(a);

            d.Method1();

            ClassE e = new ClassE();

            e.Method2();
            e.Method5();

            ClassH h = new ClassH();

            h.Method2();

            ClassJ j = new ClassJ();

            j.Method1();

            ClassK k = new ClassK();

            k.Method1();

            ClassM m = new ClassM();

            m.Method2();
            m.Method3();
            m.Method7();
            m.Method8();

            ClassN n = new ClassN();

            n.Method3();

            ClassO o = new ClassO();

            o.Method2();

            ClassP p = new ClassP();

            p.Method10();
            p.Method2();
            p.Method9();

            ClassL l = new ClassL(p);

            l.Method1();

            ClassQ q = new ClassQ();

            q.Method3();

            ClassR r = new ClassR();

            r.Method1();

            ClassS s = new ClassS();

            s.Method1();
            s.Method2();
            s.Method3();

            ClassT t = new ClassT(e);

            t.Method2();

            ClassU u = new ClassU();

            u.Mehthod1();

            ClassV v = new ClassV();

            v.Method2();

            ClassW w = new ClassW(kernel.Get <IInterfaceSomething>());

            w.Method2();
            w.Method3();

            ClassX x = new ClassX();

            x.Method1();

            ClassY y = new ClassY();

            y.Method2();

            ClassZ z = new ClassZ();

            z.Method2();
        }