public void Merge(Sector metadataSource) { if (metadataSource == null) { throw new ArgumentNullException("metadataSource"); } // TODO: This is very fragile; if a new type is added to Sector we need to add more code here. if (metadataSource.Names.Any()) { Names.Clear(); Names.AddRange(metadataSource.Names); } if (metadataSource.DataFile != null && DataFile != null && (metadataSource.DataFile.FileName != DataFile.FileName || metadataSource.DataFile.Type != DataFile.Type)) { throw new Exception(string.Format("Mismatching DataFile entries for {0}", this.Names[0].Text)); } if (metadataSource.DataFile != null) { DataFile = metadataSource.DataFile; } Subsectors.AddRange(metadataSource.Subsectors); Allegiances.AddRange(metadataSource.Allegiances); Borders.AddRange(metadataSource.Borders); Routes.AddRange(metadataSource.Routes); Labels.AddRange(metadataSource.Labels); Credits = metadataSource.Credits; Products.AddRange(metadataSource.Products); StylesheetText = metadataSource.StylesheetText; }
public Subsector this[char alpha] { get { return(Subsectors.Where(ss => ss.Index != null && ss.Index[0] == alpha).FirstOrDefault()); } }
public int SubsectorIndexFor(string label) { if (string.IsNullOrWhiteSpace(label)) { return(-1); } Subsector subsector; if (label.Length == 1) { char c = char.ToUpperInvariant(label[0]); if (Util.InRange(c, 'A', 'P')) { return((int)c - (int)'A'); } } subsector = Subsectors.Where(ss => !string.IsNullOrEmpty(ss.Name) && ss.Name.Equals(label, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault(); return(subsector?.IndexNumber ?? -1); }
public Subsector Subsector(char alpha) { return(Subsectors.Where(ss => ss.Index != null && ss.Index[0] == alpha).FirstOrDefault()); }