CSLE.CLS_Type_Enum.ConvertTo C# (CSharp) Method

ConvertTo() public method

public ConvertTo ( CLS_Content content, object src, CLType targetType ) : object
content CLS_Content
src object
targetType CLType
return object
        public object ConvertTo(CLS_Content content, object src, CLType targetType)
        {
            Type targetSysType = (Type)targetType;

            if (targetSysType.IsEnum)
                return Enum.ToObject(targetSysType, src);
            else if (targetSysType == typeof(int))
                return System.Convert.ToInt32(src);
            else if (targetSysType == typeof(uint))
                return System.Convert.ToUInt32(src);
            else if (targetSysType == typeof(short))
                return System.Convert.ToInt16(src);
            else if (targetSysType == typeof(ushort))
                return System.Convert.ToUInt16(src);
            else if (targetSysType == typeof(long))
                return System.Convert.ToInt64(src);
            else if (targetSysType == typeof(ulong))
                return System.Convert.ToUInt64(src);

            throw new NotImplementedException();
        }