本文整理汇总了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);
}
示例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);
}
示例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
};
}
示例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;
}
示例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);
}
示例6: GetElementType
internal override IEdmEntityType GetElementType(IEdmNavigationSource navigationSource)
{
return navigationSource.EntityType();
}