Skip to content

Commit

Permalink
improve StaticResource detection: icsharpcode#206 works now partially
Browse files Browse the repository at this point in the history
  • Loading branch information
siegfriedpammer committed Apr 8, 2012
1 parent c2c419e commit cc0d71d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class KnownInfo
internal TypeDeclaration[] KnownTypeTable = null;
internal PropertyDeclaration[] KnownPropertyTable = null;
internal static String[] KnownAssemblyTable = null;
internal Hashtable KnownResourceTable = new Hashtable();
internal Dictionary<int, ResourceName> KnownResourceTable = new Dictionary<int, ResourceName>();

#region Initialize

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ object GetResourceName(short identifier)
bool isNotKey = (identifier > 0xe8);
if (isNotKey)
identifier = (short)(identifier - 0xe8);
ResourceName resource = (ResourceName) KnownInfo.KnownResourceTable[(int)identifier];
ResourceName resource = KnownInfo.KnownResourceTable[identifier];
if (!isNotKey)
return new ResourceName(resource.Name + "Key");
return resource;
Expand Down Expand Up @@ -1512,9 +1512,12 @@ void ReadPropertyWithStaticResourceIdentifier()

object GetStaticResource(short identifier)
{
if (identifier < keys[currentKey - 1].StaticResources.Count)
return keys[currentKey - 1].StaticResources[(int)identifier];

int keyIndex = currentKey;
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 + "???";
throw new ArgumentException("Cannot find StaticResource: " + identifier, "identifier");
}
Expand Down

0 comments on commit cc0d71d

Please sign in to comment.