Exemple #1
0
 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;
     }
 }
Exemple #2
0
 internal static LayoutVersion.LayoutFeature GetLastNonReservedFeature(LayoutVersion.LayoutFeature
                                                                       [] features)
 {
     for (int i = features.Length - 1; i >= 0; i--)
     {
         LayoutVersion.FeatureInfo info = features[i].GetInfo();
         if (!info.IsReservedForOldRelease())
         {
             return(features[i]);
         }
     }
     throw new Exception("All layout versions are reserved.");
 }
        /// <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));
            }
        }
Exemple #4
0
        /// <summary>
        /// Gets formatted string that describes
        /// <see cref="LayoutVersion"/>
        /// information.
        /// </summary>
        public virtual string GetString(IDictionary <int, ICollection <LayoutVersion.LayoutFeature
                                                                       > > map, LayoutVersion.LayoutFeature[] values)
        {
            StringBuilder buf = new StringBuilder();

            buf.Append("Feature List:\n");
            foreach (LayoutVersion.LayoutFeature f in values)
            {
                LayoutVersion.FeatureInfo info = f.GetInfo();
                buf.Append(f).Append(" introduced in layout version ").Append(info.GetLayoutVersion
                                                                                  ()).Append(" (").Append(info.GetDescription()).Append(")\n");
            }
            buf.Append("\n\nLayoutVersion and supported features:\n");
            foreach (LayoutVersion.LayoutFeature f_1 in values)
            {
                LayoutVersion.FeatureInfo info = f_1.GetInfo();
                buf.Append(info.GetLayoutVersion()).Append(": ").Append(map[info.GetLayoutVersion
                                                                                ()]).Append("\n");
            }
            return(buf.ToString());
        }