internal static IElement ConstructElementType(XmlElement element, XmlPrefixMap map, AElement parent) { Type t = null; if (BusinessProcess.ElementMapCache != null) { if (BusinessProcess.ElementMapCache.IsCached(element.Name)) { t = BusinessProcess.ElementMapCache[element.Name]; } else { t = Utility.LocateElementType((parent == null ? null : parent.GetType()), element.Name, map); BusinessProcess.ElementMapCache[element.Name] = t; } } else { t = Utility.LocateElementType((parent == null ? null : parent.GetType()), element.Name, map); } if (t != null) { return((IElement)_xmlConstructors[t].Invoke(new object[] { element, map, parent })); } return(null); }
public void MapIdeals(XmlPrefixMap map) { Dictionary <string, Dictionary <string, Type> > ideals = Utility.IdealMap; foreach (string prefix in ideals.Keys) { List <string> tmp = map.Translate(prefix); if (tmp.Count > 0) { foreach (string trans in tmp) { foreach (string tag in ideals[prefix].Keys) { if (!_cachedMaps.ContainsKey(string.Format("{0}:{1}", trans, tag))) { _cachedMaps.Add(string.Format("{0}:{1}", trans, tag), ideals[prefix][tag]); } } } } else { foreach (String tag in ideals[prefix].Keys) { _cachedMaps.Add(string.Format("{0}:{1}", prefix, tag), ideals[prefix][tag]); _cachedMaps.Add(tag, ideals[prefix][tag]); } } } }
public static Type LocateElementType(Type parent, string tagName, XmlPrefixMap map) { DateTime start = DateTime.Now; Type ret = null; if (parent != null) { if (_xmlChildren.ContainsKey(parent)) { foreach (Type t in _xmlChildren[parent]) { foreach (XMLTag xt in _tagAttributes[t]) { if (xt.Matches(map, tagName)) { ret = t; break; } } if (ret != null) { break; } } } } foreach (Type t in _globalXMLChildren) { foreach (XMLTag xt in _tagAttributes[t]) { if (xt.Matches(map, tagName)) { ret = t; break; } } if (ret != null) { break; } } //Console.WriteLine("Time to translate [{0}] to [{1}] is {2}ms", new object[] { tagName, (ret == null ? null : ret.FullName), DateTime.Now.Subtract(start).TotalMilliseconds }); return(ret); }
public static Type LocateElementType(Type parent, string tagName, XmlPrefixMap map) { Type ret = null; if (parent != null) { if (_xmlChildren.ContainsKey(parent)) { foreach (Type t in _xmlChildren[parent]) { foreach (XMLTag xt in t.GetCustomAttributes(typeof(XMLTag), false)) { if (xt.Matches(map, tagName)) { ret = t; break; } } if (ret != null) { break; } } } } foreach (Type t in _globalXMLChildren) { foreach (XMLTag xt in t.GetCustomAttributes(typeof(XMLTag), false)) { if (xt.Matches(map, tagName)) { ret = t; break; } } if (ret != null) { break; } } return(ret); }