Beispiel #1
0
 public void InitializeDefaults()
 {
     if (Directory.Exists(BasePath))
     {
         if (File.Exists(SettingsFilePath))
         {
             return;
         }
     }
     this.RootElement = new SettingsElement()
     {
         Servers = new List<ServerElement>()
         {
             new ServerElement()
             {
                 Name = "Cobalt",
                 Hostname = "irc.cobaltapp.net",
                 Port = 6667,
                 Channels = new List<string>() {"#flux"}
             }
         },
         DefaultProfile = new UserProfileElement()
         {
             Nickname1 = $"{Environment.UserName}",
             Nickname2 = $"{Environment.UserName}_",
             Nickname3 = $"{Environment.UserName}__",
             Username = Environment.UserName,
             FullName = Environment.UserName
         },
         FontFamily = "Segoe UI",
         FontSize = 14,
         ScrollbackLines = 300
     };
     Save();
 }
Beispiel #2
0
        private SettingsElement createTestElement()
        {
            SettingsElement root = new SettingsElement
            {
                ScrollbackLines = 300,
                FontFamily = "Segoe UI",
                FontSize = 14,
                DefaultProfile = new UserProfileElement()
                {
                    Nickname1 = "Nick1",
                    FullName = "FullName",
                    Username = "******"
                }
            };
            root.Networks.Add(new NetworkElement()
            {
                Name = "Memers",
                Port = 6667,
                UserProfile = new UserProfileElement()
                {
                    Nickname1 = "Override",
                    FullName = "Override",
                    Username = "******"
                }
            });

            return root;
        }
 public string Serialize(SettingsElement rootElement)
 {
     XmlSerializer x = new XmlSerializer(typeof(SettingsElement));
     using (StringWriter sw = new StringWriter())
     {
         x.Serialize(sw, rootElement);
         return sw.ToString();
     }
 }
Beispiel #4
0
 public void Load()
 {
     string data = File.ReadAllText(SettingsFilePath);
     RootElement = _serializer.Deserialize(data);
 }
Beispiel #5
0
 public void Load()
 {
     try
     {
         string data = File.ReadAllText(SettingsFilePath);
         RootElement = _serializer.Deserialize(data);
     }
     catch (Exception ex) when (ex is FileNotFoundException || ex is DirectoryNotFoundException)
     {
         InitializeDefaults();
         Save();
     }
 }
Beispiel #6
0
 public void InitializeDefaults(bool overwrite = false)
 {
     if (Directory.Exists(BasePath))
     {
         if (overwrite == false && File.Exists(SettingsFilePath))
         {
             return;
         }
     }
     this.RootElement = new SettingsElement()
     {
         Networks = 
         {
             new NetworkElement()
             {
                 Name = "Cobalt",
                 Hostname = "irc.cobaltapp.net",
                 Port = 6667,
                 Channels = {new ChannelElement()
                 {
                     Name = "#flux"                            
                 }}
             }
         },
         DefaultProfile = new UserProfileElement()
         {
             Nickname1 = $"{Environment.UserName}",
             Nickname2 = $"{Environment.UserName}_",
             Username = Environment.UserName,
             FullName = Environment.UserName,
             NickservPassword = "******"
         },
         FontFamily = "Segoe UI",
         FontSize = 14,
         ScrollbackLines = 300
     };
     Save();
 }
 public async Task<string> SerializeAsync(SettingsElement rootElement)
 {
     return await Task.Run(() => Serialize(rootElement));
 }
 public string Serialize(SettingsElement rootElement)
 {            
     return JsonConvert.SerializeObject(rootElement);
 }
 public Task<string> SerializeAsync(SettingsElement rootElement)
 {
     throw new NotImplementedException();
 }