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


C# IEdmNavigationSource.EntityType方法代码示例

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


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

示例1: GetElementType

        /// <summary>Returns the entity type of the given navigation source.</summary>
        /// <param name="navigationSource">The navigation source to get the element type of.</param>
        /// <returns>The <see cref="IEdmEntityType"/> representing the entity type of the <paramref name="navigationSource" />.</returns>
        internal override IEdmEntityType GetElementType(IEdmNavigationSource navigationSource)
        {
            IEdmEntityType entityType = navigationSource.EntityType();
            
            if (entityType == null)
            {
                return null;
            }

            return (IEdmEntityType)this.ResolveType(entityType);
        }
开发者ID:rossjempson,项目名称:odata.net,代码行数:14,代码来源:EdmTypeReaderResolver.cs

示例2: NavigationSourceLinkBuilderAnnotation

        /// <summary>
        /// Initializes a new instance of the <see cref="NavigationSourceLinkBuilderAnnotation"/> class.
        /// </summary>
        /// <param name="navigationSource">The navigation source for which the link builder is being constructed.</param>
        /// <param name="model">The EDM model that this navigation source belongs to.</param>
        /// <remarks>This constructor creates a link builder that generates URL's that follow OData conventions for the given navigation source.</remarks>
        public NavigationSourceLinkBuilderAnnotation(IEdmNavigationSource navigationSource, IEdmModel model)
        {
            if (navigationSource == null)
            {
                throw Error.ArgumentNull("navigationSource");
            }

            if (model == null)
            {
                throw Error.ArgumentNull("model");
            }

            IEdmEntityType elementType = navigationSource.EntityType();
            IEnumerable<IEdmEntityType> derivedTypes = model.FindAllDerivedTypes(elementType).Cast<IEdmEntityType>();

            // Add navigation link builders for all navigation properties of entity.
            foreach (IEdmNavigationProperty navigationProperty in elementType.NavigationProperties())
            {
                Func<EntityInstanceContext, IEdmNavigationProperty, Uri> navigationLinkFactory =
                    (entityInstanceContext, navProperty) => entityInstanceContext.GenerateNavigationPropertyLink(navProperty, includeCast: false);
                AddNavigationPropertyLinkBuilder(navigationProperty, new NavigationLinkBuilder(navigationLinkFactory, followsConventions: true));
            }

            // Add navigation link builders for all navigation properties in derived types.
            bool derivedTypesDefineNavigationProperty = false;
            foreach (IEdmEntityType derivedEntityType in derivedTypes)
            {
                foreach (IEdmNavigationProperty navigationProperty in derivedEntityType.DeclaredNavigationProperties())
                {
                    derivedTypesDefineNavigationProperty = true;
                    Func<EntityInstanceContext, IEdmNavigationProperty, Uri> navigationLinkFactory =
                    (entityInstanceContext, navProperty) => entityInstanceContext.GenerateNavigationPropertyLink(navProperty, includeCast: true);
                    AddNavigationPropertyLinkBuilder(navigationProperty, new NavigationLinkBuilder(navigationLinkFactory, followsConventions: true));
                }
            }

            _navigationSourceName = navigationSource.Name;
            _feedSelfLinkBuilder = (feedContext) => feedContext.GenerateFeedSelfLink();

            Func<EntityInstanceContext, string> selfLinkFactory =
                (entityInstanceContext) => entityInstanceContext.GenerateSelfLink(includeCast: derivedTypesDefineNavigationProperty);
            _idLinkBuilder = new SelfLinkBuilder<string>(selfLinkFactory, followsConventions: true);
        }
开发者ID:nicholaspei,项目名称:aspnetwebstack,代码行数:49,代码来源:NavigationSourceLinkBuilderAnnotation.cs

示例3: Create

 /// <summary>
 /// Create ODataContextUrlInfo from basic information
 /// </summary>
 /// <param name="navigationSource">Navigation source for current element.</param>\
 /// <param name="expectedEntityTypeName">The expectedEntity for current element.</param>
 /// <param name="isSingle">Whether target is single item.</param>
 /// <param name="odataUri">The odata uri info for current query.</param>
 /// <returns>The generated ODataContextUrlInfo.</returns>
 internal static ODataContextUrlInfo Create(IEdmNavigationSource navigationSource, string expectedEntityTypeName, bool isSingle, ODataUri odataUri)
 {
     EdmNavigationSourceKind kind = navigationSource.NavigationSourceKind();
     string navigationSourceEntityType = navigationSource.EntityType().FullName();
     return new ODataContextUrlInfo()
     {
         isContained = kind == EdmNavigationSourceKind.ContainedEntitySet,
         IsUnknownEntitySet = kind == EdmNavigationSourceKind.UnknownEntitySet,
         navigationSource = navigationSource.Name,
         TypeCast = navigationSourceEntityType == expectedEntityTypeName ? null : expectedEntityTypeName,
         TypeName = navigationSourceEntityType,
         IncludeFragmentItemSelector = isSingle && kind != EdmNavigationSourceKind.Singleton,
         odataUri = odataUri
     };
 }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:23,代码来源:ODataContextUrlInfo.cs

示例4: ConvertToODataEntry

        /// <summary>
        /// Converts an item from the data store into an ODataEntry.
        /// </summary>
        /// <param name="element">The item to convert.</param>
        /// <param name="navigationSource">The navigation source that the item belongs to.</param>
        /// <param name="targetVersion">The OData version this segment is targeting.</param>
        /// <returns>The converted ODataEntry.</returns>
        public static ODataEntry ConvertToODataEntry(object element, IEdmNavigationSource entitySource, ODataVersion targetVersion)
        {
            IEdmStructuredType entityType = EdmClrTypeUtils.GetEdmType(DataSourceManager.GetCurrentDataSource().Model, element) as IEdmStructuredType;

            if (entityType == null)
            {
                throw new InvalidOperationException("Can not create an entry for " + entitySource.Name);
            }

            var entry = new ODataEntry
            {
                Properties = GetProperties(element, entityType)
            };

            // Add Annotation in Entity Level
            if (((ClrObject)element).Annotations != null)
            {
                foreach (InstanceAnnotationType annotation in ((ClrObject)element).Annotations)
                {
                    if (string.IsNullOrEmpty(annotation.Target))
                    {
                        entry.InstanceAnnotations.Add(new ODataInstanceAnnotation(annotation.Name, annotation.ConvertValueToODataValue()));
                    }
                }
            }

            string typeName;
            if (entityType is IEdmEntityType)
            {
                typeName = (entityType as IEdmEntityType).Name;
            }
            else if (entityType is IEdmComplexType)
            {
                typeName = (entityType as IEdmComplexType).Name;
            }
            else
            {
                throw new InvalidOperationException("Not Supported Edmtype to convert to OData Entry.");
            }
            entry.TypeName = element.GetType().Namespace + "." + typeName;

            // TODO tiano. work around for now
            if (!(entitySource is IEdmContainedEntitySet))
            {
                Uri entryUri = BuildEntryUri(element, entitySource, targetVersion);
                if (element.GetType().BaseType != null && entitySource.EntityType().Name != typeName)
                {
                    var editLink = new Uri(entryUri.AbsoluteUri.TrimEnd('/') + "/" + entry.TypeName);
                    entry.EditLink = editLink;
                    entry.ReadLink = editLink;
                }
                else
                {
                    entry.EditLink = entryUri;
                    entry.ReadLink = entryUri;
                }
                entry.Id = entryUri;
            }

            if (Utility.IsMediaEntity(element.GetType()))
            {
                var streamProvider = DataSourceManager.GetCurrentDataSource().StreamProvider;
                entry.MediaResource = new ODataStreamReferenceValue()
                {
                    ContentType = streamProvider.GetContentType(element),
                    ETag = streamProvider.GetETag(element),
                };
            }

            return entry;
        }
开发者ID:nickgoodrow,项目名称:ODataSamples,代码行数:78,代码来源:ODataObjectModelConverter.cs

示例5: BuildNewMetadataBinder

 private MetadataBinder BuildNewMetadataBinder(IEdmNavigationSource targetNavigationSource)
 {
     BindingState state = new BindingState(this.configuration)
     {
         ImplicitRangeVariable =
             NodeFactory.CreateImplicitRangeVariable(targetNavigationSource.EntityType().ToTypeReference(), targetNavigationSource)
     };
     state.RangeVariables.Push(state.ImplicitRangeVariable);
     return new MetadataBinder(state);
 }
开发者ID:vebin,项目名称:odata.net,代码行数:10,代码来源:SelectExpandBinder.cs

示例6: GetElementType

 internal override IEdmEntityType GetElementType(IEdmNavigationSource navigationSource)
 {
     return navigationSource.EntityType();
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:4,代码来源:EdmTypeWriterResolver.cs


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