object ConvertValue(object value) { if (value is TypeReference tr) { return(TypeSystem.GetTypeFor(tr)); } return(value); }
public IXamlType MakeGenericType(IReadOnlyList <IXamlType> typeArguments) { if (Reference == Definition) { var i = Definition.MakeGenericInstanceType(typeArguments.Cast <ITypeReference>().Select(r => r.Reference) .ToArray()); return(TypeSystem.GetTypeFor(i)); } throw new InvalidOperationException(); }
public IXamlIlType FindType(string fullName) { if (_typeCache.TryGetValue(fullName, out var rv)) { return(rv); } var lastDot = fullName.LastIndexOf(".", StringComparison.Ordinal); var asmRef = new AssemblyNameReference(Assembly.Name.Name, Assembly.Name.Version); var tref = (lastDot == -1) ? new TypeReference(null, fullName, Assembly.MainModule, asmRef) : new TypeReference(fullName.Substring(0, lastDot), fullName.Substring(lastDot + 1), Assembly.MainModule, asmRef); var resolved = tref.Resolve(); if (resolved != null) { return(_typeCache[fullName] = TypeSystem.GetTypeFor(resolved)); } return(null); }