Exemplo n.º 1
0
        public void DynamicTest()
        {
            //assets
            var defaults = new List <MeauseUnit>()
            {
                new MeauseUnit  {
                    Id = 1, CLRType = typeof(int), IsSystem = true, Abbreviation = "FactoryShop", Description = "Цех, производство"
                },
                new MeauseUnit  {
                    Id = 1, CLRType = typeof(int), IsSystem = true, Abbreviation = "Plant", Description = "Установка"
                },
            };

            dynamic expando = new ExpandoObject() as IDictionary <string, Object>;

            expando.Add("Shout", new Action(() => { Console.WriteLine("Hellooo!!!"); }));
            expando.Add("Id", 1);

            //dynamic root;
            var root = new GeneralHierarchyUnit()
            {
                Id = 1, Description = "My root"
            };


            dynamic p = new ExpandoObject();

            p["firstNam"] = "John";

            defaults.ForEach(item => expando.Add(item.Abbreviation, 0));

            Console.WriteLine();
            Console.ReadKey();
        }
Exemplo n.º 2
0
        public void StructureEq()
        {
            var tree     = new Tree <GeneralHierarchyUnit>();
            var rootNode = new GeneralHierarchyUnit()
            {
                Depth = 0, Id = 1, Description = "Нафтан"
            };

            var node1 = new GeneralHierarchyUnit()
            {
                Depth = 1, Id = 2, Description = "Электpодвигатели (ЭД)", Parent = rootNode
            };
            var node2 = new GeneralHierarchyUnit()
            {
                Depth = 1, Id = 3, Description = "Насосы (НС) (НКО)", Parent = rootNode
            };
            var node3 = new GeneralHierarchyUnit()
            {
                Depth = 1, Id = 4, Description = "Компрессоры (К) (HКО)", Parent = rootNode
            };
            var node4 = new GeneralHierarchyUnit()
            {
                Depth = 1, Id = 5, Description = "Грузоподъемные механизмы", Parent = rootNode
            };

            var node5 = new GeneralHierarchyUnit()
            {
                Depth = 1, Id = 6, Description = "Электpодвигатели (ЭД)", Parent = rootNode
            };
            var node6 = new GeneralHierarchyUnit()
            {
                Depth = 1, Id = 7, Description = "Насосы (НС) (НКО)", Parent = rootNode
            };
        }