当前位置: 首页>>代码示例>>C#>>正文


C# Config.XmlConfigSource类代码示例

本文整理汇总了C#中Nini.Config.XmlConfigSource的典型用法代码示例。如果您正苦于以下问题:C# XmlConfigSource类的具体用法?C# XmlConfigSource怎么用?C# XmlConfigSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


XmlConfigSource类属于Nini.Config命名空间,在下文中一共展示了XmlConfigSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EmptyConstructor

        public void EmptyConstructor()
        {
            string filePath = "EmptyConstructor.xml";
            XmlConfigSource source = new XmlConfigSource ();

            IConfig config = source.AddConfig ("Pets");
            config.Set ("cat", "Muffy");
            config.Set ("dog", "Rover");
            config.Set ("bird", "Tweety");
            source.Save (filePath);

            Assert.AreEqual (3, config.GetKeys ().Length);
            Assert.AreEqual ("Muffy", config.Get ("cat"));
            Assert.AreEqual ("Rover", config.Get ("dog"));
            Assert.AreEqual ("Tweety", config.Get ("bird"));

            source = new XmlConfigSource (filePath);
            config = source.Configs["Pets"];

            Assert.AreEqual (3, config.GetKeys ().Length);
            Assert.AreEqual ("Muffy", config.Get ("cat"));
            Assert.AreEqual ("Rover", config.Get ("dog"));
            Assert.AreEqual ("Tweety", config.Get ("bird"));

            File.Delete (filePath);
        }
开发者ID:rwhitworth,项目名称:nini,代码行数:26,代码来源:XmlConfigSourceTests.cs

示例2: AutoUpdateHepler

 static AutoUpdateHepler()
 {
     string str = FileUtility.ApplicationRootPath + @"\update";
     if (LoggingService.IsInfoEnabled)
     {
         LoggingService.Info("读取升级配置:" + str);
     }
     XmlConfigSource source = null;
     if (System.IO.File.Exists(str + ".cxml"))
     {
         XmlTextReader decryptXmlReader = new CryptoHelper(CryptoTypes.encTypeDES).GetDecryptXmlReader(str + ".cxml");
         IXPathNavigable document = new XPathDocument(decryptXmlReader);
         source = new XmlConfigSource(document);
         decryptXmlReader.Close();
     }
     else if (System.IO.File.Exists(str + ".xml"))
     {
         source = new XmlConfigSource(str + ".xml");
     }
     if (source != null)
     {
         softName = source.Configs["FtpSetting"].GetString("SoftName", string.Empty);
         version = source.Configs["FtpSetting"].GetString("Version", string.Empty);
         server = source.Configs["FtpSetting"].GetString("Server", string.Empty);
         user = source.Configs["FtpSetting"].GetString("User", string.Empty);
         password = source.Configs["FtpSetting"].GetString("Password", string.Empty);
         path = source.Configs["FtpSetting"].GetString("Path", string.Empty);
         liveup = source.Configs["FtpSetting"].GetString("LiveUp", string.Empty);
         autoupdate = source.Configs["FtpSetting"].GetString("autoupdate", string.Empty);
     }
 }
开发者ID:vanloc0301,项目名称:mychongchong,代码行数:31,代码来源:AutoUpdateHepler.cs

示例3: HasNewVesion

 public static bool HasNewVesion()
 {
     try
     {
         if (!string.IsNullOrEmpty(server))
         {
             WebRequest request = WebRequest.Create(string.Format("ftp://{0}/{1}/update.xml", server, softName));
             request.Credentials = new NetworkCredential(user, password);
             WebResponse response = request.GetResponse();
             XmlDocument document = new XmlDocument();
             document.Load(response.GetResponseStream());
             XmlConfigSource source = new XmlConfigSource(document);
             if (source.Configs["FtpSetting"].GetString("Version").CompareTo(version) > 0)
             {
                 LoggingService.InfoFormatted("系统有新版本:{0}", new object[] { source.Configs["FtpSetting"].GetString("Version") });
                 return true;
             }
         }
     }
     catch (Exception exception)
     {
         LoggingService.Error("查询是否有新版本时出错", exception);
     }
     return false;
 }
开发者ID:vanloc0301,项目名称:mychongchong,代码行数:25,代码来源:AutoUpdateHepler.cs

示例4: GetConfig

 private static XmlConfigSource GetConfig(string cfgFileName)
 {
     XmlConfigSource source = null;
     if (configs.ContainsKey(cfgFileName))
     {
         return configs[cfgFileName];
     }
     string filename = cfgFileName;
     int num = filename.LastIndexOf('.');
     if (filename.EndsWith(".config") && File.Exists(filename.Insert(num + 1, "c")))
     {
         filename = filename.Insert(num + 1, "c");
         LoggingService.DebugFormatted("读取的是加密的配置文件:{0}", new object[] { filename });
         CryptoHelper helper = new CryptoHelper(CryptoTypes.encTypeDES);
         using (XmlTextReader reader = helper.GetDecryptXmlReader(filename))
         {
             XPathDocument document = new XPathDocument(reader);
             source = new XmlConfigSource(document);
             goto Label_00B8;
         }
     }
     if (!File.Exists(filename))
     {
         throw new ArgumentOutOfRangeException(cfgFileName + "不存在");
     }
     source = new XmlConfigSource(filename);
     Label_00B8:
     configs.Add(cfgFileName, source);
     return source;
 }
开发者ID:vanloc0301,项目名称:mychongchong,代码行数:30,代码来源:NiniConfigHelper.cs

示例5: CheckForUpdates

        public string CheckForUpdates(string clientVersion)
        {
            var response = string.Empty;

            try
            {
                if (!Directory.Exists(_dir + @"\Ester"))
                {
                    throw new Exception("Cannot find Ester folder on server");
                }

                _clientConfigSource = new XmlConfigSource(Path.Combine(HttpRuntime.AppDomainAppPath, @"Resources\Ester\Config.xml")) { AutoSave = true };
                int clientVersionNumber;
                if (int.TryParse(clientVersion, out clientVersionNumber))
                {
                    if (clientVersionNumber < GetLastVersionNumber())
                    {
                        response = _configSource.Configs["Update"].Get("UpdateFileUrl");
                    }
                }
            }
            catch (Exception exception)
            {
                WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.InternalServerError;
                WebOperationContext.Current.OutgoingResponse.StatusDescription = exception.Message;
            }

            return response;
        }
开发者ID:kib357,项目名称:Ester2,代码行数:29,代码来源:UpdateModule.cs

示例6: Merge

		public void Merge ()
		{
			StringWriter textWriter = new StringWriter ();
			XmlTextWriter xmlWriter = NiniWriter (textWriter);
			WriteSection (xmlWriter, "Pets");
			WriteKey (xmlWriter, "cat", "muffy");
			WriteKey (xmlWriter, "dog", "rover");
			WriteKey (xmlWriter, "bird", "tweety");
			xmlWriter.WriteEndDocument ();
			
			StringReader reader = new StringReader (textWriter.ToString ());
			XmlTextReader xmlReader = new XmlTextReader (reader);
			XmlConfigSource xmlSource = new XmlConfigSource (xmlReader);
			
			StringWriter writer = new StringWriter ();
			writer.WriteLine ("[People]");
			writer.WriteLine (" woman = Jane");
			writer.WriteLine (" man = John");
			IniConfigSource iniSource = 
					new IniConfigSource (new StringReader (writer.ToString ()));
			
			xmlSource.Merge (iniSource);
			
			IConfig config = xmlSource.Configs["Pets"];
			Assert.AreEqual (3, config.GetKeys ().Length);
			Assert.AreEqual ("muffy", config.Get ("cat"));
			Assert.AreEqual ("rover", config.Get ("dog"));
			
			config = xmlSource.Configs["People"];
			Assert.AreEqual (2, config.GetKeys ().Length);
			Assert.AreEqual ("Jane", config.Get ("woman"));
			Assert.AreEqual ("John", config.Get ("man"));
		}
开发者ID:JeffreyZksun,项目名称:gpstranslator,代码行数:33,代码来源:ConfigSourceBaseTests.cs

示例7: PluginSettingsBase

        /// <summary>
        /// Initializes a new instance of the <see cref="PluginSettingsBase"/> class.
        /// </summary>
        /// <param name="pluginName">Name of the plugin.</param>
        public PluginSettingsBase(string pluginName)
        {
            var fileName = string.Format("{0}\\Probel\\nDoctor\\{1}.plugin.config"
                   , Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
                   , pluginName);

            if (!File.Exists(fileName)) { this.BuildDefaultFileStream(fileName); }

            Source = new XmlConfigSource(fileName);
        }
开发者ID:seniorOtaka,项目名称:ndoctor,代码行数:14,代码来源:PluginSettingsBase.cs

示例8: GeneralSettings

        /// <summary>
        /// Initializes a new instance of the <see cref="GeneralSettings"/> class.
        /// </summary>
        /// <remarks>
        /// Internal to prevent construction of this class by any other
        /// assembly.  This class is intended to be constructed by the
        /// <see cref="Configuration"/> class only.
        /// </remarks>
        /// <param name="configurationSource">Reference to the
        /// configuration source that contains the configuration file.</param>
        internal GeneralSettings(XmlConfigSource configurationSource)
        {
            _config = configurationSource.Configs["General"];

            if (_config == null)
            {
                _config = configurationSource.AddConfig("General");
                SetDefaults();
            }
        }
开发者ID:vsukhoml,项目名称:gcdashboard,代码行数:20,代码来源:GeneralSettings.cs

示例9: DatabaseSettings

        /// <summary>
        /// Initializes a new instance of the <see cref="DatabaseSettings"/> class.
        /// </summary>
        /// <remarks>
        /// Internal to prevent construction of this class by any other
        /// assembly.  This class is intended to be constructed by the
        /// <see cref="Configuration"/> class only.
        /// </remarks>
        /// <param name="configurationSource">Reference to the
        /// configuration source that contains the configuration file.</param>
        internal DatabaseSettings(XmlConfigSource configurationSource)
        {
            _config = configurationSource.Configs["Database"];

            if (_config == null)
            {
                _config = configurationSource.AddConfig("Database");
                SetDefaults();
            }
        }
开发者ID:vsukhoml,项目名称:gcdashboard,代码行数:20,代码来源:DatabaseSettings.cs

示例10: GetConfig

        public void GetConfig()
        {
            StringWriter textWriter = new StringWriter ();
            XmlTextWriter writer = NiniWriter (textWriter);
            WriteSection (writer, "Pets");
            WriteKey (writer, "cat", "muffy");
            WriteKey (writer, "dog", "rover");
            WriteKey (writer, "bird", "tweety");
            writer.WriteEndDocument ();

            StringReader reader = new StringReader (textWriter.ToString ());
            XmlTextReader xmlReader = new XmlTextReader (reader);
            XmlConfigSource source = new XmlConfigSource (xmlReader);

            IConfig config = source.Configs["Pets"];
            Assert.AreEqual ("Pets", config.Name);
            Assert.AreEqual (3, config.GetKeys ().Length);
            Assert.AreEqual (source, config.ConfigSource);
        }
开发者ID:rwhitworth,项目名称:nini,代码行数:19,代码来源:XmlConfigSourceTests.cs

示例11: SupportClass

 static SupportClass()
 {
     string path = Path.Combine(DAOConfigsPath, "DAO.config");
     LoggingService.DebugFormatted("查找DAO配置文件:{0}", new object[] { path });
     if (File.Exists(path))
     {
         config = new XmlConfigSource(path);
     }
     else
     {
         path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, path);
         LoggingService.DebugFormatted("查找DAO配置文件:{0}", new object[] { path });
         if (File.Exists(path))
         {
             config = new XmlConfigSource(path);
         }
     }
     if (config == null)
     {
         LoggingService.Warn("没有找到DAO配置文件...");
     }
 }
开发者ID:vanloc0301,项目名称:mychongchong,代码行数:22,代码来源:SupportClass.cs

示例12: GetString

		public void GetString ()
		{
			StringWriter textWriter = new StringWriter ();
			XmlTextWriter writer = NiniWriter (textWriter);
			WriteSection (writer, "Pets");
			WriteKey (writer, "cat", "muffy");
			WriteKey (writer, "dog", "rover");
			WriteKey (writer, "bird", "tweety");
			writer.WriteEndDocument ();
			
			StringReader reader = new StringReader (textWriter.ToString ());
			XmlTextReader xmlReader = new XmlTextReader (reader);
			XmlConfigSource source = new XmlConfigSource (xmlReader);

			IConfig config = source.Configs["Pets"];
			
			Assert.AreEqual ("muffy", config.Get ("cat"));
			Assert.AreEqual ("rover", config.Get ("dog"));
			Assert.AreEqual ("muffy", config.GetString ("cat"));
			Assert.AreEqual ("rover", config.GetString ("dog"));
			Assert.AreEqual ("my default", config.Get ("Not Here", "my default"));
			Assert.IsNull (config.Get ("Not Here 2"));
		}
开发者ID:JeffreyZksun,项目名称:gpstranslator,代码行数:23,代码来源:XmlConfigSourceTests.cs

示例13: SupportClass

 static SupportClass()
 {
     string path = Path.Combine(DataFormsConfigPath, source);
     if (File.Exists(path))
     {
         config = new XmlConfigSource(path);
     }
     else
     {
         path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, source);
         if (File.Exists(path))
         {
             config = new XmlConfigSource(path);
         }
     }
     if (config == null)
     {
         throw new NullReferenceException("找不到表单配置文件:" + path);
     }
     string[] keys = config.Configs["DataBindProperty"].GetKeys();
     DBPKeys = new StringCollection();
     DBPKeys.AddRange(keys);
 }
开发者ID:vanloc0301,项目名称:mychongchong,代码行数:23,代码来源:SupportClass.cs

示例14: ReadConfig

        /// <summary>
        /// Provide same ini loader functionality for standard ini and master ini - file system or XML over http
        /// </summary>
        /// <param name="iniPath">Full path to the ini</param>
        /// <returns></returns>
        private bool ReadConfig(string iniPath)
        {
            bool success = false;

            if (!IsUri(iniPath))
            {
                m_log.InfoFormat("[CONFIG] Reading configuration file {0}",
                        Path.GetFullPath(iniPath));

                m_config.Merge(new IniConfigSource(iniPath));
                success = true;
            }
            else
            {
                m_log.InfoFormat("[CONFIG] {0} is a http:// URI, fetching ...",
                        iniPath);

                // The ini file path is a http URI
                // Try to read it
                //
                try
                {
                    XmlReader r = XmlReader.Create(iniPath);
                    XmlConfigSource cs = new XmlConfigSource(r);
                    m_config.Merge(cs);

                    success = true;
                }
                catch (Exception e)
                {
                    m_log.FatalFormat("[CONFIG] Exception reading config from URI {0}\n" + e.ToString(), iniPath);
                    Environment.Exit(1);
                }
            }
            return success;
        }
开发者ID:SignpostMarv,项目名称:opensim,代码行数:41,代码来源:ConfigurationLoader.cs

示例15: ReadConfig

        /// <summary>
        /// Provide same ini loader functionality for standard ini and master ini - file system or XML over http
        /// </summary>
        /// <param name="iniPath">Full path to the ini</param>
        /// <returns></returns>
        private bool ReadConfig(string iniPath, int i)
        {
            bool success = false;

            if (!IsUri(iniPath))
            {
                if(showIniLoading)
                    m_log.InfoFormat("[CONFIG]: Reading configuration file {0}", Path.GetFullPath(iniPath));

                m_config.Merge(new IniConfigSource(iniPath, Nini.Ini.IniFileType.AuroraStyle));
                if (inidbg)
                {
                    WriteConfigFile(i, m_config);
                }
                success = true;
            }
            else
            {
                m_log.InfoFormat("[CONFIG]: {0} is a http:// URI, fetching ...", iniPath);

                // The ini file path is a http URI
                // Try to read it
                try
                {
                    XmlReader r = XmlReader.Create(iniPath);
                    XmlConfigSource cs = new XmlConfigSource(r);
                    m_config.Merge(cs);

                    success = true;
                }
                catch (Exception e)
                {
                    m_log.FatalFormat("[CONFIG]: Exception reading config from URI {0}\n" + e.ToString(), iniPath);
                    Environment.Exit(1);
                }
            }
            return success;
        }
开发者ID:KristenMynx,项目名称:Aurora-Sim,代码行数:43,代码来源:ConfigurationLoader.cs


注:本文中的Nini.Config.XmlConfigSource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。