|
|
@ -968,7 +968,8 @@ namespace Ricciolo.StylesExplorer.MarkupReflection |
|
|
|
string recordName = this.stringTable[identifier]; |
|
|
|
string recordName = this.stringTable[identifier]; |
|
|
|
if (recordName != "Key") throw new NotSupportedException(recordName); |
|
|
|
if (recordName != "Key") throw new NotSupportedException(recordName); |
|
|
|
pd = new PropertyDeclaration(recordName, XamlTypeDeclaration); |
|
|
|
pd = new PropertyDeclaration(recordName, XamlTypeDeclaration); |
|
|
|
|
|
|
|
if (keys == null) |
|
|
|
|
|
|
|
keys = new List<KeyMapping>(); |
|
|
|
keys.Add(new KeyMapping(text) { Position = -1 }); |
|
|
|
keys.Add(new KeyMapping(text) { Position = -1 }); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -1020,7 +1021,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection |
|
|
|
if (mappingToChange == null) |
|
|
|
if (mappingToChange == null) |
|
|
|
throw new InvalidOperationException("Cannot find mapping"); |
|
|
|
throw new InvalidOperationException("Cannot find mapping"); |
|
|
|
|
|
|
|
|
|
|
|
@namespace = String.Format("{0};assembly={1}", @namespace, GetAssembly(mappingToChange.AssemblyId).Replace(" ", "")); |
|
|
|
@namespace = String.Format("{0};assembly={1}", @namespace, mappingToChange.Assembly.Replace(" ", "")); |
|
|
|
mappingToChange.XmlNamespace = @namespace; |
|
|
|
mappingToChange.XmlNamespace = @namespace; |
|
|
|
} |
|
|
|
} |
|
|
|
namespaces.Add(new XmlNamespace(prefix, @namespace)); |
|
|
|
namespaces.Add(new XmlNamespace(prefix, @namespace)); |
|
|
@ -1247,18 +1248,14 @@ namespace Ricciolo.StylesExplorer.MarkupReflection |
|
|
|
|
|
|
|
|
|
|
|
XmlPIMapping FindByClrNamespaceAndAssemblyId(TypeDeclaration declaration) |
|
|
|
XmlPIMapping FindByClrNamespaceAndAssemblyId(TypeDeclaration declaration) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return FindByClrNamespaceAndAssemblyId(declaration.Namespace, declaration.AssemblyId); |
|
|
|
return FindByClrNamespaceAndAssemblyName(declaration.Namespace, declaration.Assembly); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
XmlPIMapping FindByClrNamespaceAndAssemblyId(string clrNamespace, int assemblyId) |
|
|
|
XmlPIMapping FindByClrNamespaceAndAssemblyName(string clrNamespace, string assemblyName) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (clrNamespace == XamlTypeDeclaration.Namespace && assemblyId == XamlTypeDeclaration.AssemblyId) |
|
|
|
for (int x = 0; x < Mappings.Count; x++) { |
|
|
|
return new XmlPIMapping(XmlPIMapping.XamlNamespace, 0, clrNamespace); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int x = 0; x < Mappings.Count; x++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
XmlPIMapping xp = Mappings[x]; |
|
|
|
XmlPIMapping xp = Mappings[x]; |
|
|
|
if (xp.AssemblyId == assemblyId && String.CompareOrdinal(xp.ClrNamespace, clrNamespace) == 0) |
|
|
|
if (string.Equals(xp.Assembly, assemblyName, StringComparison.Ordinal) && string.Equals(xp.ClrNamespace, clrNamespace, StringComparison.Ordinal)) |
|
|
|
return xp; |
|
|
|
return xp; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1271,7 +1268,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection |
|
|
|
string clrNamespace = reader.ReadString(); |
|
|
|
string clrNamespace = reader.ReadString(); |
|
|
|
short assemblyId = reader.ReadInt16(); |
|
|
|
short assemblyId = reader.ReadInt16(); |
|
|
|
|
|
|
|
|
|
|
|
Mappings.Add(new XmlPIMapping(xmlNamespace, assemblyId, clrNamespace)); |
|
|
|
Mappings.Add(new XmlPIMapping(xmlNamespace, GetAssembly(assemblyId), clrNamespace)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ReadContentProperty() |
|
|
|
void ReadContentProperty() |
|
|
@ -1452,7 +1449,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection |
|
|
|
|
|
|
|
|
|
|
|
string FormatTypeDeclaration(TypeDeclaration typeDeclaration) |
|
|
|
string FormatTypeDeclaration(TypeDeclaration typeDeclaration) |
|
|
|
{ |
|
|
|
{ |
|
|
|
XmlPIMapping mapping = FindByClrNamespaceAndAssemblyId(typeDeclaration.Namespace, typeDeclaration.AssemblyId); |
|
|
|
XmlPIMapping mapping = FindByClrNamespaceAndAssemblyName(typeDeclaration.Namespace, typeDeclaration.Assembly); |
|
|
|
string prefix = (mapping != null) ? this.LookupPrefix(mapping.XmlNamespace, false) : null; |
|
|
|
string prefix = (mapping != null) ? this.LookupPrefix(mapping.XmlNamespace, false) : null; |
|
|
|
string name = typeDeclaration.Name; |
|
|
|
string name = typeDeclaration.Name; |
|
|
|
if (name.EndsWith("Extension")) |
|
|
|
if (name.EndsWith("Extension")) |
|
|
@ -1479,7 +1476,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection |
|
|
|
bool differentType = ((propertyDeclaration.DeclaringType != propertyDeclaration.DeclaringType || !isDescendant)); |
|
|
|
bool differentType = ((propertyDeclaration.DeclaringType != propertyDeclaration.DeclaringType || !isDescendant)); |
|
|
|
|
|
|
|
|
|
|
|
if (withPrefix) { |
|
|
|
if (withPrefix) { |
|
|
|
XmlPIMapping mapping = FindByClrNamespaceAndAssemblyId(propertyDeclaration.DeclaringType.Namespace, propertyDeclaration.DeclaringType.AssemblyId); |
|
|
|
XmlPIMapping mapping = FindByClrNamespaceAndAssemblyName(propertyDeclaration.DeclaringType.Namespace, propertyDeclaration.DeclaringType.Assembly); |
|
|
|
string prefix = (mapping != null) ? this.LookupPrefix(mapping.XmlNamespace, false) : null; |
|
|
|
string prefix = (mapping != null) ? this.LookupPrefix(mapping.XmlNamespace, false) : null; |
|
|
|
|
|
|
|
|
|
|
|
if (!String.IsNullOrEmpty(prefix)) { |
|
|
|
if (!String.IsNullOrEmpty(prefix)) { |
|
|
@ -1519,7 +1516,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection |
|
|
|
return keys[currentKey - 1].StaticResources[(int)identifier]; |
|
|
|
return keys[currentKey - 1].StaticResources[(int)identifier]; |
|
|
|
|
|
|
|
|
|
|
|
// return "???" + identifier + "???";
|
|
|
|
// return "???" + identifier + "???";
|
|
|
|
throw new ArgumentException("Cannot find StaticResource", "identifier"); |
|
|
|
throw new ArgumentException("Cannot find StaticResource: " + identifier, "identifier"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ReadTextWithConverter() |
|
|
|
void ReadTextWithConverter() |
|
|
@ -1542,11 +1539,11 @@ namespace Ricciolo.StylesExplorer.MarkupReflection |
|
|
|
{ |
|
|
|
{ |
|
|
|
string name = fullName.Substring(length + 1); |
|
|
|
string name = fullName.Substring(length + 1); |
|
|
|
string namespaceName = fullName.Substring(0, length); |
|
|
|
string namespaceName = fullName.Substring(0, length); |
|
|
|
declaration = new TypeDeclaration(this, this.Resolver, name, namespaceName, assemblyId, false); |
|
|
|
declaration = new TypeDeclaration(this, this.Resolver, name, namespaceName, assemblyId); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
declaration = new TypeDeclaration(this, this.Resolver, fullName, string.Empty, assemblyId, false); |
|
|
|
declaration = new TypeDeclaration(this, this.Resolver, fullName, string.Empty, assemblyId); |
|
|
|
} |
|
|
|
} |
|
|
|
this.typeTable.Add(typeId, declaration); |
|
|
|
this.typeTable.Add(typeId, declaration); |
|
|
|
} |
|
|
|
} |
|
|
@ -1579,14 +1576,13 @@ namespace Ricciolo.StylesExplorer.MarkupReflection |
|
|
|
return declaration; |
|
|
|
return declaration; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TypeDeclaration GetKnownTypeDeclarationByName(string name) |
|
|
|
TypeDeclaration GetKnownTypeDeclarationByName(string assemblyQualifiedName) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (var type in KnownInfo.KnownTypeTable) { |
|
|
|
foreach (var type in KnownInfo.KnownTypeTable) { |
|
|
|
if (name == type.AssemblyQualifiedName) |
|
|
|
if (assemblyQualifiedName == type.AssemblyQualifiedName) |
|
|
|
return type; |
|
|
|
return type; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return new ResolverTypeDeclaration(_resolver, assemblyQualifiedName); |
|
|
|
throw new NotSupportedException("Type '" + name + "' not found!"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
internal string GetAssembly(short identifier) |
|
|
|
internal string GetAssembly(short identifier) |
|
|
@ -1616,8 +1612,8 @@ namespace Ricciolo.StylesExplorer.MarkupReflection |
|
|
|
declaration = ((XmlBamlProperty)node).PropertyDeclaration.DeclaringType; |
|
|
|
declaration = ((XmlBamlProperty)node).PropertyDeclaration.DeclaringType; |
|
|
|
TypeDeclaration elementDeclaration = this.readingElements.Peek().TypeDeclaration; |
|
|
|
TypeDeclaration elementDeclaration = this.readingElements.Peek().TypeDeclaration; |
|
|
|
|
|
|
|
|
|
|
|
XmlPIMapping propertyMapping = FindByClrNamespaceAndAssemblyId(declaration) ?? XmlPIMapping.Presentation; |
|
|
|
XmlPIMapping propertyMapping = FindByClrNamespaceAndAssemblyId(declaration) ?? XmlPIMapping.GetPresentationMapping(GetAssembly); |
|
|
|
XmlPIMapping elementMapping = FindByClrNamespaceAndAssemblyId(elementDeclaration) ?? XmlPIMapping.Presentation; |
|
|
|
XmlPIMapping elementMapping = FindByClrNamespaceAndAssemblyId(elementDeclaration) ?? XmlPIMapping.GetPresentationMapping(GetAssembly); |
|
|
|
|
|
|
|
|
|
|
|
if (((XmlBamlProperty)node).PropertyDeclaration.Name == "Name" && |
|
|
|
if (((XmlBamlProperty)node).PropertyDeclaration.Name == "Name" && |
|
|
|
_resolver.IsLocalAssembly(((XmlBamlProperty)node).Parent.TypeDeclaration.Assembly)) |
|
|
|
_resolver.IsLocalAssembly(((XmlBamlProperty)node).Parent.TypeDeclaration.Assembly)) |
|
|
@ -1634,7 +1630,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection |
|
|
|
|
|
|
|
|
|
|
|
XmlPIMapping mapping = FindByClrNamespaceAndAssemblyId(declaration); |
|
|
|
XmlPIMapping mapping = FindByClrNamespaceAndAssemblyId(declaration); |
|
|
|
if (mapping == null) |
|
|
|
if (mapping == null) |
|
|
|
mapping = XmlPIMapping.Presentation; |
|
|
|
mapping = XmlPIMapping.GetPresentationMapping(GetAssembly); |
|
|
|
|
|
|
|
|
|
|
|
return mapping.XmlNamespace; |
|
|
|
return mapping.XmlNamespace; |
|
|
|
} |
|
|
|
} |
|
|
|