private void HandleRootCreation(ref XamlObject obj, XamlParseContext context) { int nameStart = _current; while ((char.IsLetter(CurrentChar) || CurrentChar == ':') && MoveNext()) { } string typeName = _value.Substring(nameStart, _current - nameStart); string ns = string.Empty; if (typeName.Contains(':')) { var parts = typeName.Split(':'); ns = parts[0]; typeName = parts[1]; } Type extensionType = context.LookupObjectByName(typeName, ns); if (extensionType is null) { throw new Exception(); } obj = new XamlObject(extensionType); }
public Type LookupObjectByName(string objType, string ns) { if (ns == string.Empty) { foreach (var includedNs in _namespaces.Where(n => string.IsNullOrEmpty(n.Name))) { string fullName = string.Format("{0}.{1}", includedNs.ClrNamespace, objType); //Ugly way with assembly name... if (TryLoad(fullName, includedNs.AssemblyName, out var t)) { return(t); } } } else { var xNamespace = _namespaces.FirstOrDefault(n => n.Name == ns); if (xNamespace is not null) { string fullName = string.Format("{0}.{1}", xNamespace.ClrNamespace, objType); if (TryLoad(fullName, xNamespace.AssemblyName, out var t)) { return(t); } } } return(_parent?.LookupObjectByName(objType, ns)); }