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


C# Setting.Save方法代码示例

本文整理汇总了C#中Setting.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Setting.Save方法的具体用法?C# Setting.Save怎么用?C# Setting.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Setting的用法示例。


在下文中一共展示了Setting.Save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

        /// <summary>
        /// Server Main Entry Point - Initialize as many things as possible here.
        /// Order is important here, any additional initialization should be place at the bottom.
        /// </summary>
        /// <param name="Directory">Start Directory.</param>
        public static void Start(string Directory)
        {
            try
            {
                // Initialize Setting
                Setting = new Setting(Directory);

                // Initialize Logger.
                Logger = new LoggerCollection();
                Logger.Start();

                if (Setting.Load())
                {
                    Setting.Save();
                }
                else
                {
                    Setting.Save();
                    Environment.Exit(0);
                    return;
                }

                // Initialize Updater
                if (Setting.CheckForUpdate)
                {
                    Updater = new Updater();
                    Updater.Update();
                }

                if (Setting.MainEntryPoint == Setting.MainEntryPointType.jianmingyong_Server)
                {
                    // Initialize Listener.
                    Listener = new Server_Client_Listener.Servers.Listener();
                    Listener.Start();

                    // Initialize RCONListener.
                    if (Setting.RCONEnable)
                    {
                        RCONListener = new RCON_Client_Listener.Servers.Listener();
                        RCONListener.Start();
                    }

                    // Initialize SCONListener.
                    if (Setting.SCONEnable)
                    {
                        SCONListener = new SCON_Client_Listener.Servers.ModuleSCON();
                        SCONListener.Start();
                        //Logger.Log("SCON have been disabled due to incompatible update. Sorry for the inconvience caused.", Server_Client_Listener.Loggers.Logger.LogTypes.Info);
                    }

                    // Initialize Nancy.
                    if (Setting.NancyEnable)
                    {
                        var dataApi = new NancyData();
                        dataApi.Add("online", GetOnlineClients);

                        NancyImpl.SetDataApi(dataApi);
                        NancyImpl.Start(Setting.NancyHost, Setting.NancyPort);
                    }
                }

                // Initialize Command.
                Command = new CommandCollection();
                Command.AddCommand();
            }
            catch (Exception ex)
            {
                ex.CatchError();
            }
        }
开发者ID:jianmingyong,项目名称:Pokemon-3D-Server-Client,代码行数:75,代码来源:Core.cs

示例2: GetSetting

        /// <summary>
        /// Gets the setting from the database for the given key. If the key does
        /// not exit then the default value will be returned. If the key does not exist
        /// then when persistToDatabase is true the default value will be save to database.
        /// </summary>
        /// <remarks>This method provides useful way to add new values to the settings table
        /// when first accessing a key which does not already exist</remarks>
        /// <param name="name">key name of the value to return from the
        /// database</param>
        /// <param name="defaultValue">default value to return if the key doesnt exist in
        /// the database</param>
        /// <param name="persistToDatabase">indicates if the key does not already exist
        /// then the default value should be stored in the database</param>
        /// <returns>string value for the key</returns>
        public static string GetSetting(string name, string defaultValue, bool persistToDatabase)
        {
            if (Settings.ContainsKey(name))
                return Settings[name].ValueX;
            else
            {
                if (persistToDatabase)
                {
                    //todo: store the value
                    Setting newSetting = new Setting();
                    newSetting.Name = name;
                    newSetting.ValueX = defaultValue;
                    newSetting.Save();

                    //force a reload of the cache on the next request
                    ClearSettingsCache();
                }

                return defaultValue;
            }
        }
开发者ID:Letractively,项目名称:dotnetkicks,代码行数:35,代码来源:SettingsCache.cs


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