コード例 #1
0
        private TSetupEntityCollection GetSetupEntityCollection(IEntityConfig config)
        {
            TSetupEntityCollection entityCollection = new TSetupEntityCollection();

            entityCollection.EntityCollection = new List <TSetupEntity>();

            // City entity
            TSetupEntity entity1 = new TSetupEntity()
            {
                EntityName            = "City",
                EntityQueryCollection = new List <TSetupEntityQuery>()
                {
                    GetSetupEntityQuery("City", EntityQueryType.FindByKey, config),
                    GetSetupEntityQuery("City", EntityQueryType.FindByString, config)
                }
            };

            // Order entity
            TSetupEntity entity2 = new TSetupEntity()
            {
                EntityName            = "Order",
                EntityQueryCollection = new List <TSetupEntityQuery>()
                {
                    GetSetupEntityQuery("Order", EntityQueryType.FindByKey, config),
                    GetSetupEntityQuery("Order", EntityQueryType.FindByString, config),
                    GetSetupEntityQuery("Order", EntityQueryType.FindByParentKey, config, "City")
                }
            };

            entityCollection.EntityCollection.Add(entity1);
            entityCollection.EntityCollection.Add(entity2);

            return(entityCollection);
        }
コード例 #2
0
        private void SaveDefaultSetup()
        {
            string        path         = Application.StartupPath;
            IEntityConfig entityConfig = new EntityConfig();
            XmlSerializer xmlser       = new XmlSerializer(typeof(TSetupEntityCollection));

            TSetupEntityCollection setupEntityCollection = GetSetupEntityCollection(entityConfig);

            SetupRepository.SaveSetupEntityCollection(path, setupEntityCollection);
        }
コード例 #3
0
        public static void SaveSetupEntityCollection(string path, TSetupEntityCollection col)
        {
            Debug.Assert(!string.IsNullOrWhiteSpace(path));
            string fullFileName = Path.Combine(path, SettingsFileName);

            XmlSerializer xmlser = new XmlSerializer(typeof(TSetupEntityCollection));
            StreamWriter  sw     = new StreamWriter(fullFileName);

            xmlser.Serialize(sw, col);
            sw.Close();
        }
コード例 #4
0
        private void SaveSettings()
        {
            string path = Application.StartupPath;
            TSetupEntityCollection entityCol = new TSetupEntityCollection();

            entityCol.EntityCollection = new List <TSetupEntity>();
            foreach (TSetupEntity el in m_EntityName_BindingSource.List)
            {
                entityCol.EntityCollection.Add(el);
            }

            SetupRepository.SaveSetupEntityCollection(path, entityCol);
        }
コード例 #5
0
        public static TSetupEntityCollection LoadSetupConnectionCollection(string path)
        {
            Debug.Assert(!string.IsNullOrWhiteSpace(path));
            string fullFileName = Path.Combine(path, SettingsFileName);

            // Создание пустого файла настроек
            if (!File.Exists(fullFileName))
            {
                TSetupEntityCollection colTmp = new TSetupEntityCollection();
                SaveSetupEntityCollection(path, colTmp);
            }

            XmlSerializer          xmlser = new XmlSerializer(typeof(TSetupEntityCollection));
            StreamReader           sr     = new StreamReader(fullFileName);
            TSetupEntityCollection col    = (TSetupEntityCollection)xmlser.Deserialize(sr);

            sr.Close();

            return(col);
        }