Exemple #1
0
        /// <summary>
        /// Applies the settings.
        /// </summary>
        /// <param name="settings">The settings.</param>
        public void ApplySettings(InstanceSettings settings)
        {
            this.Enabled = settings.Enabled;

            this.Away.ApplySetting(settings.Away);
            this.BadNickname.ApplySetting(settings.BadNickname);
            this.Control.ApplySetting(settings.Control);
            this.Event.ApplySetting(settings.Event);
            this.Idle.ApplySetting(settings.Idle);
            this.Message.ApplySetting(settings.Message);
            this.Record.ApplySetting(settings.Record);
            this.Sticky.ApplySetting(settings.Sticky);
            this.Vote.ApplySetting(settings.Vote);

            if (!string.IsNullOrEmpty(settings.Global.BotNickname))
            {
                this.Global.BotNickname = settings.Global.BotNickname;
            }
            if (BasicHelper.IsValidCulture(settings.Global.Globalization))
            {
                this.Global.Globalization = settings.Global.Globalization;
            }

            this.TeamSpeak.Host         = settings.TeamSpeak.Host;
            this.TeamSpeak.Instance     = settings.TeamSpeak.Instance;
            this.TeamSpeak.InstancePort = settings.TeamSpeak.InstancePort;
            this.TeamSpeak.QueryPort    = settings.TeamSpeak.QueryPort;
            this.TeamSpeak.Username     = settings.TeamSpeak.Username;
            this.TeamSpeak.Password     = settings.TeamSpeak.Password;
        }
 /// <summary>
 /// Writes the settings.
 /// </summary>
 /// <param name="settings">The settings.</param>
 /// <param name="stream">The stream.</param>
 public static void WriteSettings(InstanceSettings settings, Stream stream)
 {
     lock (Serializer)
     {
         var result = new StreamWriter(stream);
         Serializer.Serialize(result, settings);
     }
 }
Exemple #3
0
 /// <summary>
 /// Writes the settings.
 /// </summary>
 /// <param name="settings">The settings.</param>
 /// <param name="stream">The stream.</param>
 public static void WriteSettings(InstanceSettings settings, Stream stream)
 {
     lock (Serializer)
     {
         var result = new StreamWriter(stream);
         Serializer.Serialize(result, settings);
     }
 }
 /// <summary>
 /// Writes the settings.
 /// </summary>
 /// <param name="settings">The settings.</param>
 /// <returns></returns>
 public static Stream WriteSettings(InstanceSettings settings)
 {
     lock (Serializer)
     {
         var result = new MemoryStream();
         Serializer.Serialize(result, settings);
         result.Seek(0, SeekOrigin.Begin);
         return(result);
     }
 }
Exemple #5
0
 /// <summary>
 /// Writes the settings.
 /// </summary>
 /// <param name="settings">The settings.</param>
 /// <returns></returns>
 public static Stream WriteSettings(InstanceSettings settings)
 {
     lock (Serializer)
     {
         var result = new MemoryStream();
         Serializer.Serialize(result, settings);
         result.Seek(0, SeekOrigin.Begin);
         return result;
     }
 }
        /// <summary>
        /// Loads the settings.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <returns>The instance settings</returns>
        public static InstanceSettings LoadSettings(string path)
        {
            InstanceSettings result = SettingsSerializer.ReadSettings(BasicHelper.DefaultConfiguration);

            using (var streamReader = new StreamReader(path, true))
            {
                result.ApplySettings(SettingsSerializer.ReadSettings(streamReader.BaseStream));
            }

            result.Id       = Path.GetFileName(path);
            result.FilePath = path;
            return(result);
        }
        /// <summary>
        /// Applies the settings.
        /// </summary>
        /// <param name="settings">The settings.</param>
        public void ApplySettings(InstanceSettings settings)
        {
            this.Enabled = settings.Enabled;

            this.Away.ApplySetting(settings.Away);
            this.BadNickname.ApplySetting(settings.BadNickname);
            this.Control.ApplySetting(settings.Control);
            this.Event.ApplySetting(settings.Event);
            this.Idle.ApplySetting(settings.Idle);
            this.Message.ApplySetting(settings.Message);
            this.Record.ApplySetting(settings.Record);
            this.Sticky.ApplySetting(settings.Sticky);
            this.Vote.ApplySetting(settings.Vote);

            if (!string.IsNullOrEmpty(settings.Global.BotNickname))
                this.Global.BotNickname = settings.Global.BotNickname;
            if (BasicHelper.IsValidCulture(settings.Global.Globalization))
                this.Global.Globalization = settings.Global.Globalization;

            this.TeamSpeak.Host = settings.TeamSpeak.Host;
            this.TeamSpeak.Instance = settings.TeamSpeak.Instance;
            this.TeamSpeak.InstancePort = settings.TeamSpeak.InstancePort;
            this.TeamSpeak.QueryPort = settings.TeamSpeak.QueryPort;
            this.TeamSpeak.Username = settings.TeamSpeak.Username;
            this.TeamSpeak.Password = settings.TeamSpeak.Password;
        }