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


C# Config.Save方法代码示例

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


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

示例1: DialogSetting

 public DialogSetting()
 {
     Configs = new Config("Config gh-Helpful Tool v2.0 By Help-Kung", Environment.GetEnvironmentVariable("TEMP")+"\\gh2.0_HelpfulToolSettings.ini");
     if (!Configs.Created)
     {
         Configs.Save("Folder", new String[] { "C:\\" });
         Configs.Save("Speed", new String[] { "200" });
         Configs.Save("Language", new String[] { "1" });
         Configs.Write();
     }
     InitializeComponent();
     ChangeLanguage();
 }
开发者ID:dvgamer,项目名称:ghHelpful,代码行数:13,代码来源:DialogSetting.cs

示例2: SampleMethod

        public static void SampleMethod() {
            using(Config<SampleNamespace.SampleConfig> c = new Config<SampleNamespace.SampleConfig>()) {
                // Access and save values via c.Values
				// if saving use c.Save() to save and refresh
                c.Save();
            }
        }
开发者ID:jussinen,项目名称:Crafted.Config,代码行数:7,代码来源:Sample.cs

示例3: Awake

    public bool useIniFile = false; // get client settings from an ini file or from this script

    #endregion Fields

    #region Methods

    // Start the TimelineServer if this client is acting as a server
    // One (and only one) client must be selected as a server
    void Awake()
    {
        Config config=Config.Load(Application.dataPath+"/../" + iniFileName + ".ini");

        if (config == null)
        {
            config = new Config();
            config.AddChild("IsServer", isServer);
            config.Save(Application.dataPath+"/../" + iniFileName + ".ini");

        }

        if (useIniFile && config["IsServer"].BoolValue)
        {
            DontDestroyOnLoad(this);
            TimelineServer.Start(true);
            Debug.Log("Server Started");
        }
            else
        {
            config["IsServer"].BoolValue = isServer;
            config.Save(Application.dataPath+"/../" + iniFileName + ".ini");
            if (isServer)
            {
                DontDestroyOnLoad(this);
                TimelineServer.Start(true);
                Debug.Log("Server Started");
            }

        }
    }
开发者ID:Berrrrnie,项目名称:Storytelling,代码行数:39,代码来源:TimelineServerStarter.cs

示例4: TestEmptyDocumentCreatesFile

        public void TestEmptyDocumentCreatesFile() {
            IConfig config = new Config();

            config.Save(this.ConfigFileA);

            this.ConfigFileA.Refresh();

            Assert.IsTrue(this.ConfigFileA.Exists);
        }
开发者ID:EBassie,项目名称:Potato,代码行数:9,代码来源:TestSave.cs

示例5: TestSimpleDocumentCreatesFile

        public void TestSimpleDocumentCreatesFile() {
            IConfig config = new Config() {
                Document = new JObject() {
                    new JProperty("Hello", "World!")
                }
            };

            config.Save(this.ConfigFileA);

            this.ConfigFileA.Refresh();

            Assert.IsTrue(this.ConfigFileA.Exists);
        }
开发者ID:EBassie,项目名称:Potato,代码行数:13,代码来源:TestSave.cs

示例6: TestSimpleDocumentCanDeserialize

        public void TestSimpleDocumentCanDeserialize() {
            IConfig config = new Config() {
                Document = new JObject() {
                    new JProperty("Hello", "World!")
                }
            };

            config.Save(this.ConfigFileA);

            JObject deseralized = JsonConvert.DeserializeObject(File.ReadAllText(this.ConfigFileA.FullName)) as JObject;

            Assert.IsNotNull(deseralized);
            Assert.AreEqual("World!", deseralized["Hello"].Value<String>());
        }
开发者ID:EBassie,项目名称:Potato,代码行数:14,代码来源:TestSave.cs

示例7: TestEnabledPluginSavedToConfig

        public void TestEnabledPluginSavedToConfig() {
            Guid connectionGuid = Guid.NewGuid();
            Guid onePluginGuid = Guid.NewGuid();
            Guid twoPluginGuid = Guid.NewGuid();

            ICorePluginController plugins = new CorePluginController() {
                Connection = new ConnectionController() {
                    ConnectionModel = new ConnectionModel() {
                        ConnectionGuid = connectionGuid
                    }
                },
                LoadedPlugins = new List<PluginModel>() {
                    new PluginModel() {
                        Name = "One",
                        IsEnabled = false,
                        PluginGuid = onePluginGuid
                    },
                    new PluginModel() {
                        Name = "Two",
                        IsEnabled = true,
                        PluginGuid = twoPluginGuid
                    }
                }
            };

            IConfig config = new Config().Create<CorePluginController>();

            plugins.WriteConfig(config);

            config.Save(this.ConfigFile);

            // Now load up the config and ensure it saved what we wanted it too.

            var loadConfig = new Config();
            loadConfig.Load(this.ConfigFile);

            var commands = loadConfig.RootOf<CorePluginController>().Children<JObject>().Select(item => item.ToObject<IConfigCommand>(JsonSerialization.Minimal)).ToList();

            Assert.AreEqual("PluginsEnable", commands[0].Command.Name);
            Assert.AreEqual(connectionGuid, commands[0].Command.Scope.ConnectionGuid);
            Assert.AreEqual(twoPluginGuid, commands[0].Command.Scope.PluginGuid);
        }
开发者ID:EBassie,项目名称:Potato,代码行数:42,代码来源:TestPluginConfig.cs

示例8: TestNullException

        public void TestNullException() {
            IConfig config = new Config();

            config.Save(null);
        }
开发者ID:EBassie,项目名称:Potato,代码行数:5,代码来源:TestSave.cs

示例9: TestWriteConfig

        public void TestWriteConfig() {
            var variables = (VariableController)new VariableController().Execute();
            variables.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.VariablesSetA,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "NameToWriteString",
                    "this is a string"
                })
            });

            variables.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.VariablesSetA,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "NameToWriteInteger",
                    1
                })
            });

            // Empty strings should not be written. No point saving nothing.
            variables.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.VariablesSetA,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "NameToignore",
                    ""
                })
            });

            variables.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.VariablesSet,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "NameToNotWrite",
                    "This shouldn't appear in the saved file."
                })
            });

            variables.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.VariablesSetA,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    CommonVariableNames.MaximumProtocolConnections,
                    10
                })
            });

            // Save a config of the variables controller
            var saveConfig = new Config();
            saveConfig.Create(typeof (VariableController));
            variables.WriteConfig(saveConfig);
            saveConfig.Save(ConfigFileInfo);

            // Load the config in a new config.
            var loadConfig = new Config();
            loadConfig.Load(ConfigFileInfo);

            var commands = loadConfig.RootOf<VariableController>().Children<JObject>().Select(item => item.ToObject<IConfigCommand>(JsonSerialization.Minimal)).ToList();

            // Order is not maintained so we can only check that the values in some disorder are output.
            // Nope, not perfect.
            foreach (var command in commands) {
                Assert.AreEqual("VariablesSetA", command.Command.Name);
                Assert.IsTrue(new List<String>() { "NameToWriteString", "NameToWriteInteger", "MaximumProtocolConnections" }.Contains(command.Command.Parameters[0].First<String>()));
                Assert.IsTrue(new List<String>() { "this is a string", "1", "10" }.Contains(command.Command.Parameters[1].First<String>()));
            }
        }
开发者ID:EBassie,项目名称:Potato,代码行数:68,代码来源:TestVariableController.cs

示例10: CreateConfig

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        private Config CreateConfig()
        {
            string filename = Path.Combine(Application.StartupPath, "PS6216Import.xml");
            Config config = null;
            try
            {
                config = (Config)Config.Load(typeof(Config), filename);
            }
            catch (Exception ex)
            {
                config = new Config();
                config.FromConnectionString = "f";
                config.ToConnectionString = "t";
                config.ImportInterval = TimeSpan .Parse ("00:00:10");

                NameMap nm = new NameMap();
                nm.FromName = "FN";
                nm.ToName = "TN";

                config.NameMapCollection.Add(nm);

                config.Save(filename);
                NUnit.UiKit.UserMessage.DisplayFailure(ex.Message);
                Environment.Exit(1);
            }
            return config;
        }
开发者ID:hkiaipc,项目名称:yh,代码行数:31,代码来源:Importer.cs

示例11: DoWorkDownloade


//.........这里部分代码省略.........
                                            if (DnsGetingURL.Connected)
                                            {
                                                Response = DnsGetingURL.ResponseHeader(RetryImage);
                                                // foreach (KeyValuePair<String, String> head in Response) Console.WriteLine(head.Key + ": " + head.Value);
                                                if (Response.ContainsKey("Content-Length")) ContentLenght = Int32.Parse(Response["Content-Length"]);

                                                if (Response["HTTP"] == "200 OK" && ContentLenght != 0)
                                                { // Start receiving data
                                                    Console.WriteLine("Start receiving URL...");
                                                    DownloadWorker.ReportProgress(-2);
                                                    do
                                                    {
                                                        ResponseHTML += DnsGetingURL.Response(Int32.Parse(Settings.Configs.GetValue("Speed")) * 1024);
                                                        NowLenght += DnsGetingURL.Downloading;
                                                        DownloadWorker.ReportProgress((NowLenght * 5) / ContentLenght);
                                                        // Console.WriteLine("Lenght:" + ContentLenght + " Speed: " + DnsGetingURL.Downloading + " | Total: " + NowLenght);
                                                    } while (NowLenght < ContentLenght && DnsGetingURL.Downloading != 0);
                                                    DownloadWorker.ReportProgress(-3);
                                                    if (RetryImage == "") RetryImage += "?nl="; else RetryImage += "&nl=";
                                                    String nlString = SplitUp.GetCenter(ResponseHTML, "onclick=\"return nl", "\">Click here if the image fails loading");
                                                    RetryImage += nlString.Substring(1, (nlString.Length - 2));

                                                    ResponseHTML = SplitUp.GetCenter(ResponseHTML, "</iframe>", "</iframe>");
                                                    ResponseHTML = SplitUp.GetCenter(ResponseHTML, "<img src=\"", "\"");
                                                    URLImage = ResponseHTML;                                                    
                                                    ImageName = SplitUp.GetRight(SplitUp.GetRight(URLImage, "keystamp="), "/");
                                                    if (ImageName == "")
                                                    {

                                                    }
                                                    if (Images.Count > ImagesCurrent) Images.RemoveAt(ImagesCurrent);
                                                    Console.WriteLine("ImageName: " + ImageName);
                                                    Images.Add(ImageName + "#");
                                                    Items.Save("Images", Images.ToArray());
                                                }
                                                else
                                                { // Error Page Connecting                                                    
                                                    Console.WriteLine(" ===>> Page :: " + Response["HTTP"] + " <<===");
                                                    ReceiveImage = false;
                                                    ImageFailsLoading = false;
                                                }
                                            }
                                            else
                                            { // Error Page Loading Image.
                                                Console.WriteLine(" ===>> Page :: Fails Connected <<===");
                                                ReceiveImage = false;
                                                ImageFailsLoading = false;
                                                e.Cancel = true;
                                            }
                                        }

                                        if (ReceiveImage)
                                        { // Start receiving data
                                            Console.WriteLine("Loading Images...");
                                            SyncNet DnsLoadImage = new SyncNet(URLImage);
                                            if (DnsLoadImage.Connected)
                                            {
                                                Response = DnsLoadImage.ResponseHeader("");
                                                // foreach (KeyValuePair<String, String> head in Response) Console.WriteLine(head.Key + ": " + head.Value);
                                                if (Response.ContainsKey("HTTP"))
                                                {
                                                    if (Response.ContainsKey("Content-Length")) ContentLenght = Int32.Parse(Response["Content-Length"]);
                                                    if (!Response.ContainsKey("Content-Disposition") && Response["HTTP"] == "200 OK")
                                                    {
                                                        Images[ImagesCurrent] = ImageName + "#" + ContentLenght;
                                                        Items.Save("Images", Images.ToArray());                                                        
开发者ID:dvgamer,项目名称:ghHelpful,代码行数:67,代码来源:DialogDownloader.cs

示例12: TestSecurityWriteConfig

        public void TestSecurityWriteConfig() {
            var security = new SecurityController();
            security.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.SecurityAddGroup,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "GroupName"
                })
            });
            security.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.SecurityGroupSetPermission,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "GroupName",
                    "CustomPermission",
                    22
                })
            });
            security.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.SecurityGroupSetPermission,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "GroupName",
                    CommandType.VariablesSet,
                    77
                })
            });
            security.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.SecurityGroupSetPermission,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "GroupName",
                    CommandType.VariablesSetA,
                    88
                })
            });
            security.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.SecurityGroupAddAccount,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "GroupName",
                    "Phogue"
                })
            });
            security.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.SecurityAccountSetPassword,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "Phogue",
                    "password"
                })
            });

            security.Tunnel(CommandBuilder.SecurityAccountAppendAccessToken("Phogue", Guid.Parse("f380eb1e-1438-48c0-8c3d-ad55f2d40538"), "Token Hash", DateTime.Parse("2024-04-14 20:51:00 PM")).SetOrigin(CommandOrigin.Local));

            security.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.SecurityAccountSetPreferredLanguageCode,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "Phogue",
                    "de-DE"
                })
            });
            security.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.SecurityAccountAddPlayer,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "Phogue",
                    CommonProtocolType.DiceBattlefield3,
                    "ABCDEF"
                })
            });

            // Save a config of the language controller
            var saveConfig = new Config();
            saveConfig.Create(typeof(SecurityController));
            security.WriteConfig(saveConfig);
            saveConfig.Save(ConfigFileInfo);

            // Load the config in a new config.
            var loadConfig = new Config();
            loadConfig.Load(ConfigFileInfo);

            var commands = loadConfig.RootOf<SecurityController>().Children<JObject>().Select(item => item.ToObject<IConfigCommand>(JsonSerialization.Minimal)).ToList();

            Assert.AreEqual("SecurityAddGroup", commands[0].Command.Name);
            Assert.AreEqual("Guest", commands[0].Command.Parameters[0].First<String>());

            Assert.AreEqual("SecurityAddGroup", commands[1].Command.Name);
            Assert.AreEqual("GroupName", commands[1].Command.Parameters[0].First<String>());

            Assert.AreEqual("SecurityGroupSetPermission", commands[2].Command.Name);
            Assert.AreEqual("GroupName", commands[2].Command.Parameters[0].First<String>());
            Assert.AreEqual(CommandType.VariablesSet.ToString(), commands[2].Command.Parameters[1].First<String>());
            Assert.AreEqual("77", commands[2].Command.Parameters[2].First<String>());

            Assert.AreEqual("SecurityGroupSetPermission", commands[3].Command.Name);
            Assert.AreEqual("GroupName", commands[3].Command.Parameters[0].First<String>());
            Assert.AreEqual(CommandType.VariablesSetA.ToString(), commands[3].Command.Parameters[1].First<String>());
            Assert.AreEqual("88", commands[3].Command.Parameters[2].First<String>());
//.........这里部分代码省略.........
开发者ID:EBassie,项目名称:Potato,代码行数:101,代码来源:TestSecurity.cs

示例13: TestSecurityLoadConfig

        public void TestSecurityLoadConfig() {
            var saveSecurity = new SecurityController();
            saveSecurity.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.SecurityAddGroup,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "GroupName"
                })
            });
            saveSecurity.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.SecurityGroupSetPermission,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "GroupName",
                    "CustomPermission",
                    22
                })
            });
            saveSecurity.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.SecurityGroupSetPermission,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "GroupName",
                    CommandType.VariablesSet,
                    77
                })
            });
            saveSecurity.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.SecurityGroupSetPermission,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "GroupName",
                    CommandType.VariablesSetA,
                    88
                })
            });
            saveSecurity.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.SecurityGroupAddAccount,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "GroupName",
                    "Phogue"
                })
            });
            saveSecurity.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.SecurityAccountSetPassword,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "Phogue",
                    "password"
                })
            });

            saveSecurity.Tunnel(CommandBuilder.SecurityAccountAppendAccessToken("Phogue", Guid.Parse("f380eb1e-1438-48c0-8c3d-ad55f2d40538"), "Token Hash", DateTime.Parse("2024-04-14 20:51:00 PM")).SetOrigin(CommandOrigin.Local));

            saveSecurity.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.SecurityAccountSetPreferredLanguageCode,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "Phogue",
                    "de-DE"
                })
            });
            saveSecurity.Tunnel(new Command() {
                Origin = CommandOrigin.Local,
                CommandType = CommandType.SecurityAccountAddPlayer,
                Parameters = TestHelpers.ObjectListToContentList(new List<Object>() {
                    "Phogue",
                    CommonProtocolType.DiceBattlefield3,
                    "ABCDEF"
                })
            });

            // Save a config of the security controller
            var saveConfig = new Config();
            saveConfig.Create(typeof(SecurityController));
            saveSecurity.WriteConfig(saveConfig);
            saveConfig.Save(ConfigFileInfo);

            // Load the config in a new config.
            var loadSecurity = (SecurityController)new SecurityController().Execute();
            var loadConfig = new Config();
            loadConfig.Load(ConfigFileInfo);
            loadSecurity.Execute(loadConfig);

            var lastGroup = loadSecurity.Groups.LastOrDefault(group => @group.Name == "GroupName") ?? new GroupModel();

            Assert.AreEqual("Guest", loadSecurity.Groups.First().Name);
            Assert.AreEqual("GroupName", loadSecurity.Groups.Last().Name);
            Assert.AreEqual(22, lastGroup.Permissions.First(permission => permission.Name == "CustomPermission").Authority);
            Assert.AreEqual(77, lastGroup.Permissions.First(permission => permission.Name == CommandType.VariablesSet.ToString()).Authority);
            Assert.AreEqual(88, lastGroup.Permissions.First(permission => permission.Name == CommandType.VariablesSetA.ToString()).Authority);
            Assert.AreEqual("Phogue", loadSecurity.Groups.SelectMany(group => group.Accounts).First().Username);
            Assert.AreEqual(Guid.Parse("f380eb1e-1438-48c0-8c3d-ad55f2d40538"), loadSecurity.Groups.SelectMany(group => group.Accounts).First().AccessTokens.First().Value.Id);
            Assert.AreEqual("Token Hash", loadSecurity.Groups.SelectMany(group => group.Accounts).First().AccessTokens.First().Value.TokenHash);
            Assert.AreEqual(DateTime.Parse("2024-04-14 20:51:00 PM"), loadSecurity.Groups.SelectMany(group => group.Accounts).First().AccessTokens.First().Value.LastTouched);
            Assert.AreEqual("de-DE", loadSecurity.Groups.Last().Accounts.First().PreferredLanguageCode);
            Assert.AreEqual(CommonProtocolType.DiceBattlefield3, loadSecurity.Groups.SelectMany(group => group.Accounts).SelectMany(account => account.Players).First().ProtocolType);
            Assert.AreEqual("ABCDEF", loadSecurity.Groups.SelectMany(group => group.Accounts).SelectMany(account => account.Players).First().Uid);

//.........这里部分代码省略.........
开发者ID:EBassie,项目名称:Potato,代码行数:101,代码来源:TestSecurity.cs

示例14: LoadConfig

        /// <summary> Loads configuration settings from a file called botsettings.txt </summary>
        private void LoadConfig()
        {
            try {
                config = new Config( "botsettings.txt" );
                if( !config.Exists() ) {
                    using( StreamWriter sw = new StreamWriter( "botsettings.txt" ) ) {
                        sw.WriteLine("UseRemoteServer: false");
                        sw.WriteLine("RemotePort: ");
                        sw.WriteLine("RemotePassword: ");
                        sw.WriteLine("CommandsRequireOperator: true");
                        sw.WriteLine("ReconnectAfterKick: true");
                        sw.WriteLine("SaveMap: false");
                        sw.WriteLine("Operators:");
                        sw.WriteLine("#And now, a little explaination on what all these mean.");
                        sw.WriteLine("#UseRemoteServer - Allows remote clients to connect and perform actions on the bot / chat through it. By default, this is disabled." +
                                     "If you choose to use the remote function, you may need to forward the port and/or add an exception to your firewall.");
                        sw.WriteLine("#RemotePort - The port the server will listen on for remote clients. It is fine to leave this blank if UseRemoteServer is false.");
                        sw.WriteLine("#RemotePassword - The password to use for verifying remote clients. " +
                                     "If UseRemoteServer is true and this is blank, the password will be set to \"password\". ");
                        sw.WriteLine("#CommandsRequireOperators - This determines whether bot commands require the person who called them to be in the operators file." +
                                     "Usually you would want this to be true.");
                        sw.WriteLine("#ReconnectAfterKick - This determines if the bot will reconnect after being kicked. Note that if the bot receives a kick packet before" +
                                     "a ServerIdentification packet, it will abort, and assume it has been banned from connecting.");
                        sw.WriteLine("#SaveMap - This determines if the bot will save the map when the chunk packets are sent to it." +
                                     "If this is true, it will be saved as a fCraft compatible map. (Large maps of 512 x 512 x 512 " +
                                     "can use up to ~150 megabytes of RAM when saving, so be wary. After saving, memory usage should return to normal.");
                        sw.WriteLine( "#Operators: Comma separated list of operators, with no spaces. (e.g. test,test1,test2)" );
                        Events.RaiseConfigCreating( new ConfigCreatingEventArgs( config, sw ) );
                    }
                }

                config.Load();
                if( !config.TryParseValueOrDefault( "useremoteserver", false, out UseRemoteServer ) )
                    Log( LogType.Warning, "Couldn't load value for useremoteserver from config. Setting to default value of false" );
                if( UseRemoteServer ) {
                    int remotePort;
                    if( !config.TryParseValueOrDefault( "remoteport", 25561, out remotePort ) ) {
                        Log( LogType.Warning, "Couldn't load value for remoteport from config. Setting to default value of 25561" );
                    }
                    string remotePassword;
                    config.TryGetRawValue( "remotepassword", out remotePassword );
                    if( String.IsNullOrEmpty( remotePassword ) ) {
                        remotePassword = "password";
                        Log( LogType.Warning, "Couldn't load value for remotepassword from config. Setting to default value of \"password\"" );
                    }

                    server = new Server();
                    server.Start( this, remotePort, remotePassword );
                }

                if( !config.TryParseValueOrDefault( "commandsrequireoperator", true, out _requiresop ) )
                    Log( LogType.Warning, "Couldn't load value for commandsrequireoperator from config. Setting to default value of true" );
                if( !config.TryParseValueOrDefault( "reconnectafterkick", true, out _reconnectonkick ) )
                    Log( LogType.Warning, "Couldn't load value for reconnectafterkick from config. Setting to default value of true" );
                if( !config.TryParseValueOrDefault( "savemap", false, out _savemap ) )
                    Log( LogType.Warning, "Couldn't load value for savemap from config. Setting to default value of false" );
                string rawUsers; // Comma separated.
                config.TryGetRawValue( "operators", out rawUsers );
                if( String.IsNullOrEmpty( rawUsers ) ) {
                    Log( LogType.Warning, "Couldn't load value for operators from config. Setting to default value of empty." );
                } else {
                    string[] users = rawUsers.Split( ',' );
                    bool fixedNames = false;
                    for( int i = 0; i < users.Length; i++ ) {
                        if( users[i].IndexOf( ' ' ) != -1 ) {
                            fixedNames = true;
                            users[i] = users[i].Replace( " ", String.Empty );
                        }
                    }
                    if( fixedNames ) {
                        config.AddOrUpdateValue( "operators", String.Join( ",", users ) );
                        Log( LogType.BotActivity, "Fixed up spaces in the list of operators." );
                        config.Save();
                    }
                    Users.AddRange( users );
                }

                Events.RaiseConfigLoading( new ConfigLoadingEventArgs( config ) );
            } catch( Exception e ) {
                Log( LogType.Error, "Couldn't load config:", e.ToString() );
            }
        }
开发者ID:Grivaryg,项目名称:LibClassicBot,代码行数:83,代码来源:MainBot.cs

示例15: WriteConfig

        /// <summary>
        /// Preps the config, then passes it to the executable object's WriteConfig(Config)
        /// </summary>
        /// <remarks>You can see a similar implementation of this in Instance, which is treated
        /// as the base class (therefore it's not passing a config to a child class) but instead
        /// needs to make the initial config object before writing to it.</remarks>
        public virtual void WriteConfig() {
            if (this.ConfigDirectoryInfo != null) {
                Config config = new Config();
                config.Create(this.GetType());
                this.WriteConfig(config);

                config.Save(new FileInfo(Path.Combine(this.ConfigDirectoryInfo.FullName, this.GetType().Namespace + ".json")));
            }
        }
开发者ID:EBassie,项目名称:Potato,代码行数:15,代码来源:PluginController.cs


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