/// <summary>The get minify css pivots.</summary> /// <param name="contentItem">The content item.</param> /// <param name="dpiValues">The dpi values.</param> /// <param name="mergedResources">The merged resources.</param> /// <param name="allDpiResources">The all Dpi Resources.</param> /// <returns>The pivots of the css to minify</returns> private static IEnumerable <MinifyCssPivot> GetMinifyCssPivots(ContentItem contentItem, IEnumerable <float> dpiValues, Dictionary <ResourcePivotKey[], IDictionary <string, IDictionary <string, string> > > mergedResources, IDictionary <string, IDictionary <string, string> > allDpiResources) { var contentResourcePivotKeys = contentItem.ResourcePivotKeys ?? new ResourcePivotKey[] { }; var dpiPivots = dpiValues.Select( dpi => { var dpiResolutionName = EverythingActivity.DpiToResolutionName(dpi); IDictionary <string, string> dpiResources = null; if (allDpiResources != null) { allDpiResources.TryGetValue(dpiResolutionName, out dpiResources); } var dpiResourcePivotKey = new ResourcePivotKey(Strings.DpiResourcePivotKey, dpiResolutionName); return(new { dpi, dpiResolutionName, dpiResourcePivotKey, dpiResources }); }); // Make sure we do dpi each before pivot to make it optimal when parallel var pivots = mergedResources.SelectMany( mergedResourceValues => { var mergedResource = mergedResourceValues.Value.Values.ToList(); return(dpiPivots.Select( dpiPivot => { var dpiSpecificMergedResources = mergedResource.ToList(); if (dpiPivot.dpiResources != null) { dpiSpecificMergedResources.Add(dpiPivot.dpiResources); } return new MinifyCssPivot( dpiSpecificMergedResources, contentResourcePivotKeys.Concat(mergedResourceValues.Key).Concat(new[] { dpiPivot.dpiResourcePivotKey }).ToArray(), dpiPivot.dpi); })); }); return(pivots); }
/// <summary>Determines if the resource pivot key should be temporary ignored.</summary> /// <param name="resourcePivotKey">The resource pivot key.</param> /// <returns>The <see cref="bool"/>.</returns> private bool ShouldIgnore(ResourcePivotKey resourcePivotKey) { return(this.resourcePivots.ContainsKey(resourcePivotKey.GroupKey) && this.resourcePivots[resourcePivotKey.GroupKey].Any() && this.resourcePivots[resourcePivotKey.GroupKey].All(pivotToIgnore => resourcePivotKey.Key.IndexOf(pivotToIgnore, StringComparison.OrdinalIgnoreCase) == -1)); }