internal string GetSchemaTypeName(bool applyNetObjectProxy, ref bool requiresBclImport) { Type type = ItemType; if (type == null) { type = MemberType; } return(model.GetSchemaTypeName(type, DataFormat, applyNetObjectProxy && asReference, applyNetObjectProxy && dynamicType, ref requiresBclImport)); }
public static string ExtractGenericTypeName(Type type, RuntimeTypeModel model) { string typeName = type.Name; StringBuilder sb = new StringBuilder(typeName); int split = typeName.IndexOf('`'); if (split >= 0) { sb.Length = split; } sb.Append('<'); var genericArguments = type #if WINRT || COREFX || PROFILE259 .GetTypeInfo().GenericTypeArguments #else .GetGenericArguments() #endif ; for (int i = 0; i < genericArguments.Length; i++) { var arg = genericArguments[i]; Type tmp = arg; int key = model.GetKey(ref tmp); MetaType mt; if (key >= 0 && (mt = model[tmp]) != null && !mt.HasSurrogate) // <=== need to exclude surrogate to avoid chance of infinite loop { sb.Append(mt.GetSchemaTypeName()); } else { if (tmp #if WINRT || COREFX || PROFILE259 .GetTypeInfo() #endif .IsGenericType) { // Nested generic type. string result = TTDUtils.ExtractGenericTypeName(tmp, model); sb.Append(result); } else { RuntimeTypeModel.CommonImports ci = RuntimeTypeModel.CommonImports.None; sb.Append(model.GetSchemaTypeName(tmp, DataFormat.Default, false, false, ref ci)); } } if (i != (genericArguments.Length - 1)) { sb.Append(','); } } sb.Append('>'); return(sb.ToString()); }