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


C# IConfig.Append方法代码示例

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


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

示例1: WriteConfig

        /// <summary>
        /// Saves all the connections to the config file.
        /// </summary>
        /// <param name="config"></param>
        /// <param name="password"></param>
        public override void WriteConfig(IConfig config, String password = null) {
            this.Shared.Variables.WriteConfig(config, password);

            this.Shared.Events.WriteConfig(config, password);

            this.Packages.WriteConfig(config, password);

            this.Database.WriteConfig(config, password);

            this.Shared.Languages.WriteConfig(config, password);

            this.Shared.Security.WriteConfig(config, password);

            this.CommandServer.WriteConfig(config, password);
            
            this.PushEvents.WriteConfig(config, password);

            lock (this.Connections) {
                foreach (ConnectionController connection in this.Connections) {
                    // This command is executed in the Potato object.
                    // I had to write this comment because I kept moving it to the actual connection and failing oh so hard.
                    config.Append(new Command() {
                        CommandType = CommandType.PotatoAddConnection,
                        Parameters = new List<ICommandParameter>() {
                            new CommandParameter() {
                                Data = {
                                    Content = new List<String>() {
                                        connection.ConnectionModel.ProtocolType.Provider
                                    }
                                }
                            },
                            new CommandParameter() {
                                Data = {
                                    Content = new List<String>() {
                                        connection.ConnectionModel.ProtocolType.Type
                                    }
                                }
                            },
                            new CommandParameter() {
                                Data = {
                                    Content = new List<String>() {
                                        connection.ConnectionModel.Hostname
                                    }
                                }
                            },
                            new CommandParameter() {
                                Data = {
                                    Content = new List<String>() {
                                        connection.ConnectionModel.Port.ToString(CultureInfo.InvariantCulture)
                                    }
                                }
                            },
                            new CommandParameter() {
                                Data = {
                                    Content = new List<String>() {
                                        connection.ConnectionModel.Password
                                    }
                                }
                            },
                            new CommandParameter() {
                                Data = {
                                    Content = new List<String>() {
                                        connection.ConnectionModel.Arguments
                                    }
                                }
                            }
                        }
                    }.ToConfigCommand().Encrypt(password));

                    connection.WriteConfig(config, password);
                }
            }
        }
开发者ID:EBassie,项目名称:Potato,代码行数:78,代码来源:PotatoController.cs

示例2: WriteConfig

        /// <summary>
        /// Relies on children classes to implement this.
        /// </summary>
        public override void WriteConfig(IConfig config, String password = null) {
            base.WriteConfig(config, password);

            foreach (GroupModel group in this.Groups) {
                config.Append(CommandBuilder.SecurityAddGroup(group.Name).ToConfigCommand());

                foreach (PermissionModel permission in group.Permissions) {
                    if (permission.Authority.HasValue == true) {
                        config.Append(CommandBuilder.SecurityGroupSetPermission(group.Name, permission.Name, permission.Authority.Value).ToConfigCommand());
                    }
                }

                foreach (AccountModel account in group.Accounts) {
                    config.Append(CommandBuilder.SecurityGroupAddAccount(group.Name, account.Username).ToConfigCommand());

                    config.Append(CommandBuilder.SecurityAccountSetPasswordHash(account.Username, account.PasswordHash).ToConfigCommand());

                    config.Append(CommandBuilder.SecurityAccountSetPreferredLanguageCode(account.Username, account.PreferredLanguageCode).ToConfigCommand());

                    foreach (AccountPlayerModel assignment in account.Players) {
                        config.Append(CommandBuilder.SecurityAccountAddPlayer(account.Username, assignment.ProtocolType, assignment.Uid).ToConfigCommand());
                    }

                    foreach (var token in account.AccessTokens.Select(token => token.Value)) {
                        config.Append(CommandBuilder.SecurityAccountAppendAccessToken(account.Username, token.Id, token.TokenHash, token.LastTouched).ToConfigCommand());
                    }
                }
            }
        }
开发者ID:EBassie,项目名称:Potato,代码行数:32,代码来源:SecurityController.cs

示例3: WriteConfig

        public override void WriteConfig(IConfig config, string password = null) {
            base.WriteConfig(config, password);

            // Writing configs may seem a little bit convoluted in Potato 2, but you should
            // think of it simply as Command serialization, which allows you to save complex
            // parameters.

            config.Append(new Command() {
                Name = "ThisIsJustACommand",
                Parameters = new List<ICommandParameter>() {
                    new CommandParameter() {
                        Data = {
                            Content = new List<String>() {
                                "Parameter1Value"
                            }
                        }
                    },
                    new CommandParameter() {
                        Data = {
                            Content = new List<String>() {
                                "Parameter2Value"
                            }
                        }
                    }
                }
            }.ToConfigCommand());
        }
开发者ID:EBassie,项目名称:Potato,代码行数:27,代码来源:Program.cs

示例4: WriteConfig

 public override void WriteConfig(IConfig config, string password = null) {
     foreach (PluginModel plugin in this.LoadedPlugins.Where(plugin => plugin.IsEnabled == true)) {
         config.Append(new Command() {
             CommandType = CommandType.PluginsEnable,
             Scope = {
                 ConnectionGuid = this.Connection.ConnectionModel.ConnectionGuid,
                 PluginGuid = plugin.PluginGuid
             }
         }.ToConfigCommand());
     }
 }
开发者ID:EBassie,项目名称:Potato,代码行数:11,代码来源:CorePluginController.cs


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