Exemple #1
0
        internal void MigrateFrom83Alpha(DictionaryConfigurationModel alphaModel)
        {
            // original migration neglected to update the version number; -1 (Pre83) is the same as 1 (Alpha1)
            if (alphaModel.Version == PreHistoricMigrator.VersionPre83 || alphaModel.Version == PreHistoricMigrator.VersionAlpha1)
            {
                RemoveNonLoadableData(alphaModel.PartsAndSharedItems);
            }
            // now that it's safe to specify them, it would be helpful to have parents in certain steps:
            DictionaryConfigurationModel.SpecifyParentsAndReferences(alphaModel.Parts, alphaModel.SharedItems);
            switch (alphaModel.Version)
            {
            case -1:
            case 1:
            case 2:
                HandleNodewiseChanges(alphaModel.PartsAndSharedItems, m_logger, 2, alphaModel.IsReversal);
                goto case 3;

            case 3:
                HandleNodewiseChanges(alphaModel.PartsAndSharedItems, m_logger, 3, alphaModel.IsReversal);
                DCM.SetWritingSystemForReversalModel(alphaModel, Cache);
                AddSharedNodesToAlphaConfigurations(alphaModel);
                goto case 4;

            case 4:
                HandleNodewiseChanges(alphaModel.PartsAndSharedItems, m_logger, 4, alphaModel.IsReversal);
                goto case VersionAlpha2;

            case VersionAlpha2:
                HandleNodewiseChanges(alphaModel.PartsAndSharedItems, m_logger, VersionAlpha2, alphaModel.IsReversal);
                goto case 6;

            case 6:
                HandleNodewiseChanges(alphaModel.PartsAndSharedItems, m_logger, 6, alphaModel.IsReversal);
                goto case 7;

            case 7:
                var fileName = Path.GetFileNameWithoutExtension(alphaModel.FilePath);
                if (!alphaModel.IsRootBased)
                {
                    alphaModel.IsRootBased = fileName == DCM.RootFileName;
                }
                break;

            default:
                m_logger.WriteLine(string.Format(
                                       "Unable to migrate {0}: no migration instructions for version {1}", alphaModel.Label, alphaModel.Version));
                break;
            }
            alphaModel.Version = VersionAlpha3;
        }
        internal void MigrateFrom83Alpha(ISimpleLogger logger, DictionaryConfigurationModel oldConfig, DictionaryConfigurationModel currentDefaultModel)
        {
            // it may be helpful to have parents and current custom fields in the oldConfig (currentDefaultModel already has them):
            DictionaryConfigurationModel.SpecifyParentsAndReferences(oldConfig.Parts, oldConfig.SharedItems);
            DictionaryConfigurationController.MergeCustomFieldsIntoDictionaryModel(oldConfig, Cache);
            ChooseAppropriateComplexForms(oldConfig);             // 13->14, but needed before rearranging and adding new nodes
            ConflateMainEntriesIfNecessary(logger, oldConfig);    // 12->13, but needed before rearranging and adding new nodes
            var currentDefaultList = new List <ConfigurableDictionaryNode>(currentDefaultModel.PartsAndSharedItems);

            foreach (var part in oldConfig.PartsAndSharedItems)
            {
                MigratePartFromOldVersionToCurrent(logger, oldConfig, part, FindMatchingChildNode(part.Label, currentDefaultList));
            }
            oldConfig.Version = DCM.VersionCurrent;
            logger.WriteLine("Migrated to version " + DCM.VersionCurrent);
        }
        internal void MigrateFrom83Alpha(ISimpleLogger logger, DictionaryConfigurationModel oldConfig, DictionaryConfigurationModel currentDefaultModel)
        {
            // it may be helpful to have parents and current custom fields in the oldConfig (currentDefaultModel already has them):
            DictionaryConfigurationModel.SpecifyParentsAndReferences(oldConfig.Parts, oldConfig.SharedItems);
            DictionaryConfigurationController.MergeCustomFieldsIntoDictionaryModel(oldConfig, Cache);
            ChooseAppropriateComplexForms(oldConfig);             // 13->14, but needed before rearranging and adding new nodes
            ConflateMainEntriesIfNecessary(logger, oldConfig);    // 12->13, but needed before rearranging and adding new nodes
            var currentDefaultList = new List <ConfigurableDictionaryNode>(currentDefaultModel.PartsAndSharedItems);

            foreach (var part in oldConfig.PartsAndSharedItems)
            {
                var defaultPart = FindMatchingChildNode(part.Label, currentDefaultList);
                if (defaultPart == null)
                {
                    throw new NullReferenceException(string.Format(
                                                         "{0} is corrupt. {1} has no corresponding part in the defaults (perhaps it missed a rename migration step).",
                                                         oldConfig.FilePath, part.Label));
                }
                MigratePartFromOldVersionToCurrent(logger, oldConfig, part, defaultPart);
            }
            oldConfig.Version = DCM.VersionCurrent;
            logger.WriteLine("Migrated to version " + DCM.VersionCurrent);
        }