private void IncludeSlabsDependencies(IDictionary <string, Slab> includedSlabs, Dictionary <string, IEnumerable <string> > slabNameToDependencies, string[] enabledFeatureNames, LayoutType layout) { if (!slabNameToDependencies.Any <KeyValuePair <string, IEnumerable <string> > >()) { return; } IEnumerable <string> source = from slabNameToDependency in slabNameToDependencies.Values from dependency in slabNameToDependency where !includedSlabs.ContainsKey(dependency) select dependency; ILookup <string, string> lookup = source.ToLookup((string s) => s); Dictionary <string, IEnumerable <string> > dictionary = new Dictionary <string, IEnumerable <string> >(); IEnumerable <KeyValuePair <string, SlabDefinition> > enumerable = from kv in this.SlabDefinitions where lookup.Contains(kv.Key) select kv; foreach (KeyValuePair <string, SlabDefinition> keyValuePair in enumerable) { string key = keyValuePair.Key; SlabDefinition value = keyValuePair.Value; string[] array = enabledFeatureNames.Where(new Func <string, bool>(value.HasBinding)).ToArray <string>(); IEnumerable <string> enumerable2; if (array.Any <string>()) { includedSlabs[key] = value.GetSlab(array, layout, out enumerable2); } else if (value.HasDefaultBinding()) { includedSlabs[key] = value.GetDefaultSlab(layout, out enumerable2); } else { string text = value.GetFeatures().First <string>(); includedSlabs[key] = value.GetSlab(new string[] { text }, layout, out enumerable2); } if (enumerable2 != null) { dictionary[key] = enumerable2; } } this.IncludeSlabsDependencies(includedSlabs, dictionary, enabledFeatureNames, layout); }
public IDictionary <string, Slab> GetSlabs(string[] enabledFeatureNames, LayoutType layout) { Dictionary <string, Slab> dictionary = new Dictionary <string, Slab>(); Dictionary <string, IEnumerable <string> > dictionary2 = new Dictionary <string, IEnumerable <string> >(); foreach (KeyValuePair <string, SlabDefinition> keyValuePair in this.SlabDefinitions) { string key = keyValuePair.Key; if (this.Type != SlabManifestType.SharedHoverCard || !key.Equals("editor")) { SlabDefinition value = keyValuePair.Value; string[] array = enabledFeatureNames.Where(new Func <string, bool>(value.HasBinding)).ToArray <string>(); IEnumerable <string> enumerable = null; if (array.Any <string>()) { dictionary[key] = value.GetSlab(array, layout, out enumerable); } else if (value.HasDefaultBinding()) { Slab defaultSlab = value.GetDefaultSlab(layout, out enumerable); if (this.Type == SlabManifestType.SharedHoverCard && defaultSlab.Dependencies.Contains("editor")) { IEnumerable <string> second = new string[] { "editor" }; defaultSlab.Dependencies = enumerable.Except(second).ToArray <string>(); } dictionary[key] = defaultSlab; } if (enumerable != null) { if (this.Type == SlabManifestType.SharedHoverCard && enumerable.Contains("editor")) { IEnumerable <string> second2 = new string[] { "editor" }; enumerable = enumerable.Except(second2).ToArray <string>(); } dictionary2[key] = enumerable; } } } this.IncludeSlabsDependencies(dictionary, dictionary2, enabledFeatureNames, layout); return(dictionary); }