本文整理汇总了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);
}
}
}
示例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());
}
}
}
}
示例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());
}
示例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());
}
}