コード例 #1
0
        private void LoadXmlConfig(string configPath)
        {
            if (!File.Exists(configPath))
            {
                _logger.Warn <UnVersionConfig>("Couldn't find config file " + configPath);
                return;
            }

            var xmlConfig = new XmlDocument();

            xmlConfig.Load(configPath);

            foreach (XmlNode xmlConfigEntry in xmlConfig.SelectNodes("/unVersionConfig/add"))
            {
                if (xmlConfigEntry.NodeType == XmlNodeType.Element)
                {
                    var configEntry = new UnVersionConfigEntry
                    {
                        DocTypeAlias = xmlConfigEntry.Attributes["docTypeAlias"] != null
                            ? xmlConfigEntry.Attributes["docTypeAlias"].Value
                            : AllDocumentTypesKey
                    };

                    if (xmlConfigEntry.Attributes["rootXpath"] != null)
                    {
                        configEntry.RootXPath = xmlConfigEntry.Attributes["rootXpath"].Value;
                    }

                    if (xmlConfigEntry.Attributes["maxDays"] != null)
                    {
                        configEntry.MaxDays = Convert.ToInt32(xmlConfigEntry.Attributes["maxDays"].Value);
                    }

                    if (xmlConfigEntry.Attributes["maxCount"] != null)
                    {
                        configEntry.MaxCount = Convert.ToInt32(xmlConfigEntry.Attributes["maxCount"].Value);
                    }

                    if (!ConfigEntries.ContainsKey(configEntry.DocTypeAlias))
                    {
                        ConfigEntries.Add(configEntry.DocTypeAlias, new List <UnVersionConfigEntry>());
                    }

                    ConfigEntries[configEntry.DocTypeAlias].Add(configEntry);
                }
            }
        }
コード例 #2
0
        private void LoadXmlConfig(string configPath)
        {
            if (!File.Exists(configPath))
            {
                Logger.Warn("Couldn't find config file " + configPath);
                return;
            }

            var xmlConfig = new XmlDocument();
            xmlConfig.Load(configPath);

            foreach (XmlNode xmlConfigEntry in xmlConfig.SelectNodes("/unVersionConfig/add"))
            {
                if (xmlConfigEntry.NodeType == XmlNodeType.Element)
                {
                    var configEntry = new UnVersionConfigEntry
                    {
                        DocTypeAlias = xmlConfigEntry.Attributes["docTypeAlias"] != null
                            ? xmlConfigEntry.Attributes["docTypeAlias"].Value
                            : "$_ALL"
                    };

                    if (xmlConfigEntry.Attributes["rootXpath"] != null)
                        configEntry.RootXPath = xmlConfigEntry.Attributes["rootXpath"].Value;

                    if (xmlConfigEntry.Attributes["maxDays"] != null)
                        configEntry.MaxDays = Convert.ToInt32(xmlConfigEntry.Attributes["maxDays"].Value);

                    if (xmlConfigEntry.Attributes["maxCount"] != null)
                        configEntry.MaxCount = Convert.ToInt32(xmlConfigEntry.Attributes["maxCount"].Value);

                    if(!ConfigEntries.ContainsKey(configEntry.DocTypeAlias))
                        ConfigEntries.Add(configEntry.DocTypeAlias, new List<UnVersionConfigEntry>());

                    ConfigEntries[configEntry.DocTypeAlias].Add(configEntry);
                }
            }
        }