本文整理汇总了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());
}
}
示例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;
}
示例3: GetFullName
public static FullName GetFullName(TypeKind kind)
{
return new FullName(Extensions.SystemUri, kind.ToString());
}
示例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());
}
}
示例5: Literal
internal static ExpressionSyntax Literal(TypeKind value)
{
return CS.MemberAccessExpr(CS.MemberAccessExpr(SDataName, "TypeKind"), value.ToString());
}
示例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());
}
}
示例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());
}
}