/// <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); } } }
/// <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()); } } } }
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()); }
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()); } }