Example #1
0
        static PropertyService()
        {
            Counters.PropertyServiceInitialization.BeginTiming();

            string      migrateVersion    = null;
            UserProfile migratableProfile = null;

            var prefsPath = UserProfile.Current.ConfigDir.Combine(FileName);

            if (!File.Exists(prefsPath))
            {
                if (GetMigratableProfile(out migratableProfile, out migrateVersion))
                {
                    FilePath migratePrefsPath = migratableProfile.ConfigDir.Combine(FileName);
                    try
                    {
                        var parentDir = prefsPath.ParentDirectory;
                        //can't use file service until property service is initialized
                        if (!Directory.Exists(parentDir))
                        {
                            Directory.CreateDirectory(parentDir);
                        }
                        File.Copy(migratePrefsPath, prefsPath);
                        LoggingService.LogInfo("Migrated core properties from {0}", migratePrefsPath);
                    }
                    catch (IOException ex)
                    {
                        string message = string.Format("Failed to migrate core properties from {0}", migratePrefsPath);
                        LoggingService.LogError(message, ex);
                    }
                }
                else
                {
                    LoggingService.LogInfo("Did not find previous version from which to migrate data");
                }
            }

            if (!LoadProperties(prefsPath))
            {
                properties = new Properties();
                properties.Set("MonoDevelop.Core.FirstRun", true);
            }

            if (migratableProfile != null)
            {
                UserDataMigrationService.SetMigrationSource(migratableProfile, migrateVersion);
            }

            properties.PropertyChanged += delegate(object sender, PropertyChangedEventArgs args)
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(sender, args);
                }
            };

            Counters.PropertyServiceInitialization.EndTiming();
        }
Example #2
0
        static PropertyService()
        {
            Counters.PropertyServiceInitialization.BeginTiming();

            IsWindows = Path.DirectorySeparatorChar == '\\';
            IsMac     = !IsWindows && IsRunningOnMac();

            FilePath testProfileRoot = Environment.GetEnvironmentVariable("MONODEVELOP_PROFILE");

            if (!testProfileRoot.IsNullOrEmpty)
            {
                Locations = UserDataLocations.ForTest(CURRENT_PROFILE_VERSION, testProfileRoot);
            }
            else
            {
                Locations = GetLocations(CURRENT_PROFILE_VERSION);
            }

            string            migrateVersion    = null;
            UserDataLocations migratableProfile = null;

            var prefsPath = Locations.Config.Combine(FileName);

            if (!File.Exists(prefsPath))
            {
                if (GetMigratableProfile(testProfileRoot, out migratableProfile, out migrateVersion))
                {
                    FilePath migratePrefsPath = migratableProfile.Config.Combine(FileName);
                    try {
                        var parentDir = prefsPath.ParentDirectory;
                        //can't use file service until property sevice in initialized
                        if (!Directory.Exists(parentDir))
                        {
                            Directory.CreateDirectory(parentDir);
                        }
                        File.Copy(migratePrefsPath, prefsPath);
                        LoggingService.LogInfo("Migrated core properties from {0}", migratePrefsPath);
                    } catch (IOException ex) {
                        string message = string.Format("Failed to migrate core properties from {0}", migratePrefsPath);
                        LoggingService.LogError(message, ex);
                    }
                }
                else
                {
                    LoggingService.LogInfo("Did not find previous version from which to migrate data");
                }
            }

            if (!LoadProperties(prefsPath))
            {
                properties = new Properties();
                properties.Set("MonoDevelop.Core.FirstRun", true);
            }

            if (migratableProfile != null)
            {
                UserDataMigrationService.SetMigrationSource(migratableProfile, migrateVersion);
            }

            properties.PropertyChanged += delegate(object sender, PropertyChangedEventArgs args) {
                if (PropertyChanged != null)
                {
                    PropertyChanged(sender, args);
                }
            };

            Counters.PropertyServiceInitialization.EndTiming();
        }