///<summary>
		/// Constructor.
		///</summary>
		///<param name="idsInFile"></param>
		///<param name="replaceIdsInFile"></param>
		///<param name="writingSystemRepository"></param>
		public static void FindOrphans(
			IEnumerable<string> idsInFile,
			IdReplacementStrategy replaceIdsInFile,
			IWritingSystemRepository writingSystemRepository
		) {
			var originalIds = new List<string>(idsInFile);
			var updatedIds = new List<string>(idsInFile);
			foreach (var wsId in originalIds)
			{
				// Check if it's in the repo
				if (writingSystemRepository.Contains(wsId))
				{
					continue;
				}
				string newId = wsId;
				if (writingSystemRepository.WritingSystemIdHasChanged(wsId))
				{
					newId = writingSystemRepository.WritingSystemIdHasChangedTo(wsId);
				}
				else
				{
					// It's an orphan
					// Check for the writing system repository compatibility mode
					if (writingSystemRepository.CompatibilityMode == WritingSystemCompatibility.Flex7V0Compatible)
					{
						if (!wsId.StartsWith("x-"))
						{
							// Clean it
							var rfcTagCleaner = new Rfc5646TagCleaner(wsId);
							rfcTagCleaner.Clean();
							newId = rfcTagCleaner.GetCompleteTag();
						}
					}
					else
					{
						// Clean it
						var rfcTagCleaner = new Rfc5646TagCleaner(wsId);
						rfcTagCleaner.Clean();
						newId = rfcTagCleaner.GetCompleteTag();
					}
				}
				var conformantWritingSystem = WritingSystemDefinition.Parse(newId);
				// If it changed, then change
				if (conformantWritingSystem.Bcp47Tag != wsId)
				{
					conformantWritingSystem = WritingSystemDefinition.CreateCopyWithUniqueId(conformantWritingSystem, updatedIds);
					replaceIdsInFile(wsId, conformantWritingSystem.Bcp47Tag);
					updatedIds.Remove(wsId);
					updatedIds.Add(conformantWritingSystem.Bcp47Tag);
				}
				// Check if it's in the repo
				if (writingSystemRepository.Contains(conformantWritingSystem.Bcp47Tag))
				{
					continue;
				}
				// It's not in the repo so set it
				writingSystemRepository.Set(conformantWritingSystem);
			}
			writingSystemRepository.Save();
		}
Beispiel #2
0
        ///<summary>
        /// Constructor.
        ///</summary>
        ///<param name="idsInFile"></param>
        ///<param name="replaceIdsInFile"></param>
        ///<param name="writingSystemRepository"></param>
        public static void FindOrphans(
            IEnumerable <string> idsInFile,
            IdReplacementStrategy replaceIdsInFile,
            IWritingSystemRepository writingSystemRepository)
        {
            List <string> originalIds = idsInFile.ToList();
            List <string> updatedIds  = originalIds.ToList();

            foreach (string wsId in originalIds)
            {
                // Check if it's in the repo
                if (writingSystemRepository.Contains(wsId))
                {
                    continue;
                }
                string newId;
                if (writingSystemRepository.WritingSystemIdHasChanged(wsId))
                {
                    newId = writingSystemRepository.WritingSystemIdHasChangedTo(wsId);
                }
                else
                {
                    // It's an orphan
                    // Clean it
                    var rfcTagCleaner = new IetfLanguageTagCleaner(wsId);
                    rfcTagCleaner.Clean();
                    newId = rfcTagCleaner.GetCompleteTag();
                }

                WritingSystemDefinition conformantWritingSystem;
                writingSystemRepository.WritingSystemFactory.Create(newId, out conformantWritingSystem);
                // If it changed, then change
                if (conformantWritingSystem.LanguageTag != wsId)
                {
                    conformantWritingSystem.LanguageTag = IetfLanguageTag.ToUniqueLanguageTag(
                        conformantWritingSystem.LanguageTag, updatedIds);
                    replaceIdsInFile(wsId, conformantWritingSystem.LanguageTag);
                    updatedIds.Remove(wsId);
                    updatedIds.Add(conformantWritingSystem.LanguageTag);
                }

                // Check if it's in the repo
                if (writingSystemRepository.Contains(conformantWritingSystem.LanguageTag))
                {
                    continue;
                }

                // It's not in the repo so set it
                writingSystemRepository.Set(conformantWritingSystem);
            }
            writingSystemRepository.Save();
        }
        ///<summary>
        /// Constructor.
        ///</summary>
        ///<param name="idsInFile"></param>
        ///<param name="replaceIdsInFile"></param>
        ///<param name="writingSystemRepository"></param>
        public static void FindOrphans(
			IEnumerable<string> idsInFile,
			IdReplacementStrategy replaceIdsInFile,
			IWritingSystemRepository writingSystemRepository)
        {
            List<string> originalIds = idsInFile.ToList();
            List<string> updatedIds = originalIds.ToList();
            foreach (string wsId in originalIds)
            {
                // Check if it's in the repo
                if (writingSystemRepository.Contains(wsId))
                {
                    continue;
                }
                string newId;
                if (writingSystemRepository.WritingSystemIdHasChanged(wsId))
                {
                    newId = writingSystemRepository.WritingSystemIdHasChangedTo(wsId);
                }
                else
                {
                    // It's an orphan
                    // Clean it
                    var rfcTagCleaner = new IetfLanguageTagCleaner(wsId);
                    rfcTagCleaner.Clean();
                    newId = rfcTagCleaner.GetCompleteTag();
                }

                WritingSystemDefinition conformantWritingSystem;
                writingSystemRepository.WritingSystemFactory.Create(newId, out conformantWritingSystem);
                // If it changed, then change
                if (conformantWritingSystem.LanguageTag != wsId)
                {
                    conformantWritingSystem.LanguageTag = IetfLanguageTag.ToUniqueLanguageTag(
                        conformantWritingSystem.LanguageTag, updatedIds);
                    replaceIdsInFile(wsId, conformantWritingSystem.LanguageTag);
                    updatedIds.Remove(wsId);
                    updatedIds.Add(conformantWritingSystem.LanguageTag);
                }

                // Check if it's in the repo
                if (writingSystemRepository.Contains(conformantWritingSystem.LanguageTag))
                    continue;

                // It's not in the repo so set it
                writingSystemRepository.Set(conformantWritingSystem);
            }
            writingSystemRepository.Save();
        }
Beispiel #4
0
        ///<summary>
        /// Constructor.
        ///</summary>
        ///<param name="idsInFile"></param>
        ///<param name="replaceIdsInFile"></param>
        ///<param name="writingSystemRepository"></param>
        public static void FindOrphans(
            IEnumerable <string> idsInFile,
            IdReplacementStrategy replaceIdsInFile,
            IWritingSystemRepository writingSystemRepository
            )
        {
            var originalIds = new List <string>(idsInFile);
            var updatedIds  = new List <string>(idsInFile);

            foreach (var wsId in originalIds)
            {
                // Check if it's in the repo
                if (writingSystemRepository.Contains(wsId))
                {
                    continue;
                }
                string newId = wsId;
                if (writingSystemRepository.WritingSystemIdHasChanged(wsId))
                {
                    newId = writingSystemRepository.WritingSystemIdHasChangedTo(wsId);
                }
                else
                {
                    // It's an orphan
                    // Check for the writing system repository compatibility mode
                    if (writingSystemRepository.CompatibilityMode == WritingSystemCompatibility.Flex7V0Compatible)
                    {
                        if (!wsId.StartsWith("x-"))
                        {
                            // Clean it
                            var rfcTagCleaner = new Rfc5646TagCleaner(wsId);
                            rfcTagCleaner.Clean();
                            newId = rfcTagCleaner.GetCompleteTag();
                        }
                    }
                    else
                    {
                        // Clean it
                        var rfcTagCleaner = new Rfc5646TagCleaner(wsId);
                        rfcTagCleaner.Clean();
                        newId = rfcTagCleaner.GetCompleteTag();
                    }
                }
                var conformantWritingSystem = WritingSystemDefinition.Parse(newId);
                // If it changed, then change
                if (conformantWritingSystem.Bcp47Tag != wsId)
                {
                    conformantWritingSystem = WritingSystemDefinition.CreateCopyWithUniqueId(conformantWritingSystem, updatedIds);
                    replaceIdsInFile(wsId, conformantWritingSystem.Bcp47Tag);
                    updatedIds.Remove(wsId);
                    updatedIds.Add(conformantWritingSystem.Bcp47Tag);
                }
                // Check if it's in the repo
                if (writingSystemRepository.Contains(conformantWritingSystem.Bcp47Tag))
                {
                    continue;
                }
                // It's not in the repo so set it
                writingSystemRepository.Set(conformantWritingSystem);
            }
            writingSystemRepository.Save();
        }