• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# TypeCode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中TypeCode的典型用法代码示例。如果您正苦于以下问题:C# TypeCode类的具体用法?C# TypeCode怎么用?C# TypeCode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TypeCode类属于命名空间,在下文中一共展示了TypeCode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: FromTypeCode

        // New function; not in original C++ file
        /// <summary>
        /// Convert system type code to a GDAL data type.
        /// </summary>
        public static DataType FromTypeCode(TypeCode typeCode)
        {
            switch(typeCode)
            {
                case TypeCode.Byte:
                    return DataType.GDT_Byte;

                case TypeCode.Int16:
                    return DataType.GDT_Int16;
                case TypeCode.UInt16:
                    return DataType.GDT_UInt16;

                case TypeCode.Int32:
                    return DataType.GDT_Int32;
                case TypeCode.UInt32:
                    return DataType.GDT_UInt32;

                case TypeCode.Single:
                    return DataType.GDT_Float32;
                case TypeCode.Double:
                    return DataType.GDT_Float64;

                default:
                    return DataType.GDT_Unknown;
            }
        }
开发者ID:LANDIS-II-Foundation,项目名称:Landis-Spatial-Modeling-Library,代码行数:30,代码来源:GdalDataType.cs


示例2: EvaluateNullable

		public static object EvaluateNullable (object a, object b, TypeCode tc, ExpressionType et)
		{
			object o = null;
			if (a == null || b == null) {
				if (tc != TypeCode.Boolean) {
					return null;
				}
				switch (et) {
				case ExpressionType.And:
					o = And (a, b);
					break;
				case ExpressionType.Or:
					o = Or (a, b);
					break;
				case ExpressionType.ExclusiveOr:
					o = ExclusiveOr (a, b);
					break;
				}
			} else {
				o = Evaluate (a, b, tc, et);
			}

			return Convert2Nullable (o, tc);

		}
开发者ID:bvangrinsven,项目名称:db4o-net,代码行数:25,代码来源:Math.cs


示例3: GetNumericConversionOrder

        /// <summary>
        /// Returns a numerical code of the size of a type.  All types get both a horizontal
        /// and vertical code.  Types that are lower in both dimensions have implicit conversions
        /// to types that are higher in both dimensions.
        /// </summary>
        internal static bool GetNumericConversionOrder(TypeCode code, out int x, out int y)
        {
            // implicit conversions:
            //     0     1     2     3     4
            // 0:       U1 -> U2 -> U4 -> U8
            //          |     |     |
            //          v     v     v
            // 1: I1 -> I2 -> I4 -> I8
            //          |     |
            //          v     v
            // 2:       R4 -> R8

            switch (code) {
                case TypeCode.Byte: x = 0; y = 0; break;
                case TypeCode.UInt16: x = 1; y = 0; break;
                case TypeCode.UInt32: x = 2; y = 0; break;
                case TypeCode.UInt64: x = 3; y = 0; break;

                case TypeCode.SByte: x = 0; y = 1; break;
                case TypeCode.Int16: x = 1; y = 1; break;
                case TypeCode.Int32: x = 2; y = 1; break;
                case TypeCode.Int64: x = 3; y = 1; break;

                case TypeCode.Single: x = 1; y = 2; break;
                case TypeCode.Double: x = 2; y = 2; break;

                default:
                    x = y = 0;
                    return false;
            }
            return true;
        }
开发者ID:robertlj,项目名称:IronScheme,代码行数:37,代码来源:TypeUtils.cs


示例4: XmlAtomicValue

        //-----------------------------------------------
        // XmlAtomicValue constructors and methods
        //-----------------------------------------------

        internal XmlAtomicValue(XmlSchemaType xmlType, bool value)
        {
            if (xmlType == null) throw new ArgumentNullException(nameof(xmlType));
            _xmlType = xmlType;
            _clrType = TypeCode.Boolean;
            _unionVal.boolVal = value;
        }
开发者ID:Corillian,项目名称:corefx,代码行数:11,代码来源:XmlAtomicValue.cs


示例5: NumberConversionRule

		/// <param name="typeCode">The <see cref="TypeCode"/> that this <see cref="NumberConversionRule"/> attempts to convert to.</param>
		public NumberConversionRule(TypeCode typeCode)
			: base(TypePointers.StringType)
		{
			if ((typeCode == TypeCode.String) || (typeCode == TypeCode.DateTime))
			{
				throw new ArgumentException("datatype cannot be String or DateTime.", "typeCode");
			}
			TypeCode = typeCode;
			numberFormatInfo = NumberFormatInfo.CurrentInfo;
			switch (typeCode)
			{
				case TypeCode.Decimal:
					NumberStyles = NumberStyles.Number;
					break;
				case TypeCode.Double:
				case TypeCode.Single:
					NumberStyles = NumberStyles.Float | NumberStyles.AllowThousands;
					break;
				case TypeCode.Byte:
				case TypeCode.SByte:
				case TypeCode.Int16:
				case TypeCode.UInt16:
				case TypeCode.Int32:
				case TypeCode.UInt32:
				case TypeCode.Int64:
				case TypeCode.UInt64:
					NumberStyles = NumberStyles.Integer;
					break;
			}
		}
开发者ID:thekindofme,项目名称:.netcf-Validation-Framework,代码行数:31,代码来源:NumberConversionRule.cs


示例6: FunctionSystem

		TypeCode _ReturnTypeCode;	// the return type

		/// <summary>
		/// passed class name, function name, and args for evaluation
		/// </summary>
		public FunctionSystem(string c, string f, IExpr[] a, TypeCode type) 
		{
			_Cls = c;
			_Func = f;
			_Args = a;
			_ReturnTypeCode = type;
		}
开发者ID:mnisl,项目名称:OD,代码行数:12,代码来源:FunctionSystem.cs


示例7: FormatOutput

		/*
		public static string FormatOutput(string valueToFormat,string format,
		                                     string dataType, string nullValue )
		{
			if (String.IsNullOrEmpty(format)) {
				return valueToFormat;
			}
			
			if (String.IsNullOrEmpty(valueToFormat)) {
				return nullValue;
			}
			
			TypeCode typeCode = TypeHelper.TypeCodeFromString(dataType);
			return FormatItem(valueToFormat,format,typeCode,nullValue);                                    
		}
		*/
		
//		private static string FormatItem (string valueToFormat,string format,
//		                         TypeCode typeCode,string nullValue)
		static string FormatItem (string valueToFormat,string format,
		                         TypeCode typeCode)	
		{
			string retValue = String.Empty;
			
			switch (typeCode) {
				case TypeCode.Int16:
				case TypeCode.Int32:
					retValue = FormatIntegers (valueToFormat,format);
					break;
				case TypeCode.DateTime:
					retValue = FormatDate(valueToFormat,format);
					break;
				case TypeCode.Boolean:
					retValue = FormatBool (valueToFormat);
					break;
				case TypeCode.Decimal:
					retValue = FormatDecimal (valueToFormat,format);
					break;
					
				case TypeCode.Double:
				case TypeCode.Single:
					break;
					
				case TypeCode.String:
				case TypeCode.Char:
					retValue = valueToFormat;
					break;
				default:
					retValue = valueToFormat;
					break;
			}
			
			return retValue;
		}
开发者ID:fanyjie,项目名称:SharpDevelop,代码行数:54,代码来源:StandardFormatter.cs


示例8: DataCenterValue

 public DataCenterValue(string name, TypeCode typeCode, object value)
     : this()
 {
     Name = name;
     TypeCode = typeCode;
     Value = value;
 }
开发者ID:gothos-folly,项目名称:TeraDataTools,代码行数:7,代码来源:DataCenterValue.cs


示例9: Translate

 public static OleDbType Translate(TypeCode type)
 {
     switch (type)
     {
         case TypeCode.Char: return OleDbType.WChar;
         case TypeCode.String: return OleDbType.WChar;
         case TypeCode.DateTime: return OleDbType.DBTimeStamp;
         case TypeCode.Decimal: return OleDbType.Decimal;
         case TypeCode.Double: return OleDbType.Double;
         case TypeCode.Byte: return OleDbType.UnsignedTinyInt;
         case TypeCode.Int16: return OleDbType.SmallInt;
         case TypeCode.Int32: return OleDbType.Integer;
         case TypeCode.Int64: return OleDbType.BigInt;
         case TypeCode.UInt16: return OleDbType.UnsignedSmallInt;
         case TypeCode.UInt32: return OleDbType.UnsignedInt;
         case TypeCode.UInt64: return OleDbType.UnsignedBigInt;
         case TypeCode.SByte: return OleDbType.TinyInt;
         case TypeCode.Single: return OleDbType.Single;
         case TypeCode.Boolean: return OleDbType.Boolean;
         case TypeCode.DBNull: return OleDbType.Empty;
         case TypeCode.Empty: return OleDbType.Empty;
         case TypeCode.Object: return OleDbType.Variant;
         default: throw new NotImplementedException("Unknown Data Type");
     }
 }
开发者ID:japj,项目名称:vulcan,代码行数:25,代码来源:OLEDBTypeTranslator.cs


示例10: DataGridViewCustomSorter

 public DataGridViewCustomSorter(DataGridView dgv)
 {
     myDataGridView = dgv;
     mySortTypeCode = Type.GetTypeCode(Type.GetType("System.String"));
     ColumnIndex = 0;
     OrderOfSort = SortOrder.None;
 }
开发者ID:lukepfeiffer10,项目名称:EDDiscovery,代码行数:7,代码来源:DataGridViewSorter.cs


示例11: Convert

 public Object Convert(Object value, TypeCode typeCode) {
     if (value==null) { 
         throw new ArgumentNullException("value");
     }
     Contract.EndContractBlock();
     return System.Convert.ChangeType(value, typeCode, CultureInfo.InvariantCulture); 
 }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:7,代码来源:FormatterConverter.cs


示例12: GetType

        public IType GetType(TypeCode typeCode)
        {
            switch (typeCode) {
            case TypeCode.Empty:
                return GetType(typeof(void));

            case TypeCode.Object:
                return GetType(typeof(object));

            case TypeCode.DBNull:
                return GetType(typeof(DBNull));

            case TypeCode.Boolean:
                return GetType(typeof(bool));

            case TypeCode.Char:
                return GetType(typeof(char));

            case TypeCode.SByte:
                return GetType(typeof(sbyte));

            case TypeCode.Byte:
                return GetType(typeof(byte));

            case TypeCode.Int16:
                return GetType(typeof(short));

            case TypeCode.UInt16:
                return GetType(typeof(ushort));

            case TypeCode.Int32:
                return GetType(typeof(int));

            case TypeCode.UInt32:
                return GetType(typeof(uint));

            case TypeCode.Int64:
                return GetType(typeof(long));

            case TypeCode.UInt64:
                return GetType(typeof(ulong));

            case TypeCode.Single:
                return GetType(typeof(float));

            case TypeCode.Double:
                return GetType(typeof(double));

            case TypeCode.Decimal:
                return GetType(typeof(decimal));

            case TypeCode.DateTime:
                return GetType(typeof(DateTime));

            case TypeCode.String:
                return GetType(typeof(string));
            }

            throw new KeyNotFoundException(typeCode.ToString());
        }
开发者ID:irdc,项目名称:PoundWise,代码行数:60,代码来源:ReflectionTypeProvider.cs


示例13: UnBox

 static double UnBox(object numeric, TypeCode typeCode)
 {
     switch (typeCode)
     {
     case TypeCode.Byte:
         return (double)(Byte) numeric;
     case TypeCode.SByte:
         return (double)(SByte) numeric;
     case TypeCode.UInt16:
         return (double)(UInt16) numeric;
     case TypeCode.UInt32:
         return (double)(UInt32) numeric;
     case TypeCode.UInt64:
         return (double)(UInt64) numeric;
     case TypeCode.Int16:
         return (double)(Int16) numeric;
     case TypeCode.Int32:
         return (double)(Int32) numeric;
     case TypeCode.Int64:
         return (double)(Int64) numeric;
     case TypeCode.Decimal:
         return (double)(Decimal) numeric;
     case TypeCode.Double:
         return (double)(Double) numeric;
     case TypeCode.Single:
         return (double)(Single) numeric;
     }
     throw new InvalidCastException(string.Format("Cannot unbox typecode {0} to double", typeCode));
 }
开发者ID:xytovl,项目名称:RemoteEverything,代码行数:29,代码来源:TypeConverter.cs


示例14: Expression

 internal Expression(ReportDefn r, ReportLink p, String xNode, ExpressionType et) : base(r, p)
 {
     _Source = xNode;
     _Type = TypeCode.Empty;
     _ExpectedType = et;
     _Expr = null;
 }
开发者ID:myersBR,项目名称:My-FyiReporting,代码行数:7,代码来源:Expression.cs


示例15: DataCenterValueRaw

 public DataCenterValueRaw(TypeCode typeCode, ushort key, uint value)
     : this()
 {
     TypeCode = typeCode;
     Key = key;
     _value = value;
 }
开发者ID:anders0913,项目名称:TeraDataTools,代码行数:7,代码来源:DataCenterValueRaw.cs


示例16: RuntimeType

        internal RuntimeType(RuntimeTypeHandle handle)
        {
            this.handle = handle;
            typeStruct = (MetadataTypeStruct*)((uint**)&handle)[0];

            assemblyQualifiedName = Mosa.Runtime.Internal.InitializeMetadataString(typeStruct->Name);    // TODO
            name = Mosa.Runtime.Internal.InitializeMetadataString(typeStruct->Name);                 // TODO
            @namespace = Mosa.Runtime.Internal.InitializeMetadataString(typeStruct->Name);               // TODO
            fullname = Mosa.Runtime.Internal.InitializeMetadataString(typeStruct->Name);

            typeCode = (TypeCode)(typeStruct->Attributes >> 24);
            attributes = (TypeAttributes)(typeStruct->Attributes & 0x00FFFFFF);

            // Declaring Type
            if (typeStruct->DeclaringType != null)
            {
                RuntimeTypeHandle declaringHandle = new RuntimeTypeHandle();
                ((uint**)&declaringHandle)[0] = (uint*)typeStruct->DeclaringType;
                declaringTypeHandle = declaringHandle;
            }

            // Element Type
            if ((*typeStruct).ElementType != null)
            {
                RuntimeTypeHandle elementHandle = new RuntimeTypeHandle();
                ((uint**)&elementHandle)[0] = (uint*)typeStruct->ElementType;
                elementTypeHandle = elementHandle;
            }
        }
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:29,代码来源:RuntimeType.cs


示例17: ConvertType

        public static string ConvertType(TypeCode typeCode)
        {
            switch (typeCode)
            {
                case TypeCode.Boolean:
                    return "Boolean";

                case TypeCode.SByte:
                case TypeCode.Byte:
                case TypeCode.Int16:
                case TypeCode.UInt16:
                case TypeCode.Int32:
                case TypeCode.UInt32:
                case TypeCode.Int64:
                case TypeCode.UInt64:
                case TypeCode.Single:
                case TypeCode.Double:
                case TypeCode.Decimal:
                case TypeCode.DateTime:
                    return "Number";

                case TypeCode.Char:
                case TypeCode.String:
                    return "String";

                case TypeCode.Empty:
                case TypeCode.Object:
                case TypeCode.DBNull:
                default:
                    return "Null";
            }
        }
开发者ID:wapacz,项目名称:DBExtractor,代码行数:32,代码来源:XMLHelper.cs


示例18: GetWireType

        private WireType GetWireType(TypeCode code, DataFormat format, ref Type type, out int modelKey)
        {
            modelKey = -1;
            if (type.IsEnum) return WireType.None;
            switch (code)
            {
                case TypeCode.Int16:
                case TypeCode.Int32:
                case TypeCode.Int64:
                case TypeCode.UInt16:
                case TypeCode.UInt32:
                case TypeCode.UInt64:
                case TypeCode.Boolean:
                case TypeCode.SByte:
                case TypeCode.Byte:
                case TypeCode.Char:
                    return WireType.Variant;
                case TypeCode.Double:
                    return WireType.Fixed64;
                case TypeCode.Single:
                    return WireType.Fixed32;
                case TypeCode.String:
                case TypeCode.DateTime:
                case TypeCode.Decimal:
                    return WireType.String;
            }
            if (type == typeof(byte[]) || type == typeof(TimeSpan)
                || type == typeof(Guid) || type == typeof(Uri)) return WireType.String;

            if ((modelKey = GetKey(ref type)) >= 0)
            {
                return WireType.String;
            }
            return WireType.None;
        }
开发者ID:martindevans,项目名称:DistributedServiceProvider,代码行数:35,代码来源:TypeModel.cs


示例19: Expression

		string _UniqueName;		// unique name of expression; not always created
	
		internal Expression(ReportDefn r, ReportLink p, XmlNode xNode, ExpressionType et) : base(r, p)
		{
			_Source=xNode.InnerText;
			_Type = TypeCode.Empty;
			_ExpectedType = et;
			_Expr = null;
		}
开发者ID:romeroyonatan,项目名称:opendental,代码行数:9,代码来源:Expression.cs


示例20: ConvertToNumeric

        /// <summary>
        /// Convert from value
        /// </summary>
        /// <param name="enumType"></param>
        /// <param name="p"></param>
        /// <param name="numberStyles"></param>
        public static object ConvertToNumeric(TypeCode dataTypeCode, string value, int numberBase)
        {
            Type dataType = FactoryStandardType.Get(dataTypeCode);
            MethodInfo mi = typeof(Convert).GetMethod(NameOfConvertToMethodNumeric(dataTypeCode), new Type[] { typeof(string), typeof(int) });

            return mi.Invoke(dataType, new object[] { value, numberBase });
        }
开发者ID:subha007,项目名称:MiniFileParser,代码行数:13,代码来源:FactoryStandardType.cs



注:本文中的TypeCode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TypeDeclaration类代码示例发布时间:2022-05-24
下一篇:
C# TypeBuilder类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap