public static T MergeStyleSets <T>(params StyleSet <T>[] styleSets) where T : StyleSet <T>, new() { var classNameSet = new T(); var classMap = new Dictionary <string, string>(); if (!styleSets.Any()) { return(new T()); } var styleSet = styleSets[0]; StyleSet <T> concatenatedStyleSet = styleSet; if (styleSets.Any()) { concatenatedStyleSet = ConcatStyleSet(styleSets); } var registrations = new List <Registration>(); foreach (var styleSetArea in concatenatedStyleSet) { var subCompKey = nameof(concatenatedStyleSet.SubComponentStyles); if (styleSetArea.Key.properertyName == subCompKey) { classNameSet.SubComponentStyles = concatenatedStyleSet.ContainsKey(styleSetArea.Key) ? concatenatedStyleSet.SubComponentStyles : new Dictionary <string, object>(); continue; } var styles = (Style)styleSetArea.Value; (var classes, var objects) = ExtractStyleParts(styles).GetAwaiter().GetResult(); var displayName = styleSetArea.Key.key; var registration = StyleToRegistration(new Style { DisplayName = displayName }, objects.ToArray()).GetAwaiter().GetResult(); registrations.Add(registration); if (registration != null) { classMap[styleSetArea.Key.key] = registration.ClassName; var value = classes.Concat(new string[] { registration.ClassName }).Join(" "); ((IStyleSet <T>)classNameSet).AddStyle(styleSetArea.Key.properertyName, value); } } foreach (var registration in registrations) { if (registration != null) { ApplyRegistration(registration, classMap).GetAwaiter().GetResult(); } } return(classNameSet); }