internal static void ApplyConfigFile(ConfigPriority priority = ConfigPriority.RuntimeChanges) { SerializedConfig config = FileConfig; if (clientID != config.clientID || clientSecret != config.clientSecret || token != config.token) { LogHelper.Logln($"One of the core values (ID, Secret, or Token) have been changed in the file ({Path.GetFullPath(configFileName)}). The program might need a restart to apply those new values.", LogType.Warning); } if (SerializableField <string> .needsToReserialize) { LogHelper.Logln("There are runtime changes to configuration.", LogType.Warning); if (priority == ConfigPriority.RuntimeChanges) { LogHelper.Logln("Abort applying runtime configs from file configs.", LogType.Success); return; } else if (priority == ConfigPriority.FileChanges) { LogHelper.Logln("Discarding runtime changes to configs.", LogType.Warning); SerializableField <string> .Reset(); } } botName = new SerializableField <string>(config.botName); serverName = new SerializableField <string>(config.serverName); textChannel = new SerializableField <string>(config.textChannelName); voiceChannel = new SerializableField <string>(config.voiceChannelName); }
private static void Serialize(SerializedConfig config, string filePath, IFormatter formatter) { using (FileStream s = new FileStream(filePath, FileMode.Create)) { formatter.Serialize(s, config); s.Close(); } }
public SerializedConfig(SerializedConfig other) { this.clientID = other.clientID; this.clientSecret = other.clientSecret; this.token = other.token; this.serverName = other.serverName; this.textChannelName = other.textChannelName; this.voiceChannelName = other.voiceChannelName; this.offlineDiskSpace = other.offlineDiskSpace; }
public bool Equals(SerializedConfig compare) { if (compare == null) { return(false); } return (clientID == compare.clientID && clientSecret == compare.clientSecret && botName == compare.botName && token == compare.token && serverName == compare.serverName && textChannelName == compare.textChannelName && voiceChannelName == compare.voiceChannelName && offlineDiskSpace == compare.offlineDiskSpace); }
static ClientConfig() { #if DEBUG LogHelper.Logln("ClientConfig is being initialized.", LogType.Debug); #endif SerializedConfig config = FileConfig; clientID = config.clientID; #if MENTION_INVOKE_COMMAND ulong.TryParse(clientID, out clientIDNum); #endif clientSecret = config.clientSecret; token = config.token; _offlineDiskSpace = new SerializableField <ulong>(config.offlineDiskSpace); botName = new SerializableField <string>(config.botName); serverName = new SerializableField <string>(config.serverName); textChannel = new SerializableField <string>(config.textChannelName); voiceChannel = new SerializableField <string>(config.voiceChannelName); #if DEBUG #endif LogHelper.Logln("ClientConfig initialized.", LogType.Success); }