/// <summary> /// Parsing from the resource Json file to obtain the mapping /// </summary> private static Dictionary <string, MegaCategory> Initialize() { var mapping = new Dictionary <string, MegaCategory>(); var assembly = IntrospectionExtensions.GetTypeInfo(typeof(MegaCategory)).Assembly; var stream = assembly.GetManifestResourceStream(SharedConstants.MegaCategoryMappingJsonFilePath); if (stream == null) { throw new ArgumentNullException(); } var r = new StreamReader(stream); var json = r.ReadToEnd(); var mappingObjectItems = JsonConvert.DeserializeObject <List <DeserializationMapping> >(json); foreach (var item in mappingObjectItems) { var megaCategory = new MegaCategory(item.Name); foreach (var subCat in item.SubCategories) { mapping.Add(subCat, megaCategory); } } mapping.Add(SharedConstants.CustomMegaCategoryLabel, new MegaCategory(SharedConstants.CustomMegaCategoryLabel)); return(mapping); }
protected bool Equals(MegaCategory other) { if (other == null) { throw new ArgumentNullException(); } return(string.Equals(Label, other.Label, StringComparison.OrdinalIgnoreCase)); }