/// <summary> /// Utility method to get the settings /// </summary> /// <param name="lookUp">IDynamoLookUp instance</param> /// <param name="updateManager"></param> /// <returns></returns> public static UpdateManagerConfiguration GetSettings(IDynamoLookUp lookUp, IUpdateManager updateManager = null) { string filePath; var exists = TryGetConfigFilePath(out filePath); #if DEBUG //This code is just to create the default config file to //save the default settings, which later on can be modified //to re-direct it to other download target for testing. if (!exists) { var umConfig = new UpdateManagerConfiguration(); umConfig.Save(filePath, updateManager); } #endif if (!exists) { return new UpdateManagerConfiguration() { DynamoLookUp = lookUp } } ; var config = Load(filePath, updateManager); if (null != config) { config.DynamoLookUp = lookUp; } return(config); }
static UpdateManagerConfiguration NewConfiguration(bool checkNewerDailyBuild =false, bool forceUpdate =false, IDynamoLookUp lookup = null) { return new UpdateManagerConfiguration() { DownloadSourcePath = DOWNLOAD_SOURCE_PATH_S, SignatureSourcePath = SIGNATURE_SOURCE_PATH_S, CheckNewerDailyBuild = checkNewerDailyBuild, ForceUpdate = forceUpdate, DynamoLookUp = lookup, }; }
static UpdateManagerConfiguration NewConfiguration(bool checkNewerDailyBuild = false, bool forceUpdate = false, IDynamoLookUp lookup = null) { return(new UpdateManagerConfiguration() { DownloadSourcePath = DOWNLOAD_SOURCE_PATH_S, SignatureSourcePath = SIGNATURE_SOURCE_PATH_S, CheckNewerDailyBuild = checkNewerDailyBuild, ForceUpdate = forceUpdate, DynamoLookUp = lookup, }); }
/// <summary> /// Utility method to get the settings /// </summary> /// <param name="lookUp">IDynamoLookUp instance</param> /// <param name="updateManager"></param> /// <returns></returns> public static UpdateManagerConfiguration GetSettings(IDynamoLookUp lookUp, IUpdateManager updateManager = null) { string filePath; var exists = TryGetConfigFilePath(out filePath); #if DEBUG //This code is just to create the default config file to //save the default settings, which later on can be modified //to re-direct it to other download target for testing. if (!exists) { var umConfig = new UpdateManagerConfiguration(); umConfig.Save(filePath, updateManager); } #endif if (!exists) return new UpdateManagerConfiguration() { DynamoLookUp = lookUp }; var config = Load(filePath, updateManager); if (null != config) config.DynamoLookUp = lookUp; return config; }
/// <summary> /// Returns list of FileVersion objects, given the IPathManager and /// IDynamoLookUp objects. If a valid IDynamoLookUp interface object /// is passed, this method uses the lookup to get Dynamo user data locations. /// </summary> /// <param name="pathManager"></param> /// <param name="dynamoLookup"></param> /// <returns></returns> public static IEnumerable <FileVersion> GetInstalledVersions(IPathManager pathManager, IDynamoLookUp dynamoLookup) { return(dynamoLookup != null ? GetInstalledVersionsCore(() => dynamoLookup.GetDynamoUserDataLocations()) : GetInstalledVersions(Path.GetDirectoryName(pathManager.UserDataDirectory))); }
/// <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); }
/// <summary> /// Migrates preference settings and copies packages and custom node /// definitions from the last but one version to the currently installed Dynamo version /// </summary> /// <param name="pathManager"></param> /// <param name="dynamoLookup"></param> /// <returns>new migrator instance after migration</returns> public static DynamoMigratorBase MigrateBetweenDynamoVersions(IPathManager pathManager, IDynamoLookUp dynamoLookup = null) { //Get the current version from the current path manager user data directory. var currentVersion = GetInstallVersionFromUserDataFolder(pathManager.UserDataDirectory); var previousVersion = GetLatestVersionToMigrate(pathManager, dynamoLookup, currentVersion); if (!previousVersion.HasValue || previousVersion.Value.UserDataRoot == null) { return(null); //Don't have previous version for migration } return(Migrate(previousVersion.Value, currentVersion)); }