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


C# IEdmPrimitiveTypeReference.AsString方法代码示例

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


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

示例1: ConvertToTaupoPrimitiveDataType

        public static DataType ConvertToTaupoPrimitiveDataType(IEdmPrimitiveTypeReference edmPrimitiveTypeReference)
        {
            PrimitiveDataType result = null;
            EdmPrimitiveTypeKind primitiveKind = edmPrimitiveTypeReference.PrimitiveKind();
            if (!facetlessDataTypeLookup.TryGetValue(primitiveKind, out result))
            {
                switch (primitiveKind)
                {
                    case EdmPrimitiveTypeKind.Binary:
                        var edmBinary = edmPrimitiveTypeReference.AsBinary();
                        result = EdmDataTypes.Binary(edmBinary.MaxLength);
                        break;

                    case EdmPrimitiveTypeKind.DateTimeOffset:
                        var edmDateTimeOffset = edmPrimitiveTypeReference.AsTemporal();
                        result = EdmDataTypes.DateTimeOffset(edmDateTimeOffset.Precision);
                        break;

                    case EdmPrimitiveTypeKind.Decimal:
                        var edmDecimal = edmPrimitiveTypeReference.AsDecimal();
                        result = EdmDataTypes.Decimal(edmDecimal.Precision, edmDecimal.Scale);
                        break;

                    case EdmPrimitiveTypeKind.String:
                        var edmString = edmPrimitiveTypeReference.AsString();
                        var maxLength = edmString.MaxLength;
                        if (edmString.IsUnbounded == true)
                        {
                            maxLength = MaxLengthMaxTaupoDefaultValue; 
                        }

                        result = EdmDataTypes.String(maxLength, edmString.IsUnicode);
                        break;

                    case EdmPrimitiveTypeKind.Duration:
                        var edmTime = edmPrimitiveTypeReference.AsTemporal();
                        result = EdmDataTypes.Time(edmTime.Precision);
                        break;

                    default:
                        throw new TaupoInvalidOperationException("unexpected Edm Primitive Type Kind: " + primitiveKind);
                }
            }

            return result.Nullable(edmPrimitiveTypeReference.IsNullable);
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:46,代码来源:EdmToTaupoPrimitiveDataTypeConverter.cs

示例2: AppendFacets

 private static void AppendFacets(this StringBuilder sb, IEdmPrimitiveTypeReference type)
 {
     switch (type.PrimitiveKind())
     {
         case EdmPrimitiveTypeKind.Binary:
             sb.AppendBinaryFacets(type.AsBinary());
             break;
         case EdmPrimitiveTypeKind.Decimal:
             sb.AppendDecimalFacets(type.AsDecimal());
             break;
         case EdmPrimitiveTypeKind.String:
             sb.AppendStringFacets(type.AsString());
             break;
         case EdmPrimitiveTypeKind.Time:
         case EdmPrimitiveTypeKind.DateTime:
         case EdmPrimitiveTypeKind.DateTimeOffset:
             sb.AppendTemporalFacets(type.AsTemporal());
             break;
         case EdmPrimitiveTypeKind.Geography:
         case EdmPrimitiveTypeKind.GeographyPoint:
         case EdmPrimitiveTypeKind.GeographyLineString:
         case EdmPrimitiveTypeKind.GeographyPolygon:
         case EdmPrimitiveTypeKind.GeographyCollection:
         case EdmPrimitiveTypeKind.GeographyMultiPolygon:
         case EdmPrimitiveTypeKind.GeographyMultiLineString:
         case EdmPrimitiveTypeKind.GeographyMultiPoint:
         case EdmPrimitiveTypeKind.Geometry:
         case EdmPrimitiveTypeKind.GeometryPoint:
         case EdmPrimitiveTypeKind.GeometryLineString:
         case EdmPrimitiveTypeKind.GeometryPolygon:
         case EdmPrimitiveTypeKind.GeometryCollection:
         case EdmPrimitiveTypeKind.GeometryMultiPolygon:
         case EdmPrimitiveTypeKind.GeometryMultiLineString:
         case EdmPrimitiveTypeKind.GeometryMultiPoint:
             sb.AppendSpatialFacets(type.AsSpatial());
             break;
     }
 }
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:38,代码来源:ToTraceStringExtensionMethods.cs

示例3: AppendFacets

		private static void AppendFacets(this StringBuilder sb, IEdmPrimitiveTypeReference type)
		{
			EdmPrimitiveTypeKind edmPrimitiveTypeKind = type.PrimitiveKind();
			switch (edmPrimitiveTypeKind)
			{
				case EdmPrimitiveTypeKind.Binary:
				{
					sb.AppendBinaryFacets(type.AsBinary());
					return;
				}
				case EdmPrimitiveTypeKind.Boolean:
				case EdmPrimitiveTypeKind.Byte:
				case EdmPrimitiveTypeKind.Double:
				case EdmPrimitiveTypeKind.Guid:
				case EdmPrimitiveTypeKind.Int16:
				case EdmPrimitiveTypeKind.Int32:
				case EdmPrimitiveTypeKind.Int64:
				case EdmPrimitiveTypeKind.SByte:
				case EdmPrimitiveTypeKind.Single:
				case EdmPrimitiveTypeKind.Stream:
				{
					return;
				}
				case EdmPrimitiveTypeKind.DateTime:
				case EdmPrimitiveTypeKind.DateTimeOffset:
				case EdmPrimitiveTypeKind.Time:
				{
					sb.AppendTemporalFacets(type.AsTemporal());
					return;
				}
				case EdmPrimitiveTypeKind.Decimal:
				{
					sb.AppendDecimalFacets(type.AsDecimal());
					return;
				}
				case EdmPrimitiveTypeKind.String:
				{
					sb.AppendStringFacets(type.AsString());
					return;
				}
				case EdmPrimitiveTypeKind.Geography:
				case EdmPrimitiveTypeKind.GeographyPoint:
				case EdmPrimitiveTypeKind.GeographyLineString:
				case EdmPrimitiveTypeKind.GeographyPolygon:
				case EdmPrimitiveTypeKind.GeographyCollection:
				case EdmPrimitiveTypeKind.GeographyMultiPolygon:
				case EdmPrimitiveTypeKind.GeographyMultiLineString:
				case EdmPrimitiveTypeKind.GeographyMultiPoint:
				case EdmPrimitiveTypeKind.Geometry:
				case EdmPrimitiveTypeKind.GeometryPoint:
				case EdmPrimitiveTypeKind.GeometryLineString:
				case EdmPrimitiveTypeKind.GeometryPolygon:
				case EdmPrimitiveTypeKind.GeometryCollection:
				case EdmPrimitiveTypeKind.GeometryMultiPolygon:
				case EdmPrimitiveTypeKind.GeometryMultiLineString:
				case EdmPrimitiveTypeKind.GeometryMultiPoint:
				{
					sb.AppendSpatialFacets(type.AsSpatial());
					return;
				}
				default:
				{
					return;
				}
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:66,代码来源:ToTraceStringExtensionMethods.cs


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