本文整理汇总了C#中IEdmNavigationSource类的典型用法代码示例。如果您正苦于以下问题:C# IEdmNavigationSource类的具体用法?C# IEdmNavigationSource怎么用?C# IEdmNavigationSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IEdmNavigationSource类属于命名空间,在下文中一共展示了IEdmNavigationSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AppendNavigationPropertySegment
/// <summary>
/// Build a segment representing a navigation property.
/// </summary>
/// <param name="path">Path to perform the computation on.</param>
/// <param name="navigationProperty">The navigation property this segment represents.</param>
/// <param name="navigationSource">The navigation source of the entities targetted by this navigation property. This can be null.</param>
/// <returns>The ODataPath with navigation property appended in the end in the end</returns>
public static ODataPath AppendNavigationPropertySegment(this ODataPath path, IEdmNavigationProperty navigationProperty, IEdmNavigationSource navigationSource)
{
var newPath = new ODataPath(path);
NavigationPropertySegment np = new NavigationPropertySegment(navigationProperty, navigationSource);
newPath.Add(np);
return newPath;
}
示例2: WriteEntry
/// <summary>
/// Writes an OData entry.
/// </summary>
/// <param name="writer">The ODataWriter that will write the entry.</param>
/// <param name="element">The item from the data store to write.</param>
/// <param name="navigationSource">The navigation source in the model that the entry belongs to.</param>
/// <param name="model">The data store model.</param>
/// <param name="targetVersion">The OData version this segment is targeting.</param>
/// <param name="selectExpandClause">The SelectExpandClause.</param>
public static void WriteEntry(ODataWriter writer, object element, IEdmNavigationSource entitySource, ODataVersion targetVersion, SelectExpandClause selectExpandClause, Dictionary<string, string> incomingHeaders = null)
{
var entry = ODataObjectModelConverter.ConvertToODataEntry(element, entitySource, targetVersion);
entry.ETag = Utility.GetETagValue(element);
if (selectExpandClause != null && selectExpandClause.SelectedItems.OfType<PathSelectItem>().Any())
{
ExpandSelectItemHandler selectItemHandler = new ExpandSelectItemHandler(entry);
foreach (var item in selectExpandClause.SelectedItems.OfType<PathSelectItem>())
{
item.HandleWith(selectItemHandler);
}
entry = selectItemHandler.ProjectedEntry;
}
CustomizeEntry(incomingHeaders, entry);
writer.WriteStart(entry);
// gets all of the expandedItems, including ExpandedRefernceSelectItem and ExpandedNavigationItem
var expandedItems = selectExpandClause == null ? null : selectExpandClause.SelectedItems.OfType<ExpandedReferenceSelectItem>();
WriteNavigationLinks(writer, element, entry.ReadLink, entitySource, targetVersion, expandedItems);
writer.WriteEnd();
}
示例3: SnapResults
public static void SnapResults(List<DeltaSnapshotEntry> results, IEnumerable entries, IEdmNavigationSource entitySource, SelectExpandClause selectExpandClause, string parentId, string relationShip)
{
foreach (object entry in entries)
{
SnapResult(results, entry, entitySource, selectExpandClause, parentId, relationShip);
}
}
示例4: SnapResult
private static void SnapResult(List<DeltaSnapshotEntry> results, object entry, IEdmNavigationSource entitySource, SelectExpandClause selectExpandClause, string parentId, string relationShip)
{
var oDataEntry = ODataObjectModelConverter.ConvertToODataEntry(entry, entitySource, ODataVersion.V4);
results.Add(new DeltaSnapshotEntry(oDataEntry.Id.AbsoluteUri, parentId, relationShip));
var expandedNavigationItems = selectExpandClause == null ? null : selectExpandClause.SelectedItems.OfType<ExpandedNavigationSelectItem>();
SnapExpandedEntry(results, entry, entitySource, expandedNavigationItems, oDataEntry.Id.AbsoluteUri);
}
示例5: ODataWriterCore
/// <summary>
/// Constructor.
/// </summary>
/// <param name="outputContext">The output context to write to.</param>
/// <param name="navigationSource">The navigation source we are going to write entities for.</param>
/// <param name="entityType">The entity type for the entries in the feed to be written (or null if the entity set base type should be used).</param>
/// <param name="writingFeed">True if the writer is created for writing a feed; false when it is created for writing an entry.</param>
/// <param name="listener">If not null, the writer will notify the implementer of the interface of relevant state changes in the writer.</param>
protected ODataWriterCore(
ODataOutputContext outputContext,
IEdmNavigationSource navigationSource,
IEdmEntityType entityType,
bool writingFeed,
IODataReaderWriterListener listener = null)
{
Debug.Assert(outputContext != null, "outputContext != null");
this.outputContext = outputContext;
this.writingFeed = writingFeed;
// create a collection validator when writing a top-level feed and a user model is present
if (this.writingFeed && this.outputContext.Model.IsUserModel())
{
this.feedValidator = new FeedWithoutExpectedTypeValidator();
}
if (navigationSource != null && entityType == null)
{
entityType = this.outputContext.EdmTypeResolver.GetElementType(navigationSource);
}
ODataUri odataUri = outputContext.MessageWriterSettings.ODataUri.Clone();
// Remove key for top level entry
if (!writingFeed && odataUri != null && odataUri.Path != null)
{
odataUri.Path = odataUri.Path.TrimEndingKeySegment();
}
this.listener = listener;
this.scopes.Push(new Scope(WriterState.Start, /*item*/null, navigationSource, entityType, /*skipWriting*/false, outputContext.MessageWriterSettings.SelectedProperties, odataUri));
}
示例6: SnapExpandedEntry
private static void SnapExpandedEntry(List<DeltaSnapshotEntry> results, object element, IEdmNavigationSource edmParent, IEnumerable<ExpandedNavigationSelectItem> expandedNavigationItems, string parentId)
{
foreach (var navigationProperty in ((IEdmEntityType)EdmClrTypeUtils.GetEdmType(DataSourceManager.GetCurrentDataSource().Model, element)).NavigationProperties())
{
var expandedNavigationItem = GetExpandedNavigationItem(expandedNavigationItems, navigationProperty.Name);
if (expandedNavigationItem != null)
{
bool isCollection = navigationProperty.Type.IsCollection();
ExpandSelectItemHandler expandItemHandler = new ExpandSelectItemHandler(element);
expandedNavigationItem.HandleWith(expandItemHandler);
var propertyValue = expandItemHandler.ExpandedChildElement;
if (propertyValue != null)
{
IEdmNavigationSource targetSource = edmParent.FindNavigationTarget(navigationProperty);
if (isCollection)
{
SnapResults(results, propertyValue as IEnumerable, targetSource as IEdmEntitySetBase, expandedNavigationItem.SelectAndExpand, parentId, navigationProperty.Name);
}
else
{
SnapResult(results, propertyValue, targetSource, expandedNavigationItem.SelectAndExpand, parentId, navigationProperty.Name);
}
}
}
}
}
示例7: GetNavigationSource
/// <inheritdoc/>
public override IEdmNavigationSource GetNavigationSource(IEdmNavigationSource previousNavigationSource)
{
if (NavigationProperty != null && previousNavigationSource != null)
{
return previousNavigationSource.FindNavigationTarget(NavigationProperty);
}
return null;
}
示例8: EdmUnknownEntitySet
/// <summary>
/// Initializes a new instance of the <see cref="EdmUnknownEntitySet"/> class.
/// </summary>
/// <param name="parentNavigationSource">The <see cref="IEdmNavigationSource"/> that container element belongs to</param>
/// <param name="navigationProperty">An <see cref="IEdmNavigationProperty"/> containing the navagation property definition of the contained element</param>
public EdmUnknownEntitySet(IEdmNavigationSource parentNavigationSource, IEdmNavigationProperty navigationProperty)
: base(navigationProperty.Name, navigationProperty.ToEntityType())
{
EdmUtil.CheckArgumentNull(parentNavigationSource, "parentNavigationSource");
EdmUtil.CheckArgumentNull(navigationProperty, "navigationProperty");
this.parentNavigationSource = parentNavigationSource;
this.navigationProperty = navigationProperty;
}
示例9: CreateSwaggerPathForEntity
/// <summary>
/// Create the Swagger path for the Edm entity.
/// </summary>
/// <param name="navigationSource">The Edm navigation source.</param>
/// <returns>The <see cref="Newtonsoft.Json.Linq.JObject"/> represents the related Edm entity.</returns>
public static JObject CreateSwaggerPathForEntity(IEdmNavigationSource navigationSource)
{
IEdmEntitySet entitySet = navigationSource as IEdmEntitySet;
if (entitySet == null)
{
return new JObject();
}
var keyParameters = new JArray();
foreach (var key in entitySet.EntityType().Key())
{
string format;
string type = GetPrimitiveTypeAndFormat(key.Type.Definition as IEdmPrimitiveType, out format);
keyParameters.Parameter(key.Name, "path", "key: " + key.Name, type, format);
}
return new JObject()
{
{
"get", new JObject()
.Summary("Get entity from " + entitySet.Name + " by key.")
.OperationId(entitySet.Name + "_GetById")
.Description("Returns the entity with the key from " + entitySet.Name)
.Tags(entitySet.Name)
.Parameters((keyParameters.DeepClone() as JArray)
.Parameter("$select", "query", "description", "string"))
.Responses(new JObject()
.Response("200", "EntitySet " + entitySet.Name, entitySet.EntityType())
.DefaultErrorResponse())
},
{
"patch", new JObject()
.Summary("Update entity in EntitySet " + entitySet.Name)
.OperationId(entitySet.Name + "_PatchById")
.Description("Update entity in EntitySet " + entitySet.Name)
.Tags(entitySet.Name)
.Parameters((keyParameters.DeepClone() as JArray)
.Parameter(entitySet.EntityType().Name, "body", "The entity to patch",
entitySet.EntityType()))
.Responses(new JObject()
.Response("204", "Empty response")
.DefaultErrorResponse())
},
{
"delete", new JObject()
.Summary("Delete entity in EntitySet " + entitySet.Name)
.OperationId(entitySet.Name + "_DeleteById")
.Description("Delete entity in EntitySet " + entitySet.Name)
.Tags(entitySet.Name)
.Parameters((keyParameters.DeepClone() as JArray)
.Parameter("If-Match", "header", "If-Match header", "string"))
.Responses(new JObject()
.Response("204", "Empty response")
.DefaultErrorResponse())
}
};
}
示例10: SelectExpandBinder
/// <summary>
/// Build the ExpandOption variant of an SelectExpandBinder
/// </summary>
/// <param name="configuration">The configuration used for binding.</param>
/// <param name="edmType">The type of the top level expand item.</param>
/// <param name="navigationSource">The navigation source of the top level expand item.</param>
public SelectExpandBinder(ODataUriParserConfiguration configuration, IEdmStructuredType edmType, IEdmNavigationSource navigationSource)
{
ExceptionUtils.CheckArgumentNotNull(configuration, "configuration");
ExceptionUtils.CheckArgumentNotNull(edmType, "edmType");
this.configuration = configuration;
this.edmType = edmType;
this.navigationSource = navigationSource;
}
示例11: EntityRangeVariable
/// <summary>
/// Creates a <see cref="EntityRangeVariable"/>.
/// </summary>
/// <param name="name"> The name of the associated any/all parameter (null if none)</param>
/// <param name="entityType">The entity type of each item in the collection that this range variable iterates over.</param>
/// <param name="navigationSource">The navigation source of the collection this node iterates over.</param>
/// <exception cref="System.ArgumentNullException">Throws if the input name or entityType is null.</exception>
public EntityRangeVariable(string name, IEdmEntityTypeReference entityType, IEdmNavigationSource navigationSource)
{
ExceptionUtils.CheckArgumentNotNull(name, "name");
ExceptionUtils.CheckArgumentNotNull(entityType, "entityType");
this.name = name;
this.entityTypeReference = entityType;
this.entityCollectionNode = null;
this.navigationSource = navigationSource;
}
示例12: GenerateDeltaItemsFromFeed
/// <summary>
/// Handle first level entities, genreate the delta items which need to be write
/// </summary>
/// <param name="entries">Query results</param>
/// <param name="entitySet">EntitySet</param>
/// <param name="targetVersion">Target Version</param>
/// <param name="selectExpandClause">Select and Expand Clause</param>
private void GenerateDeltaItemsFromFeed(IEnumerable entries, IEdmNavigationSource entitySet, ODataVersion targetVersion, SelectExpandClause selectExpandClause)
{
foreach (var entry in entries)
{
// Handle single element in first level and their related navigation property
GenerateDeltaItemFromEntry(entry, entitySet, targetVersion, selectExpandClause, string.Empty, string.Empty);
}
// Handle deleted element in first level
GenerateDeltaItemsFromDeletedEntities(string.Empty, string.Empty);
}
示例13: 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);
}
示例14: SetNavigationSourceLinkBuilder
public static void SetNavigationSourceLinkBuilder(this IEdmModel model, IEdmNavigationSource navigationSource,
NavigationSourceLinkBuilderAnnotation navigationSourceLinkBuilder)
{
if (model == null)
{
throw Error.ArgumentNull("model");
}
model.SetAnnotationValue(navigationSource, navigationSourceLinkBuilder);
}
示例15: 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);
}