Ejemplo n.º 1
0
        internal static Config LoadConfig()
        {
            string userAppDaraPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            string appName = AppDomain.CurrentDomain.FriendlyName;
            while (appName.Contains("."))
            {
                appName = Path.GetFileNameWithoutExtension(appName);
            }
            appName += "." + s_configExtension;
            string path = Path.Combine(userAppDaraPath, appName);

            // search in local folder
            if (!File.Exists(path))
                return new Config();

            using (var fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read))
            {
                try
                {
                    var configObj = new XmlSerializer(typeof(Config)).Deserialize(fs);
                    var config = configObj as Config;
                    if (config != null)
                        m_lastConfig = config.Copy();
                    return config;
                }
                catch (Exception)
                {
                    return new Config();
                }
            }
        }
Ejemplo n.º 2
0
 public bool Equals(Config other)
 {
     if (other == null)
         return false;
     return TfsUrl == other.TfsUrl
         && AreaPath == other.AreaPath
         && Iteration == other.Iteration
         && AllAreaPaths.Count == other.AllAreaPaths.Count
         && AllAreaPaths.All(a => other.AllAreaPaths.Any(o => a == o))
         && other.AllAreaPaths.All(o => AllAreaPaths.Any(a => a == o));
 }
Ejemplo n.º 3
0
        internal static void SaveConfig(Config config)
        {
            if (config.Equals(m_lastConfig))
                return;

            string userAppDaraPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            string appName = AppDomain.CurrentDomain.FriendlyName;
            while (appName.Contains("."))
            {
                appName = Path.GetFileNameWithoutExtension(appName);
            }
            appName += "." + s_configExtension;
            string path = Path.Combine(userAppDaraPath, appName);

            using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Write))
            {
                var serializer = new XmlSerializer(typeof(Config));
                serializer.Serialize(fs, config);
            }
        }