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


C# IEdmTypeReference.IsEntity方法代码示例

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


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

示例1: ReadInline

        /// <inheritdoc />
        public sealed override object ReadInline(object item, IEdmTypeReference edmType, ODataDeserializerContext readContext)
        {
            if (item == null)
            {
                throw Error.ArgumentNull("item");
            }
            if (edmType == null)
            {
                throw Error.ArgumentNull("edmType");
            }
            if (!edmType.IsEntity())
            {
                throw Error.Argument("edmType", SRResources.ArgumentMustBeOfType, EdmTypeKind.Entity);
            }

            ODataEntryWithNavigationLinks entryWrapper = item as ODataEntryWithNavigationLinks;
            if (entryWrapper == null)
            {
                throw Error.Argument("item", SRResources.ArgumentMustBeOfType, typeof(ODataEntry).Name);
            }

            // Recursion guard to avoid stack overflows
            RuntimeHelpers.EnsureSufficientExecutionStack();

            return ReadEntry(entryWrapper, edmType.AsEntity(), readContext);
        }
开发者ID:tlycken,项目名称:aspnetwebstack,代码行数:27,代码来源:ODataEntityDeserializer.cs

示例2: GetEdmTypeSerializer

        public override ODataEdmTypeSerializer GetEdmTypeSerializer(IEdmTypeReference edmType)
        {
            if (edmType.IsEntity())
            {
                return entitySerializer;
            }

            return base.GetEdmTypeSerializer(edmType);
        }
开发者ID:Pliner,项目名称:TinyFeed,代码行数:9,代码来源:ODataPackageDefaultStreamAwareSerializerProvider.cs

示例3: CreateImplicitRangeVariable

        /// <summary>
        /// Creates a ParameterQueryNode for an implicit parameter ($it).
        /// </summary>
        /// <param name="elementType">Element type the parameter represents.</param>
        /// <param name="navigationSource">The navigation source. May be null and must be null for non entities.</param>
        /// <returns>A new IParameterNode.</returns>
        internal static RangeVariable CreateImplicitRangeVariable(IEdmTypeReference elementType, IEdmNavigationSource navigationSource)
        {
            if (elementType.IsEntity())
            {
                return new EntityRangeVariable(ExpressionConstants.It, elementType as IEdmEntityTypeReference, navigationSource);
            }

            Debug.Assert(navigationSource == null, "if the type wasn't an entity then there should be no navigation source");
            return new NonentityRangeVariable(ExpressionConstants.It, elementType, null);
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:16,代码来源:NodeFactory.cs

示例4: IsEntityOrFeed

 private static bool IsEntityOrFeed(IEdmTypeReference type)
 {
     Contract.Assert(type != null);
     return type.IsEntity() ||
         (type.IsCollection() && type.AsCollection().ElementType().IsEntity());
 }
开发者ID:sstrazan,项目名称:aspnetwebstack,代码行数:6,代码来源:ODataMediaTypeFormatter.cs

示例5: GetEntityType

        private static IEdmEntityType GetEntityType(IEdmTypeReference type)
        {
            IEdmEntityType entityType = null;
            if (type.IsEntity())
            {
                entityType = (IEdmEntityType)type.Definition;
            }
            else if (type.IsCollection())
            {
                type = ((IEdmCollectionType)type.Definition).ElementType;
                if (type.IsEntity())
                {
                    entityType = (IEdmEntityType)type.Definition;
                }
            }

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

示例6: ParseComplexOrCollectionAlias

        /// <summary>
        /// Parse the complex/collection value in parameter alias.
        /// </summary>
        /// <param name="queryToken">The parsed token.</param>
        /// <param name="parameterType">The expected parameter type.</param>
        /// <param name="model">The model</param>
        /// <returns>Token with complex/collection value passed.</returns>
        private static QueryToken ParseComplexOrCollectionAlias(QueryToken queryToken, IEdmTypeReference parameterType, IEdmModel model)
        {
            LiteralToken valueToken = queryToken as LiteralToken;
            string valueStr;
            if (valueToken != null && (valueStr = valueToken.Value as string) != null && !string.IsNullOrEmpty(valueToken.OriginalText))
            {
                var lexer = new ExpressionLexer(valueToken.OriginalText, true /*moveToFirstToken*/, false /*useSemicolonDelimiter*/, true /*parsingFunctionParameters*/);
                if (lexer.CurrentToken.Kind == ExpressionTokenKind.BracketedExpression)
                {
                    object result = valueStr;
                    if (!parameterType.IsEntity() && !parameterType.IsEntityCollectionType())
                    {
                        result = ODataUriUtils.ConvertFromUriLiteral(valueStr, ODataVersion.V4, model, parameterType);
                    }

                    // For non-primitive type, we have to pass parameterType to LiteralToken, then to ConstantNode so the service can know what the type it is.
                    return new LiteralToken(result, valueToken.OriginalText, parameterType);
                }
            }

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

示例7: ValidateMetadataType

        /// <summary>
        /// Validates that the (optional) <paramref name="typeReferenceFromMetadata"/> is the same as the (optional) <paramref name="typeReferenceFromValue"/>.
        /// </summary>
        /// <param name="typeReferenceFromMetadata">The (optional) type from the metadata definition (the expected type).</param>
        /// <param name="typeReferenceFromValue">The (optional) type from the value (the actual type).</param>
        /// <returns>The type as derived from the <paramref name="typeReferenceFromMetadata"/> and/or <paramref name="typeReferenceFromValue"/>.</returns>
        private static IEdmTypeReference ValidateMetadataType(IEdmTypeReference typeReferenceFromMetadata, IEdmTypeReference typeReferenceFromValue)
        {
            if (typeReferenceFromMetadata == null)
            {
                // if we have no metadata information there is nothing to validate
                return typeReferenceFromValue;
            }

            if (typeReferenceFromValue == null)
            {
                // derive the property type from the metadata
                return typeReferenceFromMetadata;
            }

            Debug.Assert(typeReferenceFromValue.TypeKind() == typeReferenceFromMetadata.TypeKind(), "typeReferenceFromValue.TypeKind() == typeReferenceFromMetadata.TypeKind()");

            // Make sure the types are the same
            if (typeReferenceFromValue.IsODataPrimitiveTypeKind())
            {
                // Primitive types must match exactly except for nullability
                ValidationUtils.ValidateMetadataPrimitiveType(typeReferenceFromMetadata, typeReferenceFromValue);
            }
            else if (typeReferenceFromMetadata.IsEntity())
            {
                ValidationUtils.ValidateEntityTypeIsAssignable((IEdmEntityTypeReference)typeReferenceFromMetadata, (IEdmEntityTypeReference)typeReferenceFromValue);
            }
            else if (typeReferenceFromMetadata.IsComplex())
            {
                ValidationUtils.ValidateComplexTypeIsAssignable(typeReferenceFromMetadata.Definition as IEdmComplexType, typeReferenceFromValue.Definition as IEdmComplexType);
            }
            else if (typeReferenceFromMetadata.IsCollection())
            {
                // Collection types must match exactly.
                if (!(typeReferenceFromMetadata.Definition.IsElementTypeEquivalentTo(typeReferenceFromValue.Definition)))
                {
                    throw new ODataException(Strings.ValidationUtils_IncompatibleType(typeReferenceFromValue.ODataFullName(), typeReferenceFromMetadata.ODataFullName()));
                }
            }
            else
            {
                // For other types, compare their full type name.
                if (typeReferenceFromMetadata.ODataFullName() != typeReferenceFromValue.ODataFullName())
                {
                    throw new ODataException(Strings.ValidationUtils_IncompatibleType(typeReferenceFromValue.ODataFullName(), typeReferenceFromMetadata.ODataFullName()));
                }
            }

            return typeReferenceFromValue;
        }
开发者ID:rossjempson,项目名称:odata.net,代码行数:55,代码来源:TypeNameOracle.cs

示例8: GetEntityType

		private static IEdmEntityType GetEntityType(IEdmTypeReference type)
		{
			IEdmEntityType definition = null;
			if (!type.IsEntity())
			{
				if (type.IsCollection())
				{
					type = ((IEdmCollectionType)type.Definition).ElementType;
					if (type.IsEntity())
					{
						definition = (IEdmEntityType)type.Definition;
					}
				}
			}
			else
			{
				definition = (IEdmEntityType)type.Definition;
			}
			return definition;
		}
开发者ID:nickchal,项目名称:pash,代码行数:20,代码来源:EdmNavigationProperty.cs

示例9: GetEdmTypeSerializer

            public override ODataEdmTypeSerializer GetEdmTypeSerializer(IEdmTypeReference edmType)
            {
                if (edmType.IsCollection() && edmType.AsCollection().ElementType().IsEntity())
                {
                    return new CustomFeedSerializer(this);
                }
                else if (edmType.IsEntity())
                {
                    return new CustomEntrySerializer(this);
                }

                return base.GetEdmTypeSerializer(edmType);
            }
开发者ID:xuanvufs,项目名称:WebApi,代码行数:13,代码来源:ODataFormatterTests.cs

示例10: BuildEntitySetPathExpression

        private static EdmPathExpression BuildEntitySetPathExpression(
            IEdmTypeReference returnTypeReference, ParameterInfo bindingParameter)
        {
            if (returnTypeReference != null &&
                returnTypeReference.IsEntity() &&
                bindingParameter != null)
            {
                return new EdmPathExpression(bindingParameter.Name);
            }

            return null;
        }
开发者ID:kosinsky,项目名称:RESTier,代码行数:12,代码来源:ConventionBasedOperationProvider.cs

示例11: BuildBoundOperationReturnTypePathExpression

        private static EdmPathExpression BuildBoundOperationReturnTypePathExpression(
            IEdmTypeReference returnTypeReference, ParameterInfo bindingParameter)
        {
            // Bound actions or functions that return an entity or a collection of entities
            // MAY specify a value for the EntitySetPath attribute
            // if determination of the entity set for the return type is contingent on the binding parameter.
            // The value for the EntitySetPath attribute consists of a series of segments
            // joined together with forward slashes.
            // The first segment of the entity set path MUST be the name of the binding parameter.
            // The remaining segments of the entity set path MUST represent navigation segments or type casts.
            if (returnTypeReference != null &&
                returnTypeReference.IsEntity() &&
                bindingParameter != null)
            {
                return new EdmPathExpression(bindingParameter.Name);
            }

            return null;
        }
开发者ID:chinadragon0515,项目名称:RESTier,代码行数:19,代码来源:RestierOperationModelBuilder.cs

示例12: GetEdmTypeSerializer

        /// <summary>
        /// Gets the serializer for the given EDM type reference.
        /// </summary>
        /// <param name="edmType">The EDM type reference involved in the serializer.</param>
        /// <returns>The serializer instance.</returns>
        public override ODataEdmTypeSerializer GetEdmTypeSerializer(IEdmTypeReference edmType)
        {
            if (edmType.IsEntity())
            {
                return this.entityTypeSerializer;
            }

            if (edmType.IsComplex())
            {
                return this.complexTypeSerializer;
            }

            if (edmType.IsPrimitive())
            {
                return this.primitiveSerializer;
            }

            if (edmType.IsEnum())
            {
                return this.enumSerializer;
            }

            if (edmType.IsCollection())
            {
                if (edmType.AsCollection().ElementType().IsEntity())
                {
                    return this.feedSerializer;
                }

                return this.collectionSerializer;
            }

            return base.GetEdmTypeSerializer(edmType);
        }
开发者ID:kosinsky,项目名称:RESTier,代码行数:39,代码来源:DefaultRestierSerializerProvider.cs

示例13: GetClrTypeName

        //fill all properties/name of the class template

        private string GetClrTypeName(IEdmTypeReference edmTypeReference)
        {
            string clrTypeName = edmTypeReference.ToString();
            IEdmType edmType = edmTypeReference.Definition;


            if (edmTypeReference.IsPrimitive()) return EdmToClr(edmType as IEdmPrimitiveType);

            //@@@ v1.0.0-rc2
            if (edmTypeReference.IsEnum())
            {
                var ent = edmType as IEdmEnumType;
                if (ent != null) return ent.Name;
            }

            if (edmTypeReference.IsComplex())
            {
                var edmComplexType = edmType as IEdmComplexType;
                if (edmComplexType != null) return edmComplexType.Name;
            }

            if (edmTypeReference.IsEntity())
            {
                var ent = edmType as IEdmEntityType;
                if (ent != null) return ent.Name;
            }

            if (edmTypeReference.IsCollection())
            {

                IEdmCollectionType edmCollectionType = edmType as IEdmCollectionType;
                if (edmCollectionType != null)
                {
                    IEdmTypeReference elementTypeReference = edmCollectionType.ElementType;
                    IEdmPrimitiveType primitiveElementType = elementTypeReference.Definition as IEdmPrimitiveType;
                    if (primitiveElementType == null)
                    {
                        IEdmSchemaElement schemaElement = elementTypeReference.Definition as IEdmSchemaElement;
                        if (schemaElement != null)
                        {
                            clrTypeName = schemaElement.Name;
                            //@@@ 1.0.0-rc2
                            // clrTypeName = string.Format("ICollection<{0}>", clrTypeName);
                            clrTypeName = string.Format("List<{0}>", clrTypeName); //to support RestSharp
                        }
                        return clrTypeName;
                    }

                    clrTypeName = EdmToClr(primitiveElementType);
                    clrTypeName = string.Format("List<{0}>", clrTypeName);
                }
                return clrTypeName;
            }//IsCollection
            return clrTypeName;
        }
开发者ID:moh-hassan,项目名称:odata2poco,代码行数:57,代码来源:Poco.cs


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