internal string GetTypeName(Type symType, bool useSimplifiedNamespaces)
{
if (symType == null)
{
return null;
}
if ((symType.IsGenericType) &&
(symType.Namespace == "System") &&
(symType.GetGenericArguments().Length == 1))
{
if (symType == typeof(bool?))
{
return "bool?";
}
if (symType == typeof(sbyte?))
{
return "sbyte?";
}
if (symType == typeof(byte?))
{
return "byte?";
}
if (symType == typeof(char?))
{
return "char?";
}
if (symType == typeof(short?))
{
return "short?";
}
if (symType == typeof(ushort?))
{
return "ushort?";
}
if (symType == typeof(int?))
{
return "int?";
}
if (symType == typeof(uint?))
{
return "uint?";
}
if (symType == typeof(long?))
{
return "long?";
}
if (symType == typeof(ulong?))
{
return "ulong?";
}
if (symType == typeof(float?))
{
return "float?";
}
if (symType == typeof(double?))
{
return "double?";
}
if (symType == typeof(decimal?))
{
return "decimal?";
}
if ((symType == typeof(Guid?)) ||
(symType == typeof(DateTime?)))
{
return GetTypeName(symType.GetGenericArguments()[0],
useSimplifiedNamespaces) + "?";
}
}
string symTypeName;
using (StringWriter stringWriter = new StringWriter())
{
gen.GenerateCodeFromExpression(new System.CodeDom.
CodeTypeReferenceExpression(symType), stringWriter, null);
symTypeName = stringWriter.ToString();
}
if (useSimplifiedNamespaces)
{
foreach (string namespacePrefix in new string[]
{
"System.Collections.Generic.",
"System.Collections.",
"System."
})
{
symTypeName = symTypeName.Replace(namespacePrefix, "");
}
}
return symTypeName;
}