private void _removeGS(GameSource source) { lock (GSList) { GSList.Remove(source); removed.Add(source); } }
internal static IKeyedCollection <string, SldrLanguageTagInfo> ParseAllTags(string allTagsContent) { string[] allTags = allTagsContent.Replace("\r\n", "\n").Split(new[] { "\n" }, StringSplitOptions.RemoveEmptyEntries); var tags = new KeyedList <string, SldrLanguageTagInfo>(info => info.LanguageTag, StringComparer.InvariantCultureIgnoreCase); foreach (string line in allTags) { string tagsStr = line; // trim off the explicit inheritance relationship information, we don't care about inheritance int index = line.LastIndexOf('>'); if (index != -1) { tagsStr = line.Substring(0, index).Trim(); } // split the the line into groups of equivalent language tags // the bar character is used to show implicit inheritance relationships between tags, // we don't care about inheritance string[] equivalentTagsStrs = tagsStr.Split('|'); foreach (string equivalentTagsStr in equivalentTagsStrs) { // split each group of equivalent language tags into individual language tags string[] tagStrs = equivalentTagsStr.Split('='); for (int i = 0; i < tagStrs.Length; i++) { tagStrs[i] = tagStrs[i].Trim(); } // check if language tag is available in the SLDR bool isAvailable = tagStrs[0].StartsWith("*"); if (isAvailable) { tagStrs[0] = tagStrs[0].Substring(1); } string sldrLangTag = tagStrs[0]; // check if a tag with a script code is equivalent to a tag without a script code // this tells us that the script is implicit string langTag, implicitStringCode; if (equivalentTagsStrs.Length == 1 && tagStrs.Length == 1) { // special case where there is a single tag on a line // if it contains a script code, then the script is implicit string[] components = tagStrs[0].Split('-'); if (components.Length == 2 && components[1].Length == 4) { langTag = components[0]; implicitStringCode = components[1]; } else { langTag = tagStrs[0]; implicitStringCode = null; } } else { var minTag = tagStrs.Select(t => new { Tag = t, Components = t.Split('-') }).MinBy(t => t.Components.Length); langTag = minTag.Tag; implicitStringCode = null; // only look for an implicit script code if the minimal tag has no script code if (minTag.Components.Length < 2 || minTag.Components[1].Length != 4) { foreach (string tagStr in tagStrs) { string[] components = tagStr.Split('-'); if (components.Length == minTag.Components.Length + 1 && components[1].Length == 4) { implicitStringCode = components[1]; } } } } SldrLanguageTagInfo existingTag; if (tags.TryGet(langTag, out existingTag)) { // alltags.txt can contain multiple lines that contain the same language tag. // if one of the lines contains information on an implicit script for a language tag, // we don't want to lose that information, so we preserve it by not replacing the // SldrLanguageTagInfo object for this language tag. if (existingTag.ImplicitScriptCode != null) { continue; } tags.Remove(langTag); } tags.Add(new SldrLanguageTagInfo(langTag, implicitStringCode, sldrLangTag, isAvailable)); } } return(tags); }
internal static IKeyedCollection<string, SldrLanguageTagInfo> ParseAllTags(string allTagsContent) { string[] allTags = allTagsContent.Replace("\r\n", "\n").Split(new[] {"\n"}, StringSplitOptions.RemoveEmptyEntries); var tags = new KeyedList<string, SldrLanguageTagInfo>(info => info.LanguageTag, StringComparer.InvariantCultureIgnoreCase); foreach (string line in allTags) { string tagsStr = line; // trim off the explicit inheritance relationship information, we don't care about inheritance int index = line.LastIndexOf('>'); if (index != -1) tagsStr = line.Substring(0, index).Trim(); // split the the line into groups of equivalent language tags // the bar character is used to show implicit inheritance relationships between tags, // we don't care about inheritance string[] equivalentTagsStrs = tagsStr.Split('|'); foreach (string equivalentTagsStr in equivalentTagsStrs) { // split each group of equivalent language tags into individual language tags string[] tagStrs = equivalentTagsStr.Split('='); for (int i = 0; i < tagStrs.Length; i++) tagStrs[i] = tagStrs[i].Trim(); // check if language tag is available in the SLDR bool isAvailable = tagStrs[0].StartsWith("*"); if (isAvailable) tagStrs[0] = tagStrs[0].Substring(1); string sldrLangTag = tagStrs[0]; // check if a tag with a script code is equivalent to a tag without a script code // this tells us that the script is implicit string langTag, implicitStringCode; if (equivalentTagsStrs.Length == 1 && tagStrs.Length == 1) { // special case where there is a single tag on a line // if it contains a script code, then the script is implicit string[] components = tagStrs[0].Split('-'); if (components.Length == 2 && components[1].Length == 4) { langTag = components[0]; implicitStringCode = components[1]; } else { langTag = tagStrs[0]; implicitStringCode = null; } } else { var minTag = tagStrs.Select(t => new {Tag = t, Components = t.Split('-')}).MinBy(t => t.Components.Length); langTag = minTag.Tag; implicitStringCode = null; // only look for an implicit script code if the minimal tag has no script code if (minTag.Components.Length < 2 || minTag.Components[1].Length != 4) { foreach (string tagStr in tagStrs) { string[] components = tagStr.Split('-'); if (components.Length == minTag.Components.Length + 1 && components[1].Length == 4) implicitStringCode = components[1]; } } } SldrLanguageTagInfo existingTag; if (tags.TryGet(langTag, out existingTag)) { // alltags.txt can contain multiple lines that contain the same language tag. // if one of the lines contains information on an implicit script for a language tag, // we don't want to lose that information, so we preserve it by not replacing the // SldrLanguageTagInfo object for this language tag. if (existingTag.ImplicitScriptCode != null) continue; tags.Remove(langTag); } tags.Add(new SldrLanguageTagInfo(langTag, implicitStringCode, sldrLangTag, isAvailable)); } } return tags; }