Dictionary<string,string> ProcessAttributes (XmlReader r, List<Pair> members)
{
var l = members;
// base (top element)
if (!xmlbase_done) {
xmlbase_done = true;
string xmlbase = r.GetAttribute ("base", XamlLanguage.Xml1998Namespace) ?? r.BaseURI;
if (xmlbase != null)
l.Add (new Pair (XamlLanguage.Base, xmlbase));
}
var atts = new Dictionary<string,string> ();
if (r.MoveToFirstAttribute ()) {
do {
switch (r.NamespaceURI) {
case XamlLanguage.Xml1998Namespace:
switch (r.LocalName) {
case "base":
continue; // already processed.
case "lang":
l.Add (new Pair (XamlLanguage.Lang, r.Value));
continue;
case "space":
l.Add (new Pair (XamlLanguage.Space, r.Value));
continue;
}
break;
case XamlLanguage.Xmlns2000Namespace:
continue;
case XamlLanguage.Xaml2006Namespace:
XamlDirective d = FindStandardDirective (r.LocalName, AllowedMemberLocations.Attribute);
if (d != null) {
l.Add (new Pair (d, r.Value));
//atts.Add(d,r.Value);
continue;
}
throw new NotSupportedException (String.Format ("Attribute '{0}' is not supported", r.Name));
default:
if (r.NamespaceURI == String.Empty) {
atts.Add (r.Name, r.Value);
continue;
}
// Should we just ignore unknown attribute in XAML namespace or any other namespaces ?
// Probably yes for compatibility with future version.
break;
}
} while (r.MoveToNextAttribute ());
r.MoveToElement ();
}
return atts;
}