SetPath() private method

private SetPath ( string aPath ) : void
aPath string
return void
        public static Configuration Load()
        {
            XmlSerializer xml = new XmlSerializer(typeof(Configuration));

            string common = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            string folder = Path.Combine(common, "ohSongcast");

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }

            string path = Path.Combine(folder, "Configuration.xml");

            if (!File.Exists(path))
            {
                return(New(path));
            }

            try
            {
                using (TextReader reader = new StreamReader(path))
                {
                    Configuration configuration = (Configuration)xml.Deserialize(reader);
                    configuration.SetPath(path);
                    return(configuration);
                }
            }
            catch (Exception)
            {
                return(New(path));
            }
        }
        private static Configuration New(string aPath)
        {
            Configuration configuration = new Configuration();

            configuration.Subnet    = 0;
            configuration.Multicast = false;
            configuration.Channel   = (uint)(new Random().Next(65535) + 1);
            configuration.Ttl       = 1;
            configuration.Latency   = 100;
            configuration.Preset    = 0;
            configuration.SetPath(aPath);
            configuration.Save();
            return(configuration);
        }
Beispiel #3
0
 private static Configuration New(string aPath)
 {
     Configuration configuration = new Configuration();
     configuration.Subnet = 0;
     configuration.Multicast = false;
     configuration.Channel = (uint)(new Random().Next(65535) + 1);
     configuration.Ttl = 1;
     configuration.Latency = 100;
     configuration.Preset = 0;
     configuration.SetPath(aPath);
     configuration.Save();
     return (configuration);
 }