private SlabBinding FindClosestBinding(ICollection <string> featureNames) { if (featureNames.Count == 0) { return(base.FindDefaultBinding()); } SlabBinding slabBinding = base.Bindings.FirstOrDefault((SlabBinding b) => b.IsDefault); int num = (slabBinding != null) ? 0 : -1; foreach (SlabBinding slabBinding2 in base.Bindings) { bool flag = slabBinding2.Features.Any((string f) => !featureNames.Contains(f)); if (slabBinding != slabBinding2 && !flag) { int num2 = (from feature in slabBinding2.Features where featureNames.Contains(feature, StringComparer.OrdinalIgnoreCase) select feature).Count <string>(); if ((slabBinding != null || num2 != 0) && num2 > 0 && num < num2) { slabBinding = slabBinding2; num = num2; } } } if (slabBinding == null) { throw new SlabBindingNotFoundException("Closest binding cannot be found"); } return(slabBinding); }
// Token: 0x06002685 RID: 9861 RVA: 0x0008B538 File Offset: 0x00089738 public void AddBinding(SlabBinding binding) { if (binding == null) { throw new ArgumentNullException("binding"); } this.bindings.Add(binding); }
// Token: 0x0600268D RID: 9869 RVA: 0x0008B8C4 File Offset: 0x00089AC4 protected SlabBinding FindDefaultBinding() { SlabBinding slabBinding = this.bindings.FirstOrDefault((SlabBinding b) => b.IsDefault); if (slabBinding == null) { throw new SlabBindingNotFoundException("Default Binding not found"); } return(slabBinding); }
// Token: 0x0600268B RID: 9867 RVA: 0x0008B690 File Offset: 0x00089890 public virtual Slab GetSlab(string[] featureNames, LayoutType layout, out IEnumerable <string> slabDependencies) { if (featureNames == null) { throw new ArgumentNullException("featureNames"); } SlabBinding binding = this.FindBinding(featureNames); return(this.GetSlabForBinding(binding, layout, out slabDependencies)); }
public Slab GetSlab(ICollection <string> featureNames, LayoutType layout) { if (featureNames == null) { throw new ArgumentNullException("featureNames"); } SlabBinding binding = this.FindClosestBinding(featureNames); IEnumerable <string> enumerable; return(this.GetSlabForBinding(binding, layout, out enumerable)); }
// Token: 0x0600268E RID: 9870 RVA: 0x0008B938 File Offset: 0x00089B38 private SlabBinding FindBinding(string[] featureNames) { using (IEnumerator <SlabBinding> enumerator = this.Bindings.GetEnumerator()) { while (enumerator.MoveNext()) { SlabBinding binding = enumerator.Current; if (featureNames.Any((string feature) => binding.Implement(new string[] { feature }))) { return(binding); } } } throw new SlabBindingNotFoundException(string.Format("Binding not found for feature '{0}'", string.Join(",", featureNames))); }
private static IList <SlabBinding> LoadSlabBindings(string slabName, XmlNode node) { if (node.LocalName != "bindings") { throw new SlabManifestFormatException("Expected xml node with local name 'bindings' but found " + node.LocalName); } List <SlabBinding> list = new List <SlabBinding>(); bool flag = false; for (int i = 0; i < node.ChildNodes.Count; i++) { SlabBinding slabBinding = SlabManifestLoader.LoadSlabSingleBinding(node.ChildNodes[i]); if (flag && slabBinding.IsDefault) { throw new SlabManifestFormatException("Multiple default binding found slab " + slabName); } flag |= slabBinding.IsDefault; list.Add(slabBinding); } return(list); }
// Token: 0x0600268C RID: 9868 RVA: 0x0008B734 File Offset: 0x00089934 protected virtual Slab GetSlabForBinding(SlabBinding binding, LayoutType layout, out IEnumerable <string> slabDependencies) { if (binding == null) { throw new ArgumentNullException("binding"); } slabDependencies = binding.Dependencies; return(new Slab { Types = this.types.ToArray <string>(), Templates = this.templates.ToArray <string>(), Styles = (from s in binding.Styles where s.IsForLayout(layout) select s).ToArray <SlabStyleFile>(), Configurations = (from s in binding.Configurations.Distinct <SlabConfiguration>() where s.IsForLayout(layout) select s).ToArray <SlabConfiguration>(), Dependencies = binding.Dependencies.Distinct <string>().ToArray <string>(), PackagedSources = (from s in binding.PackagedSources where s.IsForLayout(layout) select s).ToArray <SlabSourceFile>(), Images = (from s in binding.Images where s.IsForLayout(layout) select s).ToArray <SlabImageFile>(), Fonts = (from s in binding.Fonts where s.IsForLayout(layout) select s).ToArray <SlabFontFile>(), Sources = (from s in binding.Sources where s.IsForLayout(layout) select s).ToArray <SlabSourceFile>(), Strings = (from s in binding.Strings where s.IsForLayout(layout) select s).ToArray <SlabStringFile>(), PackagedStrings = (from s in binding.PackagedStrings where s.IsForLayout(layout) select s).ToArray <SlabStringFile>() }); }
// Token: 0x0600268A RID: 9866 RVA: 0x0008B670 File Offset: 0x00089870 public Slab GetDefaultSlab(LayoutType layout, out IEnumerable <string> slabDependencies) { SlabBinding binding = this.FindDefaultBinding(); return(this.GetSlabForBinding(binding, layout, out slabDependencies)); }