Commit cc6b2f20 authored by Tebjan Halm's avatar Tebjan Halm
Browse files

Merge pull request #103 from sunsided/pull-requests/containsattribute-nullref

fixed NullReferenceException when _styles is not set
parents d15e5419 94746802
...@@ -77,7 +77,7 @@ namespace Svg ...@@ -77,7 +77,7 @@ namespace Svg
{ {
SortedDictionary<int, string> rules; SortedDictionary<int, string> rules;
return (this.Attributes.ContainsKey(name) || this.CustomAttributes.ContainsKey(name) || return (this.Attributes.ContainsKey(name) || this.CustomAttributes.ContainsKey(name) ||
(_styles.TryGetValue(name, out rules) && (rules.ContainsKey(StyleSpecificity_InlineStyle) || rules.ContainsKey(StyleSpecificity_PresAttribute)))); (_styles != null && _styles.TryGetValue(name, out rules)) && (rules.ContainsKey(StyleSpecificity_InlineStyle) || rules.ContainsKey(StyleSpecificity_PresAttribute)));
} }
public bool TryGetAttribute(string name, out string value) public bool TryGetAttribute(string name, out string value)
{ {
...@@ -89,7 +89,7 @@ namespace Svg ...@@ -89,7 +89,7 @@ namespace Svg
} }
if (this.CustomAttributes.TryGetValue(name, out value)) return true; if (this.CustomAttributes.TryGetValue(name, out value)) return true;
SortedDictionary<int, string> rules; SortedDictionary<int, string> rules;
if (_styles.TryGetValue(name, out rules)) if (_styles != null && _styles.TryGetValue(name, out rules))
{ {
// Get staged styles that are // Get staged styles that are
if (rules.TryGetValue(StyleSpecificity_InlineStyle, out value)) return true; if (rules.TryGetValue(StyleSpecificity_InlineStyle, out value)) return true;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment