public string GetFullName(TypeMap typeMap) { if (!string.IsNullOrEmpty(_fullName)) { return(_fullName); } if (!IsGeneric) { _fullName = this.ToString(); } else { StringBuilder sb = new StringBuilder(); sb.Append(this.ToString()).Append("<"); bool isFirst = true; foreach (ushort s in GenericArguments) { if (!isFirst) { sb.Append(","); } else { isFirst = false; } BinaryTypeInfo ti = typeMap.GetTypeInfo(s); sb.Append(ti.GetFullName(typeMap)); } sb.Append(">"); _fullName = sb.ToString(); } return(_fullName); }
//public BinaryTypeInfo PrimaryTypeInfo //{ // get // { // return GetTypeInfo(0); // } //} internal string GetTypeName(ushort seq) { BinaryTypeInfo ti = GetTypeInfo(seq); if (ti == null) { return(null); } return(ti.GetFullName(this)); }
public override bool TryResolveType(TypeMap typeMap, BinaryTypeInfo typeInfo, out Type type) { type = null; if (typeInfo.Type == TypeEnum.None) { return(true); } if (string.IsNullOrEmpty(typeInfo.FullName) && _internalTypeMaps.ContainsKey(typeInfo.Type)) { type = _internalTypeMaps[typeInfo.Type]; } if (type == null || type.IsGenericType) { string typeName = typeInfo.GetFullName(typeMap); Type tmp = type; type = _typeNameMaps.GetOrAdd(typeName, (tn) => { if (typeInfo.Type == TypeEnum.Array) { TryResolveType(typeMap, typeMap.GetTypeInfo(typeInfo.GenericArguments[0]), out Type elementType); if (elementType != null) { return(elementType.MakeArrayType()); } return(null); } else if (typeInfo.Type == TypeEnum.Tuple || typeInfo.Type == TypeEnum.ValueTuple) { tmp = GetTupleType(typeInfo); } // 从fullName获取Type Type t = tmp ?? ParseType(typeInfo.FullName); if (t != null) { t = CreateGenericType(typeMap, t, typeInfo); } return(t); }); } if (type != null) { return(true); } return(false); }