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


C# IEdmTypeReference.IsODataValueType方法代码示例

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


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

示例1: CanPromoteNodeTo

        /// <summary>Promotes the specified expression to the given type if necessary.</summary>
        /// <param name="sourceNodeOrNull">The actual argument node, may be null.</param>
        /// <param name="sourceType">The actual argument type.</param>
        /// <param name="targetType">The required type to promote to.</param>
        /// <returns>True if the <paramref name="sourceType"/> could be promoted; otherwise false.</returns>
        private static bool CanPromoteNodeTo(SingleValueNode sourceNodeOrNull, IEdmTypeReference sourceType, IEdmTypeReference targetType)
        {
            Debug.Assert(targetType != null, "targetType != null");
            Debug.Assert(targetType.IsODataPrimitiveTypeKind(), "Type promotion only supported for primitive types.");

            if (sourceType == null)
            {
                // This indicates that a null literal or an open type has been specified.
                // For either case we can promote to the required target type if it is nullable
                return targetType.IsNullable;
            }

            if (sourceType.IsEquivalentTo(targetType))
            {
                return true;
            }

            if (CanConvertTo(sourceNodeOrNull, sourceType, targetType))
            {
                return true;
            }

            // Allow promotion from nullable<T> to non-nullable by directly accessing underlying value.
            if (sourceType.IsNullable && targetType.IsODataValueType())
            {
                // COMPAT 40: Type promotion in the product allows promotion from a nullable type to arbitrary value types
                IEdmTypeReference nonNullableSourceType = sourceType.Definition.ToTypeReference(false);
                if (CanConvertTo(sourceNodeOrNull, nonNullableSourceType, targetType))
                {
                    return true;
                }
            }

            return false;
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:40,代码来源:TypePromotionUtils.cs

示例2: ValidateMetadataPrimitiveType

 internal static void ValidateMetadataPrimitiveType(IEdmTypeReference expectedTypeReference, IEdmTypeReference typeReferenceFromValue)
 {
     IEdmPrimitiveType definition = (IEdmPrimitiveType) expectedTypeReference.Definition;
     IEdmPrimitiveType subtype = (IEdmPrimitiveType) typeReferenceFromValue.Definition;
     bool flag = ((expectedTypeReference.IsNullable == typeReferenceFromValue.IsNullable) || (expectedTypeReference.IsNullable && !typeReferenceFromValue.IsNullable)) || !typeReferenceFromValue.IsODataValueType();
     bool flag2 = definition.IsAssignableFrom(subtype);
     if (!flag || !flag2)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ValidationUtils_IncompatiblePrimitiveItemType(typeReferenceFromValue.ODataFullName(), typeReferenceFromValue.IsNullable, expectedTypeReference.ODataFullName(), expectedTypeReference.IsNullable));
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:11,代码来源:ValidationUtils.cs

示例3: CanPromoteTo

        /// <summary>Promotes the specified expression to the given type if necessary.</summary>
        /// <param name="sourceType">The actual argument type.</param>
        /// <param name="targetType">The required type to promote to.</param>
        /// <returns>True if the <paramref name="sourceType"/> could be promoted; otherwise false.</returns>
        private static bool CanPromoteTo(IEdmTypeReference sourceType, IEdmTypeReference targetType)
        {
            Debug.Assert(targetType != null, "targetType != null");
            Debug.Assert(sourceType == null || sourceType.IsODataPrimitiveTypeKind(), "Type promotion only supported for primitive types.");
            Debug.Assert(targetType.IsODataPrimitiveTypeKind(), "Type promotion only supported for primitive types.");

            if (sourceType == null)
            {
                // This indicates that a null literal or an open type has been specified.
                // For null literals we can promote to the required target type if it is nullable
                // TODO: review this once open types are supported.
                return targetType.IsNullable;
            }

            if (sourceType.IsEquivalentTo(targetType))
            {
                return true;
            }

            if (CanConvertTo(sourceType, targetType))
            {
                return true;
            }

            // Allow promotion from nullable to non-nullable by directly accessing underlying value.
            if (sourceType.IsNullable && targetType.IsODataValueType())
            {
                IEdmTypeReference nonNullableSourceType = sourceType.Definition.ToTypeReference(false);
                if (CanConvertTo(nonNullableSourceType, targetType))
                {
                    return true;
                }
            }

            return false;
        }
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:40,代码来源:TypePromotionUtils.cs


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