本文整理汇总了C#中Microsoft.OData.Core.ODataEntry.GetAnnotation方法的典型用法代码示例。如果您正苦于以下问题:C# ODataEntry.GetAnnotation方法的具体用法?C# ODataEntry.GetAnnotation怎么用?C# ODataEntry.GetAnnotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.OData.Core.ODataEntry
的用法示例。
在下文中一共展示了ODataEntry.GetAnnotation方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetEntryTypeNameForWriting
internal string GetEntryTypeNameForWriting(ODataEntry entry)
{
Debug.Assert(entry != null, "entry != null");
SerializationTypeNameAnnotation typeNameAnnotation = entry.GetAnnotation<SerializationTypeNameAnnotation>();
if (typeNameAnnotation != null)
{
return typeNameAnnotation.TypeName;
}
return entry.TypeName;
}
示例2: VisitEntry
/// <summary>
/// Visits an entry item.
/// </summary>
/// <param name="entry">The entry to visit.</param>
protected override ODataPayloadElement VisitEntry(ODataEntry entry)
{
ODataPayloadElement payloadElement = base.VisitEntry(entry);
ODataEntryPayloadOrderObjectModelAnnotation payloadOrderEntryAnnotation = entry.GetAnnotation<ODataEntryPayloadOrderObjectModelAnnotation>();
if (payloadOrderEntryAnnotation != null)
{
PayloadOrderODataPayloadElementAnnotation payloadOrderElementAnnotation = new PayloadOrderODataPayloadElementAnnotation();
payloadOrderElementAnnotation.PayloadItems.AddRange(payloadOrderEntryAnnotation.PayloadItems);
payloadElement.Add(payloadOrderElementAnnotation);
}
return payloadElement;
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:17,代码来源:ObjectModelToPayloadElementPayloadWithPayloadOrderConverter.cs
示例3: MaterializerEntry
/// <summary>
/// Creates a new instance of MaterializerEntry.
/// </summary>
/// <param name="entry">The entry.</param>
/// <param name="format">The format the entry was read in.</param>
/// <param name="isTracking">True if the contents of the entry will be tracked in the context, otherwise False.</param>
/// <param name="model">The client model.</param>
private MaterializerEntry(ODataEntry entry, ODataFormat format, bool isTracking, ClientEdmModel model)
{
Debug.Assert(entry != null, "entry != null");
this.entry = entry;
this.Format = format;
this.entityDescriptor = new EntityDescriptor(model);
#pragma warning disable 618
this.isAtomOrTracking = isTracking || this.Format == ODataFormat.Atom;
#pragma warning restore 618
string serverTypeName = this.Entry.TypeName;
SerializationTypeNameAnnotation serializationTypeNameAnnotation = entry.GetAnnotation<SerializationTypeNameAnnotation>();
if (serializationTypeNameAnnotation != null)
{
// If the annotation has a value use it. Otherwise, in JSON-Light, the types can be inferred from the
// context URI even if they are not present on the wire, so just use the type name from the entry.
if (serializationTypeNameAnnotation.TypeName != null || this.Format != ODataFormat.Json)
{
serverTypeName = serializationTypeNameAnnotation.TypeName;
}
}
this.entityDescriptor.ServerTypeName = serverTypeName;
}
示例4: AddTypeNameAnnotationAsNeeded_AddsAnnotationWithNullValue_IfTypeOfPathMatchesEntryType
[Fact] // Issue 984: Redundant type name serialization in OData JSON light minimal metadata mode
public void AddTypeNameAnnotationAsNeeded_AddsAnnotationWithNullValue_IfTypeOfPathMatchesEntryType()
{
// Arrange
CustomersModelWithInheritance model = new CustomersModelWithInheritance();
ODataEntry entry = new ODataEntry
{
TypeName = model.SpecialCustomer.FullName()
};
// Act
ODataEntityTypeSerializer.AddTypeNameAnnotationAsNeeded(entry, model.SpecialCustomer, ODataMetadataLevel.MinimalMetadata);
// Assert
SerializationTypeNameAnnotation annotation = entry.GetAnnotation<SerializationTypeNameAnnotation>();
Assert.NotNull(annotation); // Guard
Assert.Null(annotation.TypeName);
}
示例5: AddTypeNameAnnotationAsNeeded_AddsAnnotation_IfTypeOfPathDoesNotMatchEntryType
public void AddTypeNameAnnotationAsNeeded_AddsAnnotation_IfTypeOfPathDoesNotMatchEntryType()
{
// Arrange
string expectedTypeName = "TypeName";
ODataEntry entry = new ODataEntry
{
TypeName = expectedTypeName
};
// Act
ODataEntityTypeSerializer.AddTypeNameAnnotationAsNeeded(entry, _customerType.EntityDefinition(), ODataMetadataLevel.MinimalMetadata);
// Assert
SerializationTypeNameAnnotation annotation = entry.GetAnnotation<SerializationTypeNameAnnotation>();
Assert.NotNull(annotation); // Guard
Assert.Equal(expectedTypeName, annotation.TypeName);
}
示例6: WriteEntry
private void WriteEntry(ODataWriter writer, Lazy<ODataReader> lazyReader, ODataEntry entry)
{
this.WriteStart(writer, entry);
var annotation = entry.GetAnnotation<ODataEntryNavigationLinksObjectModelAnnotation>();
ODataNavigationLink navLink = null;
if (annotation != null)
{
for (int i = 0; i < annotation.Count; ++i)
{
bool found = annotation.TryGetNavigationLinkAt(i, out navLink);
ExceptionUtilities.Assert(found, "Navigation links should be ordered sequentially for writing");
this.WriteNavigationLink(writer, lazyReader, navLink);
}
}
this.WriteEnd(writer, ODataReaderState.EntryEnd);
this.Read(lazyReader);
}
示例7: VisitEntry
/// <summary>
/// Visits an entry item.
/// </summary>
/// <param name="entry">The entry item to visit.</param>
/// <returns>An ODataPayloadElement representing the entry.</returns>
protected override ODataPayloadElement VisitEntry(ODataEntry entry)
{
ExceptionUtilities.CheckArgumentNotNull(entry, "entry");
EntityInstance entity = (EntityInstance)base.VisitEntry(entry);
var atomMetadata = entry.GetAnnotation<AtomEntryMetadata>();
if (atomMetadata != null)
{
ConvertAtomEntryMetadata(atomMetadata, entity);
}
return entity;
}
示例8: AddTypeNameAnnotationAsNeeded_DoesNotAddAnnotation_InDefaultMetadataMode
public void AddTypeNameAnnotationAsNeeded_DoesNotAddAnnotation_InDefaultMetadataMode()
{
// Arrange
ODataEntry entry = new ODataEntry();
// Act
ODataEntityTypeSerializer.AddTypeNameAnnotationAsNeeded(entry, null, ODataMetadataLevel.Default);
// Assert
Assert.Null(entry.GetAnnotation<SerializationTypeNameAnnotation>());
}
示例9: VisitEntry
/// <summary>
/// Visits an entry item.
/// </summary>
/// <param name="entry">The entry to visit.</param>
protected override void VisitEntry(ODataEntry entry)
{
this.VisitAtomMetadata(entry.GetAnnotation<AtomEntryMetadata>());
base.VisitEntry(entry);
}
示例10: GetEntry
/// <summary>
/// Gets an entry for a given ODataEntry.
/// </summary>
/// <param name="entry">The ODataEntry.</param>
/// <returns>The materializer entry</returns>
public static MaterializerEntry GetEntry(ODataEntry entry)
{
return entry.GetAnnotation<MaterializerEntry>();
}
示例11: CreateEntry
/// <summary>
/// Creates the materializer entry.
/// </summary>
/// <param name="entry">The entry.</param>
/// <param name="format">The format the entry was read in.</param>
/// <param name="isTracking">True if the contents of the entry will be tracked in the context, otherwise False.</param>
/// <param name="model">The client model.</param>
/// <returns>A new materializer entry.</returns>
public static MaterializerEntry CreateEntry(ODataEntry entry, ODataFormat format, bool isTracking, ClientEdmModel model)
{
Debug.Assert(entry.GetAnnotation<MaterializerEntry>() == null, "MaterializerEntry has already been created.");
MaterializerEntry materializerEntry = new MaterializerEntry(entry, format, isTracking, model);
entry.SetAnnotation<MaterializerEntry>(materializerEntry);
return materializerEntry;
}