Ejemplo n.º 1
0
        /// <summary>
        /// Filling entities from FormCollection with default property converter
        /// </summary>
        /// <typeparam name="T">Type of filling object.</typeparam>
        /// <param name="collection">The FormCollection.</param>
        /// <param name="fillTObject">The filling object.</param>
        /// <returns>Object after fill value.</returns>
        public T Populate <T>(FormCollection collection, T fillTObject)
        {
            var nodes = FormTreeCollector.ConvertToTree(collection);

            DynamicFill(nodes, fillTObject);

            return(fillTObject);
        }
Ejemplo n.º 2
0
        public void TestTreeNodesConvertor()
        {
            var treeCollection = FormTreeCollector.ConvertToTree(collection);

            //{ "TestSystemField", "Value"},
            TestElement(treeCollection, "Value", "TestSystemField");
            //{ "TestSystemCollection.Field1", "Value"},
            TestElement(treeCollection, "Value", "TestSystemCollection", "Field1");
            //{ "TestSystemCollection.Field2", "Value"},
            TestElement(treeCollection, "Value", "TestSystemCollection", "Field2");

            //{"fname", "Petrov"},
            TestElement(treeCollection, "Petrov", "FirstName");
            //{"sname", "Petr" },
            TestElement(treeCollection, "Petr", "SecondaryName");

            //{"salary.amount", "10 000"}
            TestElement(treeCollection, "10 000", "Salary", "Amount");
            //{"salary.rate", "Eur"}
            TestElement(treeCollection, "Eur", "Salary", "Rate");

            //{"Phone.mobile.number", "555-55-55" },
            TestElement(treeCollection, "555-55-55", "Phones", "Mobile", "Number");
            //{"phone.home.number", "666-66-66" },
            TestElement(treeCollection, "666-66-66", "Phones", "Home", "Number");

            //{"address.home.city", "Moscow" },
            TestElement(treeCollection, "Moscow", "Address", "Home", "City");
            //{"address.home.street", "Petrova" },
            TestElement(treeCollection, "Petrova", "Address", "Home", "Street");

            //{"Workinfo.address.city", "Kazan" },
            TestElement(treeCollection, "Kazan", "WorkInfo", "Address", "City");
            //{"Workinfo.address.street", "Lenina" },
            TestElement(treeCollection, "Lenina", "WorkInfo", "Address", "Street");
            //{"Workinfo.staff.boss.fname", "Ivanov" },
            TestElement(treeCollection, "Ivanov", "WorkInfo", "Staff", "Boss", "FirstName");
            //{"Workinfo.staff.boss.sname", "Ivan" },
            TestElement(treeCollection, "Ivan", "WorkInfo", "Staff", "Boss", "SecondaryName");
            //{"Workinfo.staff.boss.phone.mobile.number", "222-22-22" },
            TestElement(treeCollection, "222-22-22", "WorkInfo", "Staff", "Boss", "Phones", "Mobile", "Number");

            //{"Workinfo.staff.SecondaryBoss.fname", "Sidorova" },
            TestElement(treeCollection, "Sidorova", "WorkInfo", "Staff", "SecondaryBoss", "FirstName");
            //{"Workinfo.staff.SecondaryBoss.sname", "Anna" },
            TestElement(treeCollection, "Anna", "WorkInfo", "Staff", "SecondaryBoss", "SecondaryName");
            //{"Workinfo.staff.SecondaryBoss.phone.mobile.number", "333-33-33" },
            TestElement(treeCollection, "333-33-33", "WorkInfo", "Staff", "SecondaryBoss", "Phones", "Undefined", "Number");
            //{"WorkInfo.Staff.SecondaryBoss.Phones.Undefined.Type", "Work" },
            TestElement(treeCollection, "Work", "WorkInfo", "Staff", "SecondaryBoss", "Phones", "Undefined", "Type");
            //{"Workinfo.staff.SecondaryBoss.phone.home.number", "111-11-11" },
            TestElement(treeCollection, "111-11-11", "WorkInfo", "Staff", "SecondaryBoss", "Phones", "Home", "Number");
        }