public static void UpdateMap(IDictionary <int, ICollection <LayoutVersion.LayoutFeature > > map, LayoutVersion.LayoutFeature[] features) { // Go through all the enum constants and build a map of // LayoutVersion <-> Set of all supported features in that LayoutVersion foreach (LayoutVersion.LayoutFeature f in features) { LayoutVersion.FeatureInfo info = f.GetInfo(); ICollection <LayoutVersion.LayoutFeature> ancestorSet = map[info.GetAncestorLayoutVersion ()]; if (ancestorSet == null) { // Empty set ancestorSet = new TreeSet <LayoutVersion.LayoutFeature>(new LayoutVersion.LayoutFeatureComparator ()); map[info.GetAncestorLayoutVersion()] = ancestorSet; } ICollection <LayoutVersion.LayoutFeature> featureSet = new TreeSet <LayoutVersion.LayoutFeature >(ancestorSet); if (info.GetSpecialFeatures() != null) { foreach (LayoutVersion.LayoutFeature specialFeature in info.GetSpecialFeatures()) { featureSet.AddItem(specialFeature); } } featureSet.AddItem(f); map[info.GetLayoutVersion()] = featureSet; } }
/// <summary> /// Given feature /// <paramref name="f"/> /// , ensures the layout version of that feature /// supports all the features supported by it's ancestor. /// </summary> private void ValidateFeatureList(LayoutVersion.LayoutFeature f) { LayoutVersion.FeatureInfo info = f.GetInfo(); int lv = info.GetLayoutVersion(); int ancestorLV = info.GetAncestorLayoutVersion(); ICollection <LayoutVersion.LayoutFeature> ancestorSet = NameNodeLayoutVersion.GetFeatures (ancestorLV); NUnit.Framework.Assert.IsNotNull(ancestorSet); foreach (LayoutVersion.LayoutFeature feature in ancestorSet) { NUnit.Framework.Assert.IsTrue("LV " + lv + " does nto support " + feature + " supported by the ancestor LV " + info.GetAncestorLayoutVersion(), NameNodeLayoutVersion.Supports(feature, lv)); } }