using System;
namespace Gaf.Utils
{
class Converter
{
public static string FromDotNetTypeToCSharpType( string strDotNetTypeString )
{
string strConvertedType = strDotNetTypeString;
#region DefineTheConvertedType
//<source>http://msdn.microsoft.com/en-us/library/ya5y69ds.aspx</source>
//<source>http://ysgitdiary.blogspot.com/2010/02/c-types-vs-net-types-code-generation.html</source>
switch (strDotNetTypeString)
{
case "System.Boolean":
strConvertedType = "bool";
break;
case "System.Byte":
strConvertedType = "byte";
break;
case "System.SByte":
strConvertedType = "sbyte";
break;
case "System.Char":
strConvertedType = "char";
break;
case "System.Decimal":
strConvertedType = "decimal";
break;
case "System.Double":
strConvertedType = "double";
break;
case "System.Single":
strConvertedType = "float";
break;
case "System.Int32":
strConvertedType = "int";
break;
case "System.UInt32":
strConvertedType = "uint";
break;
case "System.Int64":
strConvertedType = "long";
break;
case "System.UInt64":
strConvertedType = "ulong";
break;
case "System.Object":
strConvertedType = "object";
break;
case "System.Int16":
strConvertedType = "short";
break;
case "System.UInt16":
strConvertedType = "ushort";
break;
case "System.String":
strConvertedType = "string";
break;
}//eof switch
return strDotNetTypeString;
#endregion DefineTheConvertedType
} //eof method
public static string FromDotNetTypeToConvertToDotNetTypeCode(string strDotNetTypeString)
{
string strConvertTo = strDotNetTypeString;
#region DefineTheConvertedType
//<source>http://msdn.microsoft.com/en-us/library/ya5y69ds.aspx</source>
//<source>http://ysgitdiary.blogspot.com/2010/02/c-types-vs-net-types-code-generation.html</source>
switch (strDotNetTypeString)
{
case "System.Boolean":
strConvertTo = "System.Convert.ToBoolean";
break;
case "System.Byte":
strConvertTo = "System.Convert.ToByte";
break;
case "System.SByte":
strConvertTo = "System.Convert.ToSByte";
break;
case "System.Char":
strConvertTo = "System.Convert.ToChar";
break;
case "System.Decimal":
strConvertTo = "System.Convert.ToDecimal";
break;
case "System.Double":
strConvertTo = "System.Convert.ToDouble";
break;
case "System.Single":
strConvertTo = "System.Convert.ToSingle";
break;
case "System.Int32":
strConvertTo = "System.Convert.ToInt32";
break;
case "System.UInt32":
strConvertTo = "System.Convert.ToUInt32";
break;
case "System.Int64":
strConvertTo = "System.Convert.ToInt64";
break;
case "System.UInt64":
strConvertTo = "System.Convert.ToUInt64";
break;
case "System.Object":
strConvertTo = "System.Convert.ToObject";
break;
case "System.Int16":
strConvertTo = "System.Convert.ToInt16";
break;
case "System.UInt16":
strConvertTo = "System.Convert.ToUInt16";
break;
case "System.String":
strConvertTo = "System.Convert.ToString";
break;
}//eof switch
return strDotNetTypeString;
#endregion DefineTheConvertedType
} //eof method
} //eof class
} //eof
No comments:
Post a Comment
- the first minus - Comments have to be moderated because of the spammers
- the second minus - I am very lazy at moderating comments ... hardly find time ...
- the third minus - Short links are no good for security ...
- The REAL PLUS : Any critic and positive feedback is better than none, so your comments will be published sooner or later !!!!