private static Type LookupAncestorType(string ancestorTypeName, ITypeDescriptorContext context) { var parts = ancestorTypeName.Split(':'); if (parts.Length == 0 || parts.Length > 2) { throw new InvalidOperationException("Invalid type name"); } if (parts.Length == 1) { return(context.ResolveType(string.Empty, parts[0])); } else { return(context.ResolveType(parts[0], parts[1])); } }
private Type TryResolveOwnerByName(ITypeDescriptorContext context, string ns, string owner) { if (owner != null) { var result = context.ResolveType(ns, owner); if (result == null) { var name = string.IsNullOrEmpty(ns) ? owner : $"{ns}:{owner}"; throw new XamlLoadException($"Could not find type '{name}'."); } return(result); } return(null); }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { var parser = new SelectorParser((t, ns) => context.ResolveType(ns, t)); return(parser.Parse((string)value)); }