Add more system type aliases

This commit is contained in:
Antony Male 2014-07-21 10:53:06 +01:00
parent 96fdcd3e3c
commit 95f0f8b3e4
1 changed files with 8 additions and 1 deletions

View File

@ -583,13 +583,18 @@ namespace StyletIoC
private static readonly Dictionary<Type, string> primitiveNameMapping = new Dictionary<Type, string>() private static readonly Dictionary<Type, string> primitiveNameMapping = new Dictionary<Type, string>()
{ {
{ typeof(byte), "byte" },
{ typeof(sbyte), "sbyte" },
{ typeof(char), "char" },
{ typeof(short), "short" },
{ typeof(ushort), "ushort" },
{ typeof(int), "int" }, { typeof(int), "int" },
{ typeof(uint), "uint" }, { typeof(uint), "uint" },
{ typeof(long), "long" }, { typeof(long), "long" },
{ typeof(ulong), "ulong" }, { typeof(ulong), "ulong" },
{ typeof(byte), "byte" },
{ typeof(float), "float" }, { typeof(float), "float" },
{ typeof(double), "double" }, { typeof(double), "double" },
{ typeof(decimal), "decimal" },
{ typeof(bool), "bool" }, { typeof(bool), "bool" },
}; };
@ -599,11 +604,13 @@ namespace StyletIoC
return String.Format("{0}<{1}>", type.Name.Split('`')[0], String.Join(", ", type.GetTypeInfo().GenericTypeParameters.Select(x => x.Name))); return String.Format("{0}<{1}>", type.Name.Split('`')[0], String.Join(", ", type.GetTypeInfo().GenericTypeParameters.Select(x => x.Name)));
var genericArguments = type.GetGenericArguments(); var genericArguments = type.GetGenericArguments();
if (genericArguments.Length > 0) if (genericArguments.Length > 0)
{
return String.Format("{0}<{1}>", type.Name.Split('`')[0], String.Join(", ", genericArguments.Select(x => return String.Format("{0}<{1}>", type.Name.Split('`')[0], String.Join(", ", genericArguments.Select(x =>
{ {
string name; string name;
return primitiveNameMapping.TryGetValue(x, out name) ? name : x.Name; return primitiveNameMapping.TryGetValue(x, out name) ? name : x.Name;
}))); })));
}
return type.Name; return type.Name;
} }
} }