本文整理汇总了C#中Microsoft.CSharp.CSharpCodeProvider.GetTypeOutput方法的典型用法代码示例。如果您正苦于以下问题:C# CSharpCodeProvider.GetTypeOutput方法的具体用法?C# CSharpCodeProvider.GetTypeOutput怎么用?C# CSharpCodeProvider.GetTypeOutput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CSharp.CSharpCodeProvider
的用法示例。
在下文中一共展示了CSharpCodeProvider.GetTypeOutput方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FriendlyName
public static string FriendlyName(Type type)
{
using (var provider = new CSharpCodeProvider())
{
var typeRef = new CodeTypeReference(type);
return provider.GetTypeOutput(typeRef);
}
}
示例2: ToReadableString
public static string ToReadableString(this Type type)
{
using (var provider = new CSharpCodeProvider())
{
var typeRef = new CodeTypeReference(type);
return provider.GetTypeOutput(typeRef);
}
}
示例3: GetSimpleName
public static string GetSimpleName(this Type type)
{
var compiler = new CSharpCodeProvider();
var result = compiler.GetTypeOutput(new CodeTypeReference(type));
result = Regex.Replace(result, @"[_A-Za-z0-9]+\.", "");
result = Regex.Replace(result, @"Nullable<(.+?)>", @"$1?");
return result;
}
示例4: GetFriendlyTypeName
public static string GetFriendlyTypeName(Type type)
{
using (var p = new CSharpCodeProvider())
{
var r = new CodeTypeReference(type, CodeTypeReferenceOptions.GenericTypeParameter);
return p.GetTypeOutput(r);
}
}
示例5: GetCSharpTypeName
/// <summary>
/// Returns C# alias for specified <paramref name="type"/> for build-in types.
/// </summary>
public static string GetCSharpTypeName(Type type)
{
Contract.Requires(type != null, "type should not be null.");
Contract.Ensures(Contract.Result<string>() != null);
using (var provider = new CSharpCodeProvider())
{
var typeRef = new CodeTypeReference(type);
return provider.GetTypeOutput(typeRef);
}
}
示例6: GetCsTypeName
public static string GetCsTypeName(this Type type)
{
string result;
using (var provider = new CSharpCodeProvider())
{
var typeRef = new CodeTypeReference(type);
result = provider.GetTypeOutput(typeRef);
}
if (result.StartsWith("System.Nullable<") && result.EndsWith(">"))
result = result.Substring(16, result.Length - 17) + "?";
var dotIndex = result.IndexOf('.');
if (dotIndex > 0)
result = result.Substring(dotIndex + 1);
return result;
}
示例7: GetTypeName
private string GetTypeName(Type type)
{
string typeName;
using (var provider = new CSharpCodeProvider())
{
var typeRef = new CodeTypeReference(type);
typeName = provider.GetTypeOutput(typeRef);
}
return typeName;
}
示例8: ModifyCodeTypeReference
private static CodeTypeReference ModifyCodeTypeReference(CodeTypeReference typeReference, string modifier)
{
using (var provider = new CSharpCodeProvider())
return new CodeTypeReference(modifier + " " + provider.GetTypeOutput(typeReference));
}
示例9: FormatTypeReference
private string FormatTypeReference(Type type)
{
using (var provider = new CSharpCodeProvider())
{
var typeRef = new CodeTypeReference(type);
var typeName = provider.GetTypeOutput(typeRef);
typeName = typeName.Substring(typeName.LastIndexOf('.') + 1);
return typeName;
}
}
示例10: GetSpecialName
private static string GetSpecialName([NotNull] Type type)
{
var compiler = new CSharpCodeProvider();
var typeRef = new CodeTypeReference(type);
return compiler.GetTypeOutput(typeRef);
}