Microsoft.Silverlight.Toolkit.Build.Tasks.DefaultStyle.Merge C# (CSharp) Method

Merge() private method

Merge with another DefaultStyle.
private Merge ( DefaultStyle other ) : void
other DefaultStyle Other DefaultStyle to merge.
return void
        private void Merge(DefaultStyle other)
        {
            // Merge or lower namespaces
            foreach (KeyValuePair<string, string> ns in other.Namespaces)
            {
                string value = null;
                if (!Namespaces.TryGetValue(ns.Key, out value))
                {
                    Namespaces.Add(ns.Key, ns.Value);
                }
                else if (value != ns.Value)
                {
                    other.LowerNamespace(ns.Key);
                }
            }

            // Merge the resources
            foreach (KeyValuePair<string, XElement> resource in other.Resources)
            {
                if (Resources.ContainsKey(resource.Key))
                {
                    throw new InvalidOperationException(string.Format(
                        CultureInfo.InvariantCulture,
                        "Resource \"{0}\" is used by both {1} and {2}!",
                        resource.Key,
                        MergeHistory[resource.Key],
                        other.DefaultStylePath));
                }
                Resources[resource.Key] = resource.Value;
                MergeHistory[resource.Key] = other.DefaultStylePath;
            }
        }

Same methods

DefaultStyle::Merge ( IEnumerable styles ) : DefaultStyle

Usage Example

        /// <summary>
        /// Merge a sequence of DefaultStyles into a single style.
        /// </summary>
        /// <param name="styles">Sequence of DefaultStyles.</param>
        /// <returns>Merged DefaultStyle.</returns>
        public static DefaultStyle Merge(IEnumerable <DefaultStyle> styles)
        {
            DefaultStyle combined = new DefaultStyle();

            if (styles != null)
            {
                foreach (DefaultStyle style in styles)
                {
                    combined.Merge(style);
                }
            }
            return(combined);
        }
All Usage Examples Of Microsoft.Silverlight.Toolkit.Build.Tasks.DefaultStyle::Merge