/// <summary> /// Attempts to merge the specified style builder registration with our current registrations. /// </summary> /// <param name="mergeRegistration">The source registration which is to be merged with the default registration /// of the metadata.</param> /// <param name="themeName"></param> /// <returns>The default registration if successfully merged, otherwise null</returns> protected internal virtual StyleBuilderRegistration TryMergeRegistration(XmlStyleBuilderRegistration mergeRegistration, string themeName) { List <StyleBuilderRegistration> allRegistrations = this.StyleBuilderRegistrations; StyleSheet mergeStyle = null; foreach (StyleBuilderRegistration thisRegistration in allRegistrations) { bool match = false; foreach (RadStylesheetRelation mergeRelation in mergeRegistration.StylesheetRelations) { foreach (RadStylesheetRelation thisRelation in thisRegistration.StylesheetRelations) { //our registration matches the provided one if (!mergeRelation.Equals(thisRelation)) { continue; } if (mergeStyle == null) { mergeStyle = (mergeRegistration.GetRegistration().Builder as DefaultStyleBuilder).Style; } //merge style and relations (thisRegistration.Builder as DefaultStyleBuilder).Style = mergeStyle; this.AddUniqueRelations(thisRegistration, mergeRegistration.StylesheetRelations, themeName); this.MergeItemStates(mergeStyle); match = true; break; } //match is found for current registration, continue with top-level loop if (match) { return(thisRegistration); } } } return(null); }