Пример #1
0
        public void ListMethodTest()
        {
            var source = new ModelB();
            var target = new TestViewFactory();

            // bind to collection
            var binding = new CollectionBinding("List", target);

            binding.Bind(source);

            Assert.AreEqual(0, target.ViewCount);

            // add item
            source.List.Add(new ModelA()
            {
                IntValue = 1
            });
            source.List.Add(new ModelA()
            {
                IntValue = 2
            });
            source.List.Add(new ModelA()
            {
                IntValue = 3
            });

            // do shuffle
            TestUtility.Shuffle(source.List);

            // do sort
            source.List.Sort((x, y) => x.IntValue.CompareTo(y.IntValue));

            target.Destroy();
        }
Пример #2
0
        public void BindToCollection()
        {
            var source = new ModelB();
            var target = new TestViewFactory();

            // bind to collection
            var binding = new CollectionBinding("List", target);

            binding.Bind(source);

            Assert.AreEqual(0, target.viewList.Count);

            // add item
            source.List.Add(new ModelA());
            Assert.AreEqual(1, target.viewList.Count);
            Assert.AreEqual(1, target.nextIndex);

            // notify list changed
            binding.HandleSourcePropertyChanged(source, "List");

            Assert.AreEqual(2, target.nextIndex);
            Assert.AreEqual(1, target.viewList.Count);

            // notify with null property name
            binding.HandleSourcePropertyChanged(source, null);

            Assert.AreEqual(3, target.nextIndex);
            Assert.AreEqual(1, target.viewList.Count);

            target.Clear();
        }
Пример #3
0
        public void AddAndRemoveTest()
        {
            var source = new ModelB();
            var target = new TestViewFactory();

            // bind to collection
            var binding = new CollectionBinding("List", target);

            binding.Bind(source);

            Assert.AreEqual(0, target.ViewCount);

            // add item
            source.List.Add(new ModelA());
            Assert.AreEqual(1, target.ViewCount);

            // add item
            source.List.Add(new ModelA());
            Assert.AreEqual(2, target.ViewCount);

            // remove item
            source.List.RemoveAt(0);
            Assert.AreEqual(1, target.ViewCount);

            // add item
            source.List.Add(new ModelA());
            Assert.AreEqual(2, target.ViewCount);

            // clear
            source.List.Clear();
            Assert.AreEqual(0, target.ViewCount);

            target.Destroy();
        }
Пример #4
0
        public IActionResult GetB()
        {
            // Inheritance works! ModelA's augments will be applied to ModelB.
            var model = new ModelB();

            return(Ok(model));
        }
Пример #5
0
        public void ObjectTest()
        {
            var model = new ModelB
            {
                ID   = 2233,
                Body = new
                {
                    aaa = 123,
                    bbb = 456,
                    ccc = 789,
                },
            };

            // 序列化
            var json = model.ToJson();

            // 反序列化
            var model2 = json.ToJsonEntity <ModelB>();

            Assert.NotNull(model2);
            Assert.Equal(2233, model2.ID);

            var dic = model2.Body as IDictionary <String, Object>;

            Assert.Equal(3, dic.Count);
            Assert.Equal(123, dic["aaa"]);
            Assert.Equal(456, dic["bbb"]);
            Assert.Equal(789, dic["ccc"]);
        }
        public void MultipleModelsDependenciesTest()
        {
            List<string> property_notifications = new List<string>();
            ModelA ma = new ModelA() { PropA = 1 };
            ModelB mb = new ModelB() { PropB = 2 };
            ViewModel vm = new ViewModel(ma, mb);

            int current_total;

            ma.PropertyChanged += (sender, args) => property_notifications.Add("ModelA:" + args.PropertyName);
            mb.PropertyChanged += (sender, args) => property_notifications.Add("ModelB:" + args.PropertyName);
            vm.PropertyChanged += (sender, args) => property_notifications.Add("ViewModel:" + args.PropertyName);

            ma.PropA = 2;

            Assert.AreEqual(2, property_notifications.Count);
            Assert.IsTrue(property_notifications.Contains("ModelA:PropA"));
            Assert.IsTrue(property_notifications.Contains("ViewModel:Total"));
            property_notifications.Clear();

            mb.PropB = 40;

            Assert.AreEqual(2, property_notifications.Count);
            Assert.IsTrue(property_notifications.Contains("ModelB:PropB"));
            Assert.IsTrue(property_notifications.Contains("ViewModel:Total"));

            var total_property = TypeDescriptor.GetProperties(vm)["Total"];
            var total = total_property.GetValue(vm);
            Assert.AreEqual(42, total);
        }
Пример #7
0
        private IEnumerator NotifyTestB1()
        {
            var model       = new ModelB();
            var bindingList = new List <Binding>();

            for (int i = 0; i < bindingTestCount; i++)
            {
                var view = new ViewB();

                var binding = new Binding("IntValue", view, "TextA");
                binding.Bind(model);
                bindingList.Add(binding);

                binding = new Binding("FloatValue", view, "TextB");
                binding.Bind(model);
                bindingList.Add(binding);
            }

            var test = RunActionAsync("NotifyTestB1", bindingTestCount, () =>
            {
                // update value
                model.IntValue   = 1;
                model.FloatValue = 2f;
            });

            yield return(StartCoroutine(test));
        }
Пример #8
0
        public void NullRefonHasFieldsWithSameValueWithInterfaces()
        {
            var modelA = new ModelA { Name = "Yoda" };
            var modelB = new ModelB { Name = new ModelBName { Title = "Frank" } };

            Check.That(modelA).HasFieldsWithSameValues(modelB);
        }
Пример #9
0
 public ModelBViewModel(ModelB model)
 {
     _model = model;
     CVms   = new ObservableCollection();
     foreach (var modelC in model.Cs)
     {
         CVms.Add(new ModelCViewModel(modelC));
     }
 }
Пример #10
0
        public async static Task <IDevice> Get(string deviceId)
        {
            BluetoothLEDevice ble = await BluetoothLEDevice.FromIdAsync(deviceId);

            //TODO: check device model
            IModel model = new ModelB();

            return(await SensiDevice.Get(ble, model));
        }
Пример #11
0
        public void DuplicateItemTest()
        {
            var source = new ModelB();
            var target = new TestViewFactory();

            // bind to collection
            var binding = new CollectionBinding("List", target);

            binding.Bind(source);

            // get ref dictionary
            var field         = typeof(CollectionBinding).GetField("viewReferenceCountDictionary", BindingFlags.NonPublic | BindingFlags.Instance);
            var refDictionary = field.GetValue(binding) as Dictionary <GameObject, int>;

            // check initial state
            {
                Assert.AreEqual(0, target.ViewCount);
                Assert.IsTrue(refDictionary == null);
            }

            var item = new ModelA();

            // add item
            {
                source.List.Add(item);
                source.List.Add(item);

                // verify view count
                Assert.AreEqual(1, binding.BindingDictionary.Count);

                // check ref count
                refDictionary = field.GetValue(binding) as Dictionary <GameObject, int>;
                Assert.IsTrue(refDictionary != null);
                Assert.AreEqual(2, refDictionary.First().Value);
            }

            // remove item
            {
                source.List.RemoveAt(0);
                Assert.AreEqual(1, binding.BindingDictionary.Count);

                // check ref count
                Assert.AreEqual(1, refDictionary.First().Value);
            }

            // remove item
            {
                source.List.RemoveAt(0);
                Assert.AreEqual(0, binding.BindingDictionary.Count);

                // check ref count
                Assert.AreEqual(0, refDictionary.Count);
            }

            target.Destroy();
        }
Пример #12
0
        public void UpdateItemValueTest()
        {
            var source = new ModelB();
            var target = new TestViewFactory();

            // bind to collection
            var binding = new CollectionBinding("List", target);

            binding.Bind(source);

            Assert.AreEqual(0, target.ViewCount);

            // add item
            var itemA = new ModelA();

            source.List.Add(itemA);

            // add item
            var itemB = new ModelA();

            source.List.Add(itemB);

            // add item view A
            var viewA    = new ModelA();
            var bindingA = new Binding("IntValue", viewA, "IntValue");
            var dcA      = binding.BindingDictionary[itemA].GetComponent <IDataContext>();

            dcA.AddBinding(bindingA);

            // add item view B
            var viewB    = new ModelA();
            var bindingB = new Binding("IntValue", viewB, "IntValue");
            var dcB      = binding.BindingDictionary[itemB].GetComponent <IDataContext>();

            dcB.AddBinding(bindingB);

            // verify state
            Assert.IsTrue(bindingA.IsBound);
            Assert.IsTrue(bindingB.IsBound);

            Assert.AreEqual(1, dcA.BindingList.Count);
            Assert.AreEqual(1, dcB.BindingList.Count);

            Assert.AreEqual(0, viewA.IntValue);
            Assert.AreEqual(0, viewB.IntValue);

            // update value
            itemA.IntValue = 1;
            itemB.IntValue = 2;

            Assert.AreEqual(1, viewA.IntValue);
            Assert.AreEqual(2, viewB.IntValue);

            target.Destroy();
        }
Пример #13
0
        public IActionResult GetCamel()
        {
            // Json options will be honored.
            var model = new ModelB();

            return(Json(model, new JsonSerializerSettings()
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver(),
                Formatting = Formatting.Indented
            }));
        }
Пример #14
0
        public void TestItemPropertyChanged()
        {
            var source = new ModelB();
            var target = new TestViewFactory();

            var go = new GameObject("Test");
            var dc = go.AddComponent <DataContext>();

            // create collection binding
            var binding = new CollectionBinding("List", target);

            dc.AddBinding(binding);

            BindingManager.Instance.AddSource(source, "Test");
            BindingManager.Instance.AddDataContext(dc, "Test");

            // add item
            var item = new ModelA();

            item.IntValue = 2;
            source.List.Add(item);

            var itemView        = binding.BindingDictionary[item];
            var itemDataContext = itemView.GetComponent <IDataContext>();

            // add item binding
            var itemTarget  = new ModelA();
            var itemBinding = new Binding("IntValue", itemTarget, "IntValue");

            itemDataContext.AddBinding(itemBinding);

            // check item value
            Assert.AreEqual(2, itemTarget.IntValue);

            // update value
            item.IntValue = 3;
            Assert.AreEqual(2, itemTarget.IntValue);

            // notify
            BindingManager.Instance.NotifyItemPropertyChanged(source, source.List, item, "IntValue");
            Assert.AreEqual(3, itemTarget.IntValue);

            // update value
            item.IntValue = 4;
            Assert.AreEqual(3, itemTarget.IntValue);

            // notify with null
            BindingManager.Instance.NotifyItemPropertyChanged(source, source.List, item, null);
            Assert.AreEqual(4, itemTarget.IntValue);

            BindingManager.Instance.Clear();
            target.Clear();
            GameObject.DestroyImmediate(go);
        }
Пример #15
0
        public IActionResult GetAnon()
        {
            var model = new ModelB();

            // Works with anonymous objects!
            return(Ok(new
            {
                Foo = "foo",
                Inner = model
            }));
        }
Пример #16
0
            public void ForTransform()
            {
                var result = new ModelB[Source.Count];

                for (int i = 0; i < Source.Count; i++)
                {
                    var model = Source[i];
                    result[i] = new ModelB()
                    {
                        Id = model.Id, SomeInt = model.SomeInt
                    };
                }
            }
Пример #17
0
        public void NullRefonHasFieldsWithSameValueWithInterfaces()
        {
            var modelA = new ModelA {
                Name = "Yoda"
            };
            var modelB = new ModelB {
                Name = new ModelBName {
                    Title = "Frank"
                }
            };

            Check.That(modelA).HasFieldsWithSameValues(modelB);
        }
Пример #18
0
        public void DuplicateItemTest()
        {
            var source = new ModelB();
            var target = new TestViewFactory();

            // setup function
            target.GetDynamicItemsFun = () =>
            {
                var list = new List <object>();
                foreach (var item in source.List)
                {
                    list.Add(item);
                }
                return(list);
            };

            // bind to collection
            var binding = new ListDynamicBinding("List", target);

            binding.Bind(source);

            // check initial state
            {
                Assert.AreEqual(0, target.ViewCount);
            }

            var model = new ModelA();

            // add item
            {
                source.List.Add(model);
                source.List.Add(model);

                // verify view count
                Assert.AreEqual(1, binding.BindingDictionary.Count);
            }

            // remove item
            {
                source.List.RemoveAt(0);
                Assert.AreEqual(1, binding.BindingDictionary.Count);
            }

            // remove item
            {
                source.List.RemoveAt(0);
                Assert.AreEqual(0, binding.BindingDictionary.Count);
            }

            target.Destroy();
        }
Пример #19
0
        public IActionResult GetWrapper()
        {
            // You can use the special AugmenterWrapper to wrap your model with
            // some configuration that will be used when doing the augmentation.
            var model   = new ModelB();
            var wrapper = new AugmenterWrapper <ModelB>(model);

            wrapper.SetTypeConfiguration(c =>
            {
                c.Add("Baz", (x, state) => x.Id);
            });

            return(Ok(wrapper));
        }
Пример #20
0
        public void OrderTest()
        {
            var source = new ModelB();
            var target = new TestViewFactory();

            // setup function
            target.GetDynamicItemsFun = () =>
            {
                var list = new List <object>();
                foreach (var item in source.List)
                {
                    list.Add(item);
                }
                return(list);
            };

            // bind to collection
            var binding = new ListDynamicBinding("List", target);

            binding.Bind(source);

            Assert.AreEqual(0, target.ViewCount);

            // add item
            source.List.Add(new ModelA());
            source.List.Add(new ModelA());

            var sourceA = source.List[0];
            var sourceB = source.List[1];

            var viewA = binding.BindingDictionary[sourceA];

            Assert.AreEqual(0, viewA.transform.GetSiblingIndex());

            var viewB = binding.BindingDictionary[sourceB];

            Assert.AreEqual(1, viewB.transform.GetSiblingIndex());

            // switch items
            source.List[0] = sourceB;
            source.List[1] = sourceA;

            viewA = binding.BindingDictionary[sourceA];
            Assert.AreEqual(1, viewA.transform.GetSiblingIndex());

            viewB = binding.BindingDictionary[sourceB];
            Assert.AreEqual(0, viewB.transform.GetSiblingIndex());

            target.Destroy();
        }
Пример #21
0
        public void ListMethodTest()
        {
            var source = new ModelB();
            var target = new TestViewFactory();

            // setup function
            target.GetDynamicItemsFun = () =>
            {
                var list = new List <object>();
                foreach (var item in source.List)
                {
                    list.Add(item);
                }
                return(list);
            };

            // bind to collection
            var binding = new ListDynamicBinding("List", target);

            binding.Bind(source);

            Assert.AreEqual(0, target.ViewCount);

            // add item
            source.List.Add(new ModelA()
            {
                IntValue = 1
            });
            source.List.Add(new ModelA()
            {
                IntValue = 2
            });
            source.List.Add(new ModelA()
            {
                IntValue = 3
            });

            // do shuffle
            TestUtility.Shuffle(source.List);

            // do sort
            source.List.Sort((x, y) => x.IntValue.CompareTo(y.IntValue));

            target.Destroy();
        }
Пример #22
0
        public void AddAndRemoveTest()
        {
            var source = new ModelB();
            var target = new TestViewFactory();

            // bind to collection
            var binding = new ListDynamicBinding("List", target);

            binding.Bind(source);

            // setup function
            target.GetDynamicItemsFun = () =>
            {
                var list = new List <object>();
                foreach (var item in source.List)
                {
                    list.Add(item);
                }
                return(list);
            };

            Assert.AreEqual(0, target.ViewCount);

            // add item
            source.List.Add(new ModelA());
            Assert.AreEqual(1, target.ViewCount);

            // add item
            source.List.Add(new ModelA());
            Assert.AreEqual(2, target.ViewCount);

            // remove item
            source.List.RemoveAt(0);
            Assert.AreEqual(1, target.ViewCount);

            // add item
            source.List.Add(new ModelA());
            Assert.AreEqual(2, target.ViewCount);

            // clear
            source.List.Clear();
            Assert.AreEqual(0, target.ViewCount);

            target.Destroy();
        }
Пример #23
0
        public void UpdateItemsTest()
        {
            var source = new ModelB();
            var target = new TestViewFactory();

            // bind to collection
            var binding = new ListDynamicBinding("List", target);

            binding.Bind(source);

            Assert.AreEqual(0, target.ViewCount);

            // add item
            source.List.Add(new ModelA());
            source.List.Add(new ModelA());
            Assert.AreEqual(0, target.ViewCount);

            target.GetDynamicItemsFun = () =>
            {
                var list = new List <object>();
                list.Add(source.List[0]);
                return(list);
            };

            // update binding
            binding.UpdateDynamicList();
            Assert.AreEqual(1, target.ViewCount);

            target.GetDynamicItemsFun = () =>
            {
                var list = new List <object>();
                list.Add(source.List[0]);
                list.Add(source.List[1]);
                return(list);
            };

            // update binding
            binding.UpdateDynamicList();
            Assert.AreEqual(2, target.ViewCount);

            target.Destroy();
        }
Пример #24
0
        public void OrderTest()
        {
            var source = new ModelB();
            var target = new TestViewFactory();

            // bind to collection
            var binding = new CollectionBinding("List", target);

            binding.Bind(source);

            Assert.AreEqual(0, target.ViewCount);

            // add item
            source.List.Add(new ModelA());
            source.List.Add(new ModelA());

            var sourceA = source.List[0];
            var sourceB = source.List[1];

            var viewA = binding.BindingDictionary[sourceA];

            Assert.AreEqual(0, viewA.transform.GetSiblingIndex());

            var viewB = binding.BindingDictionary[sourceB];

            Assert.AreEqual(1, viewB.transform.GetSiblingIndex());

            // switch items
            source.List[0] = sourceB;
            source.List[1] = sourceA;

            viewA = binding.BindingDictionary[sourceA];
            Assert.AreEqual(1, viewA.transform.GetSiblingIndex());

            viewB = binding.BindingDictionary[sourceB];
            Assert.AreEqual(0, viewB.transform.GetSiblingIndex());

            target.Destroy();
        }
Пример #25
0
        public void MultipleModelsDependenciesTest()
        {
            List <string> property_notifications = new List <string>();
            ModelA        ma = new ModelA()
            {
                PropA = 1
            };
            ModelB mb = new ModelB()
            {
                PropB = 2
            };
            ViewModel vm = new ViewModel(ma, mb);

            int current_total;

            ma.PropertyChanged += (sender, args) => property_notifications.Add("ModelA:" + args.PropertyName);
            mb.PropertyChanged += (sender, args) => property_notifications.Add("ModelB:" + args.PropertyName);
            vm.PropertyChanged += (sender, args) => property_notifications.Add("ViewModel:" + args.PropertyName);

            ma.PropA = 2;

            Assert.AreEqual(2, property_notifications.Count);
            Assert.IsTrue(property_notifications.Contains("ModelA:PropA"));
            Assert.IsTrue(property_notifications.Contains("ViewModel:Total"));
            property_notifications.Clear();

            mb.PropB = 40;

            Assert.AreEqual(2, property_notifications.Count);
            Assert.IsTrue(property_notifications.Contains("ModelB:PropB"));
            Assert.IsTrue(property_notifications.Contains("ViewModel:Total"));

            var total_property = TypeDescriptor.GetProperties(vm)["Total"];
            var total          = total_property.GetValue(vm);

            Assert.AreEqual(42, total);
        }
Пример #26
0
        private IEnumerator NotifyTestB2()
        {
            // wait one frame
            yield return(null);

            var modelList   = new List <ModelB>();
            var bindingList = new List <Binding>();

            for (int i = 0; i < bindingTestCount; i++)
            {
                var model = new ModelB();
                modelList.Add(model);

                var view = new ViewB();

                var binding = new Binding("IntValue", view, "TextA");
                binding.Bind(model);
                bindingList.Add(binding);

                binding = new Binding("FloatValue", view, "TextB");
                binding.Bind(model);
                bindingList.Add(binding);
            }

            var test = RunActionAsync("NotifyTestB2", bindingTestCount, () =>
            {
                // update value
                foreach (var item in modelList)
                {
                    item.IntValue   = 1;
                    item.FloatValue = 2f;
                }
            });

            yield return(StartCoroutine(test));
        }
Пример #27
0
        public void NullRefonHasFieldsWithSameValueWithInterfaces()
        {
            
            Check.ThatCode(() =>
            {
                var modelA = new ModelA { Name = "Yoda" };
                var modelB = new ModelB { Name = new ModelBName { Title = "Frank" } };

                Check.That(modelA).HasFieldsWithSameValues(modelB);
            })
            .Throws<FluentCheckException>();
        }
 internal abstract void bindingMyText(ModelB source, A val);
 internal abstract A bindingMyText(ModelB source);
 override internal void bindingMyText(ModelB source, string val)
 {
     source.MyTextB = val;
 }
 override internal string bindingMyText(ModelB source)
 {
     return(source.MyTextB);
 }
Пример #32
0
        static void Main(string[] args)
        {
            Character warrior        = new Character("Human"); //У каждого класса свое предназначение, Класс кошка не может создавать ракеты...
            string    charactierInfo = warrior.GetRace();

            warrior.Hit(35);
            Console.WriteLine($"Ваша раса: {charactierInfo}, Здоровье персонажа: {warrior.GetHealth()}, Броня: {warrior.armor}");

            Character archer    = new Character("Wood Elf", 60);
            int       armorInfo = archer.armor;

            Console.WriteLine($"Ваша раса: {archer.GetRace()}, Здоровье персонажа: {archer.GetHealth()}, Броня: {armorInfo}");


            Calculator calc   = new Calculator();
            double     result = calc.SqrtLength(ab: 8, bc: 12, alpha: 45); //Именованные аргументы Ctrl + .(точка). Выбираем add argument ->

            result = Math.Round(value: result, digits: 2);
            Console.WriteLine("Площадь равна: " + result);

            double avg = calc.Average(numbers: new int[] { 1, 2, 3, 4 }); //инициализация массива Average (именованные аргументы)

            Console.WriteLine("Среднее значение: " + avg);
            //С помощью params можно передавать значения массива через запятую
            double avg2 = calc.Average2(1, 2, 3, 4);   //инициализация массива Average.

            Console.WriteLine("Инициализация среднего значения: " + avg2);


            //  Calculator.TryParsed(); //С использованием статического метода, без использования экземпляра


            Calculator divider = new Calculator();

            if (divider.TryDevide(5, 2, out double result2))
            {
                Console.WriteLine($"Результат деления равен: {result2}");
            }
            else
            {
                Console.WriteLine("Fail не получилось поделить");
            }

            //Создадим экземпляр структуры
            PointVal a; //это экземпляр структуры, тоже самое, что и PointVal a = new PointWal();

            a.x = 5;
            a.y = 8;

            //Создадим еще одну структуру b
            PointVal b = a;

            b.x = 4;
            b.y = 6;

            a.LogValues();
            b.LogValues();


            Console.WriteLine("Данные после struct (структуры)");
            //Создадим Экземпляр для класса

            PointRef c = new PointRef();

            c.x = 5;
            c.y = 8;

            //Создадим еще одну структуру b
            PointRef d = c;

            d.x = 4;
            d.y = 6;

            c.LogValues();
            d.LogValues();

            List <int> list = new List <int>();

            AddNumbers(list);
            foreach (int value in list)
            {
                Console.WriteLine("Вывод List " + value);
            }

            Swap(8, 6);
            //      SwapAuto(); //Значения вводит пользователь
            //     SwapFromFull(); //С защитой от дурака

            //Bankomat наследование inheritence
            ModelA terminalA = new ModelA(252);

            terminalA.Connect();
            ModelB terminalB = new ModelB(758);

            terminalB.Connect();

            //Car наследование
            Car1 bmw = new Car1("Bmw", "Black", 2.6, 289.7);

            bmw.CarInfo();
            Car2 dodge = new Car2("Dodge", "Yellow", 6.0, 382.3);

            dodge.CarInfo();

            Console.WriteLine();

            //Полиформизм (1 метод для каждого класса осуществляет свою операцию папка Polymorphism)
            Rectangle rectangle = new Rectangle(width: 17.5, height: 22.3);

            rectangle.Area();
            rectangle.Perimeter();
            rectangle.Draw();

            Console.WriteLine();

            Triangle triangle = new Triangle(a: 5.2, b: 6.3, c: 7.5);

            triangle.Area();
            triangle.Perimeter();
            triangle.Draw();
            Console.WriteLine();
            Console.WriteLine();

            /*Так как мы переопределили все эти методы, вызывающий код может унифицированно работать со всеми этими типами/классами
             * используя базовый класс/абстрактный, записать экземпляр абстрактного класса можно в виде массива и передать туда наши
             * классы - наследники в этот массив*/
            Shapes[] shapes = new Shapes[2];
            shapes[0] = new Triangle(6.3, 8.2, 9.7);
            shapes[1] = new Rectangle(22.4, 18.7);
            //Пройдемся foreach, используя базовый(абстрактный класс)
            foreach (var shape in shapes)
            {
                shape.Area();
                shape.Draw();
                shape.Perimeter();
            }
            Console.WriteLine();
            Console.WriteLine();
            Do(triangle);

            MyStack <int> ms = new MyStack <int>(); //у нас 2 перегрузки массива (по умолчанию 4 элемента), либо выбрать размер какой необходим

            ms.Push(1);
            ms.Push(2);
            ms.Push(3);
            Console.WriteLine(ms.Peek()); //Выведем последний добавленный элемент
            ms.Pop();                     //удалим последний элемент
            Console.WriteLine(ms.Peek());
            ms.Push(3);
            ms.Push(4);
            ms.Push(5); //чтобы произошло расширение стека, чтобы убедиться, что ничего не падает
            Console.WriteLine(ms.Peek());

            //Вадим Шванов
            ShvanovCar shamovCar = new ShvanovCar();

            shamovCar.CarInfo();
            ShvanovCar shCar = new ShvanovCar("F1", 260);

            shCar.CarInfo();

            RandomNumbers();
        }
Пример #33
0
 public ViewModel(ModelA ma, ModelB mb)
 {
     Property("Total", () => ma.PropA + mb.PropB);
 }
Пример #34
0
 public ViewModel(ModelA ma, ModelB mb)
 {
     Property("Total", () => ma.PropA + mb.PropB);
 }