internal static void WriteFriendlyName( this TranslationWriter writer, Type type, ITranslationSettings settings) { if (type.FullName == null) { if (type.IsGenericType()) { // A generic open generic parameter Type: writer.WriteGenericTypeName(type, settings); } else { // An open generic parameter Type: writer.WriteToTranslation(type.Name, InterfaceName); } return; } if (type.IsArray) { writer.WriteFriendlyName(type.GetElementType(), settings); writer.WriteToTranslation("[]"); return; } if (!type.IsGenericType()) { var substitutedTypeName = type.GetSubstitutionOrNull(); if (type.IsNested) { writer.WriteFriendlyName(type.DeclaringType, settings); writer.WriteDotToTranslation(); if (!WriteSubstituteToTranslation(substitutedTypeName, writer)) { writer.WriteTypeName(type); } return; } if (WriteSubstituteToTranslation(substitutedTypeName, writer)) { return; } writer.WriteTypeNamespaceIfRequired(type, settings); writer.WriteTypeName(type); return; } Type underlyingNullableType; if ((underlyingNullableType = Nullable.GetUnderlyingType(type)) == null) { writer.WriteGenericTypeName(type, settings); return; } writer.WriteFriendlyName(underlyingNullableType, settings); writer.WriteToTranslation('?'); }
public GenericTypeNameWriter(TranslationWriter writer, ITranslationSettings settings) { _writer = writer; _settings = settings; }