Browse Source

improve StaticResource detection: #206 works now partially

pull/348/head
Siegfried Pammer 14 years ago
parent
commit
cc0d71d15a
  1. 2
      ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/KnownInfo.cs
  2. 11
      ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs

2
ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/KnownInfo.cs

@ -12,7 +12,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
internal TypeDeclaration[] KnownTypeTable = null; internal TypeDeclaration[] KnownTypeTable = null;
internal PropertyDeclaration[] KnownPropertyTable = null; internal PropertyDeclaration[] KnownPropertyTable = null;
internal static String[] KnownAssemblyTable = null; internal static String[] KnownAssemblyTable = null;
internal Hashtable KnownResourceTable = new Hashtable(); internal Dictionary<int, ResourceName> KnownResourceTable = new Dictionary<int, ResourceName>();
#region Initialize #region Initialize

11
ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs

@ -689,7 +689,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
bool isNotKey = (identifier > 0xe8); bool isNotKey = (identifier > 0xe8);
if (isNotKey) if (isNotKey)
identifier = (short)(identifier - 0xe8); identifier = (short)(identifier - 0xe8);
ResourceName resource = (ResourceName) KnownInfo.KnownResourceTable[(int)identifier]; ResourceName resource = KnownInfo.KnownResourceTable[identifier];
if (!isNotKey) if (!isNotKey)
return new ResourceName(resource.Name + "Key"); return new ResourceName(resource.Name + "Key");
return resource; return resource;
@ -1512,9 +1512,12 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
object GetStaticResource(short identifier) object GetStaticResource(short identifier)
{ {
if (identifier < keys[currentKey - 1].StaticResources.Count) int keyIndex = currentKey;
return keys[currentKey - 1].StaticResources[(int)identifier]; while (keyIndex >= 0 && !keys[keyIndex].HasStaticResources)
keyIndex--;
if (keyIndex >= 0 && identifier < keys[keyIndex].StaticResources.Count)
return keys[keyIndex].StaticResources[(int)identifier];
// Debug.WriteLine(string.Format("Cannot find StaticResource: {0}", identifier));
// return "???" + identifier + "???"; // return "???" + identifier + "???";
throw new ArgumentException("Cannot find StaticResource: " + identifier, "identifier"); throw new ArgumentException("Cannot find StaticResource: " + identifier, "identifier");
} }

Loading…
Cancel
Save