当前位置: 首页>>代码示例>>C#>>正文


C# TypeKind.ToString方法代码示例

本文整理汇总了C#中TypeKind.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# TypeKind.ToString方法的具体用法?C# TypeKind.ToString怎么用?C# TypeKind.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TypeKind的用法示例。


在下文中一共展示了TypeKind.ToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ToString

        public static string ToString(TypeKind typeKind, object value)
        {
            switch (typeKind)
            {
                case TypeKind.String:
                    return (string)value;
                case TypeKind.IgnoreCaseString:
                    return ((IgnoreCaseString)value).Value;
                case TypeKind.Char:
                    return ((char)value).ToString();
                case TypeKind.Decimal:
                    return ((decimal)value).ToInvString();
                case TypeKind.Int64:
                    return ((long)value).ToInvString();
                case TypeKind.Int32:
                    return ((int)value).ToInvString();
                case TypeKind.Int16:
                    return ((short)value).ToInvString();
                case TypeKind.SByte:
                    return ((sbyte)value).ToInvString();
                case TypeKind.UInt64:
                    return ((ulong)value).ToInvString();
                case TypeKind.UInt32:
                    return ((uint)value).ToInvString();
                case TypeKind.UInt16:
                    return ((ushort)value).ToInvString();
                case TypeKind.Byte:
                    return ((byte)value).ToInvString();
                case TypeKind.Double:
                    {
                        bool isLiteral;
                        return ((double)value).ToInvString(out isLiteral);
                    }
                case TypeKind.Single:
                    {
                        bool isLiteral;
                        return ((float)value).ToInvString(out isLiteral);
                    }
                case TypeKind.Boolean:
                    return ((bool)value).ToInvString();
                case TypeKind.Binary:
                    return ((Binary)value).ToBase64String();
                case TypeKind.Guid:
                    return ((Guid)value).ToInvString();
                case TypeKind.TimeSpan:
                    return ((TimeSpan)value).ToInvString();
                case TypeKind.DateTimeOffset:
                    return ((DateTimeOffset)value).ToInvString();

                default:
                    throw new ArgumentException("Invalid type kind: " + typeKind.ToString());
            }
        }
开发者ID:knat,项目名称:SData,代码行数:53,代码来源:AtomExtensions.cs

示例2: TryParse


//.........这里部分代码省略.........
                            return r;
                        }
                    }
                    break;
                case TypeKind.UInt32:
                    {
                        uint r;
                        if (s.TryInvParse(out r))
                        {
                            return r;
                        }
                    }
                    break;
                case TypeKind.UInt16:
                    {
                        ushort r;
                        if (s.TryInvParse(out r))
                        {
                            return r;
                        }
                    }
                    break;
                case TypeKind.Byte:
                    {
                        byte r;
                        if (s.TryInvParse(out r))
                        {
                            return r;
                        }
                    }
                    break;
                case TypeKind.Double:
                    {
                        double r;
                        if (s.TryInvParse(out r))
                        {
                            return r;
                        }
                    }
                    break;
                case TypeKind.Single:
                    {
                        float r;
                        if (s.TryInvParse(out r))
                        {
                            return r;
                        }
                    }
                    break;
                case TypeKind.Boolean:
                    {
                        bool r;
                        if (s.TryInvParse(out r))
                        {
                            return r;
                        }
                    }
                    break;
                case TypeKind.Binary:
                    {
                        Binary r;
                        if (Binary.TryFromBase64String(s, out r, isReadOnly))
                        {
                            return r;
                        }
                    }
                    break;
                case TypeKind.Guid:
                    {
                        Guid r;
                        if (s.TryInvParse(out r))
                        {
                            return r;
                        }
                    }
                    break;
                case TypeKind.TimeSpan:
                    {
                        TimeSpan r;
                        if (s.TryInvParse(out r))
                        {
                            return r;
                        }
                    }
                    break;
                case TypeKind.DateTimeOffset:
                    {
                        DateTimeOffset r;
                        if (s.TryInvParse(out r))
                        {
                            return r;
                        }
                    }
                    break;

                default:
                    throw new ArgumentException("Invalid type kind: " + typeKind.ToString());
            }
            return null;
        }
开发者ID:knat,项目名称:SData,代码行数:101,代码来源:AtomExtensions.cs

示例3: GetFullName

 public static FullName GetFullName(TypeKind kind)
 {
     return new FullName(Extensions.SystemUri, kind.ToString());
 }
开发者ID:knat,项目名称:SData,代码行数:4,代码来源:AtomExtensionsEx.cs

示例4: TypeIsScalar

        private bool TypeIsScalar(TypeKind kind)
        {
            switch (kind)
            {
                case TypeKind.Array:
                case TypeKind.Class:
                case TypeKind.Data:
                case TypeKind.None:
                case TypeKind.Object:
                case TypeKind.Record:
                case TypeKind.Text:
                    return false;

                case TypeKind.Address:
                case TypeKind.Bitset:
                case TypeKind.Cardinal:
                case TypeKind.Cardinal1:
                case TypeKind.Cardinal2:
                case TypeKind.Cardinal4:
                case TypeKind.Cardinal8:
                case TypeKind.Cardinal16:
                case TypeKind.Character:
                case TypeKind.Enumeration:
                case TypeKind.Integer:
                case TypeKind.Integer1:
                case TypeKind.Integer2:
                case TypeKind.Integer4:
                case TypeKind.Integer8:
                case TypeKind.Integer16:
                case TypeKind.Real32:
                case TypeKind.Real64:
                    return true;

                case TypeKind.Unknown:
                default:
                    throw new System.ArgumentException("Unexpected or unknown type: " + kind.ToString());
            }
        }
开发者ID:archfrog,项目名称:Braceless0,代码行数:38,代码来源:Writer.cs

示例5: Literal

 internal static ExpressionSyntax Literal(TypeKind value)
 {
     return CS.MemberAccessExpr(CS.MemberAccessExpr(SDataName, "TypeKind"), value.ToString());
 }
开发者ID:knat,项目名称:SData,代码行数:4,代码来源:CSEX.cs

示例6: IsAtomType

 internal static bool IsAtomType(TypeKind typeKind, ITypeSymbol typeSymbol)
 {
     switch (typeKind)
     {
         case TypeKind.String:
             return typeSymbol.SpecialType == SpecialType.System_String;
         case TypeKind.IgnoreCaseString:
             return typeSymbol.FullNameEquals(IgnoreCaseStringNameParts);
         case TypeKind.Char:
             return typeSymbol.SpecialType == SpecialType.System_Char;
         case TypeKind.Decimal:
             return typeSymbol.SpecialType == SpecialType.System_Decimal;
         case TypeKind.Int64:
             return typeSymbol.SpecialType == SpecialType.System_Int64;
         case TypeKind.Int32:
             return typeSymbol.SpecialType == SpecialType.System_Int32;
         case TypeKind.Int16:
             return typeSymbol.SpecialType == SpecialType.System_Int16;
         case TypeKind.SByte:
             return typeSymbol.SpecialType == SpecialType.System_SByte;
         case TypeKind.UInt64:
             return typeSymbol.SpecialType == SpecialType.System_UInt64;
         case TypeKind.UInt32:
             return typeSymbol.SpecialType == SpecialType.System_UInt32;
         case TypeKind.UInt16:
             return typeSymbol.SpecialType == SpecialType.System_UInt16;
         case TypeKind.Byte:
             return typeSymbol.SpecialType == SpecialType.System_Byte;
         case TypeKind.Double:
             return typeSymbol.SpecialType == SpecialType.System_Double;
         case TypeKind.Single:
             return typeSymbol.SpecialType == SpecialType.System_Single;
         case TypeKind.Boolean:
             return typeSymbol.SpecialType == SpecialType.System_Boolean;
         case TypeKind.Binary:
             return typeSymbol.FullNameEquals(BinaryNameParts);
         case TypeKind.Guid:
             return typeSymbol.FullNameEquals(CS.GuidNameParts);
         case TypeKind.TimeSpan:
             return typeSymbol.FullNameEquals(CS.TimeSpanNameParts);
         case TypeKind.DateTimeOffset:
             return typeSymbol.FullNameEquals(CS.DateTimeOffsetNameParts);
         default:
             throw new ArgumentException("Invalid type kind: " + typeKind.ToString());
     }
 }
开发者ID:knat,项目名称:SData,代码行数:46,代码来源:CSEX.cs

示例7: AtomValueLiteral

 internal static ExpressionSyntax AtomValueLiteral(TypeKind typeKind, object value)
 {
     switch (typeKind)
     {
         case TypeKind.String:
             return CS.Literal((string)value);
         case TypeKind.IgnoreCaseString:
             return Literal((IgnoreCaseString)value);
         case TypeKind.Char:
             return CS.Literal((char)value);
         case TypeKind.Decimal:
             return CS.Literal((decimal)value);
         case TypeKind.Int64:
             return CS.Literal((long)value);
         case TypeKind.Int32:
             return CS.Literal((int)value);
         case TypeKind.Int16:
             return CS.Literal((short)value);
         case TypeKind.SByte:
             return CS.Literal((sbyte)value);
         case TypeKind.UInt64:
             return CS.Literal((ulong)value);
         case TypeKind.UInt32:
             return CS.Literal((uint)value);
         case TypeKind.UInt16:
             return CS.Literal((ushort)value);
         case TypeKind.Byte:
             return CS.Literal((byte)value);
         case TypeKind.Double:
             return CS.Literal((double)value);
         case TypeKind.Single:
             return CS.Literal((float)value);
         case TypeKind.Boolean:
             return CS.Literal((bool)value);
         case TypeKind.Binary:
             return Literal((Binary)value);
         case TypeKind.Guid:
             return CS.Literal((Guid)value); ;
         case TypeKind.TimeSpan:
             return CS.Literal((TimeSpan)value); ;
         case TypeKind.DateTimeOffset:
             return CS.Literal((DateTimeOffset)value); ;
         default:
             throw new ArgumentException("Invalid type kind: " + typeKind.ToString());
     }
 }
开发者ID:knat,项目名称:SData,代码行数:46,代码来源:CSEX.cs


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