Esempio n. 1
0
        /// <summary>
        /// Returns the most recent version to migrate to the given current version.
        /// </summary>
        /// <param name="pathManager"></param>
        /// <param name="dynamoLookup"></param>
        /// <param name="currentVersion"></param>
        /// <returns>FileVersion?</returns>
        public static FileVersion?GetLatestVersionToMigrate(IPathManager pathManager, IDynamoLookUp dynamoLookup, FileVersion currentVersion)
        {
            var versions = GetInstalledVersions(pathManager, dynamoLookup);

            if (versions.Count() < 2)
            {
                return(null); // No need for migration
            }
            foreach (var version in versions)
            {
                if (version < currentVersion)
                {
                    return(version);
                }

                if (version <= currentVersion &&
                    version.UserDataRoot != currentVersion.UserDataRoot)
                {
                    return(version);
                }
            }
            return(null);
        }
Esempio n. 2
0
 public DynamoMigrator08(IPathResolver pathResolver, FileVersion version)
     : base(pathResolver, version)
 {
 }
Esempio n. 3
0
        /// <summary>
        /// Given a root user directory, this creates an instance of the migrator
        /// depending on the input version using reflection. Returns the default
        /// migrator (DynamoMigratorBase) if version specific migrator does not exist
        /// </summary>
        /// <param name="pathResolver"></param>
        /// <param name="version"> input version for which migrator instance is created </param>
        /// <returns> instance of migrator specific to input version. </returns>
        internal static DynamoMigratorBase CreateMigrator(IPathResolver pathResolver, FileVersion version)
        {
            var className = "Dynamo.Core.DynamoMigrator" + version.MajorPart + version.MinorPart;

            var args = new object[] { pathResolver, version };
            var type = Assembly.GetExecutingAssembly().GetType(className);

            if (type != null)
            {
                return((DynamoMigratorBase)Activator.CreateInstance(type, args));
            }

            return(new DynamoMigratorBase(pathResolver, version));
        }
Esempio n. 4
0
        /// <summary>
        /// Given a root user data directory, this migrates user preferences,
        /// packages and custom node definition files from one installed version
        /// into another
        /// </summary>
        /// <param name="pathResolver"></param>
        /// <param name="fromVersion"> source Dynamo version from which to migrate </param>
        /// <param name="toVersion"> target Dynamo version into which to migrate </param>
        /// <returns> new migrator instance after migration, null if there's no migration </returns>
        internal static DynamoMigratorBase Migrate(IPathResolver pathResolver, FileVersion fromVersion, FileVersion toVersion)
        {
            // Create concrete DynamoMigratorBase object using previousVersion and reflection
            var sourceMigrator = CreateMigrator(pathResolver, fromVersion);

            Debug.Assert(sourceMigrator != null);

            // get migrator object for current version
            var targetMigrator = CreateMigrator(pathResolver, toVersion);

            Debug.Assert(targetMigrator != null);

            bool isPackagesDirectoryEmpty    = !Directory.EnumerateFileSystemEntries(targetMigrator.PackagesDirectory).Any();
            bool isDefinitionsDirectoryEmpty = !Directory.EnumerateFileSystemEntries(targetMigrator.DefinitionsDirectory).Any();

            // Migrate only if both packages and definitions directories are empty
            if (isPackagesDirectoryEmpty && isDefinitionsDirectoryEmpty)
            {
                DynamoModel.OnRequestMigrationStatusDialog(new SettingsMigrationEventArgs(
                                                               SettingsMigrationEventArgs.EventStatusType.Begin));

                return(targetMigrator.MigrateFrom(sourceMigrator));
            }
            return(null);
        }
Esempio n. 5
0
 public DynamoMigrator08(FileVersion version)
     : base(version)
 {
 }
Esempio n. 6
0
        /// <summary>
        /// Given a root user data directory, this migrates user preferences,
        /// packages and custom node definition files from one installed version
        /// into another
        /// </summary>
        /// <param name="pathResolver"></param>
        /// <param name="fromVersion"> source Dynamo version from which to migrate </param>
        /// <param name="toVersion"> target Dynamo version into which to migrate </param>
        /// <returns> new migrator instance after migration </returns>
        internal static DynamoMigratorBase Migrate(IPathResolver pathResolver, FileVersion fromVersion, FileVersion toVersion)
        {
            // Create concrete DynamoMigratorBase object using previousVersion and reflection
            var sourceMigrator = CreateMigrator(pathResolver, fromVersion);

            Debug.Assert(sourceMigrator != null);

            // get migrator object for current version
            var targetMigrator = CreateMigrator(pathResolver, toVersion);

            Debug.Assert(targetMigrator != null);

            return(targetMigrator.MigrateFrom(sourceMigrator));
        }