/// <summary>
/// Merge with another DefaultStyle.
/// </summary>
/// <param name="other">Other DefaultStyle to merge.</param>
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;
}
}