本文整理汇总了C#中Microsoft.Data.OData.ODataEntry类的典型用法代码示例。如果您正苦于以下问题:C# ODataEntry类的具体用法?C# ODataEntry怎么用?C# ODataEntry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ODataEntry类属于Microsoft.Data.OData命名空间,在下文中一共展示了ODataEntry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: MaterializerEntry
private MaterializerEntry(ODataEntry entry, DataServiceProtocolVersion maxProtocolVersion)
{
this.entry = entry;
this.entityDescriptor = new System.Data.Services.Client.EntityDescriptor(maxProtocolVersion);
SerializationTypeNameAnnotation annotation = entry.GetAnnotation<SerializationTypeNameAnnotation>();
this.entityDescriptor.ServerTypeName = (annotation != null) ? annotation.TypeName : (this.entityDescriptor.ServerTypeName = this.Entry.TypeName);
}
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:MaterializerEntry.cs
示例2: EntryPropertiesValueCache
internal EntryPropertiesValueCache(ODataEntry entry)
{
if (entry.Properties != null)
{
this.entryPropertiesCache = new List<ODataProperty>(entry.Properties);
}
}
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:EntryPropertiesValueCache.cs
示例3: TryAnnotateV2FeedPackage
private void TryAnnotateV2FeedPackage(ODataEntry entry, EntityInstanceContext entityInstanceContext)
{
var instance = entityInstanceContext.EntityInstance as V2FeedPackage;
if (instance != null)
{
// Set Atom entry metadata
var atomEntryMetadata = new AtomEntryMetadata();
atomEntryMetadata.Title = instance.Id;
if (!string.IsNullOrEmpty(instance.Authors))
{
atomEntryMetadata.Authors = new[] { new AtomPersonMetadata { Name = instance.Authors } };
}
if (instance.LastUpdated > DateTime.MinValue)
{
atomEntryMetadata.Updated = instance.LastUpdated;
}
if (!string.IsNullOrEmpty(instance.Summary))
{
atomEntryMetadata.Summary = instance.Summary;
}
entry.SetAnnotation(atomEntryMetadata);
// Add package download link
entry.MediaResource = new ODataStreamReferenceValue
{
ContentType = ContentType,
ReadLink = BuildLinkForStreamProperty("v2", instance.Id, instance.Version, entityInstanceContext.Request)
};
}
}
开发者ID:ZhiYuanHuang,项目名称:NuGetGallery,代码行数:30,代码来源:NuGetEntityTypeSerializer.cs
示例4: EndEntry
protected override void EndEntry(ODataEntry entry)
{
if (entry != null)
{
ProjectedPropertiesAnnotation projectedProperties = entry.GetAnnotation<ProjectedPropertiesAnnotation>();
this.jsonEntryAndFeedSerializer.WriteProperties(base.EntryEntityType, entry.Properties, false, base.DuplicatePropertyNamesChecker, projectedProperties);
this.jsonOutputContext.JsonWriter.EndObjectScope();
}
}
开发者ID:nickchal,项目名称:pash,代码行数:9,代码来源:ODataJsonWriter.cs
示例5: ConvertFeed
public void ConvertFeed(Uri relativeODataUri, Uri relativeSodaUri, JsonPayload jsonPayload,
DateTimeOffset feedUpdateTime)
{
var jsonObject = jsonPayload.JsonObject;
var entries = jsonObject.PropertyValue<JArray>("entries");
var meta = jsonObject.PropertyValue<JObject>("meta");
var view = meta.PropertyValue<JObject>("view");
IList<string> fieldsToIgnore;
var model = BuildModel(view, out fieldsToIgnore);
var entitySet = model.EntityContainers.Single().EntitySets().Single();
var settings = new ODataMessageWriterSettings
{
Indent = true,
};
using (var writer = new ODataMessageWriter(Message, settings, model))
{
var feedWriter = writer.CreateODataFeedWriter();
var feed = new ODataFeed();
feed.SetAnnotation(new AtomFeedMetadata
{
Updated = feedUpdateTime,
});
feed.Id = new Uri(ODataEndpointUri, relativeODataUri.OriginalString).OriginalString;
feedWriter.WriteStart(feed);
foreach (var entry in entries.Cast<JObject>())
{
var entryMetadata = new ODataEntry();
entryMetadata.Id = (string) ((JValue) entry.Property("id").Value).Value;
entryMetadata.TypeName = entitySet.ElementType.FullName();
entryMetadata.Properties = ConvertProperties(entry, fieldsToIgnore);
entryMetadata.SetAnnotation(new AtomEntryMetadata
{
Updated = ConvertDateTimeOffset(entry.PrimitivePropertyValue<long>("updated_at")),
Published = ConvertDateTimeOffset(entry.PrimitivePropertyValue<long>("created_at")),
});
feedWriter.WriteStart(entryMetadata);
feedWriter.WriteEnd();
}
feedWriter.WriteEnd();
}
}
开发者ID:OData,项目名称:OData4Soda,代码行数:54,代码来源:SodaToODataConverter.cs
示例6: StartEntry
protected override void StartEntry(ODataEntry entry)
{
if (entry == null)
{
this.jsonOutputContext.JsonWriter.WriteValue((string) null);
}
else
{
this.jsonOutputContext.JsonWriter.StartObjectScope();
ProjectedPropertiesAnnotation projectedProperties = entry.GetAnnotation<ProjectedPropertiesAnnotation>();
this.jsonEntryAndFeedSerializer.WriteEntryMetadata(entry, projectedProperties, base.EntryEntityType, base.DuplicatePropertyNamesChecker);
}
}
开发者ID:nickchal,项目名称:pash,代码行数:13,代码来源:ODataJsonWriter.cs
示例7: CreateEntry
public static MaterializerEntry CreateEntry(ODataEntry entry, DataServiceProtocolVersion maxProtocolVersion)
{
MaterializerEntry annotation = new MaterializerEntry(entry, maxProtocolVersion);
entry.SetAnnotation<MaterializerEntry>(annotation);
if (entry.Id == null)
{
throw System.Data.Services.Client.Error.InvalidOperation(System.Data.Services.Client.Strings.Deserialize_MissingIdElement);
}
annotation.EntityDescriptor.Identity = entry.Id;
annotation.EntityDescriptor.EditLink = entry.EditLink;
annotation.EntityDescriptor.SelfLink = entry.ReadLink;
annotation.EntityDescriptor.ETag = entry.ETag;
return annotation;
}
开发者ID:nickchal,项目名称:pash,代码行数:14,代码来源:MaterializerEntry.cs
示例8: ODataResponse
ODataResponse IODataView.CreateView()
{
var oDataResponse = new ODataResponse();
var messageWriter = new ODataMessageWriter(oDataResponse);
var entryWriter = messageWriter.CreateODataFeedWriter();
var feed = new ODataFeed() { Count = Videos.Count, Id = "Hypermedia-Learning" };
var atomFeed = feed.Atom();
atomFeed.Title = "Hypermedia API - " + PageTitle;
entryWriter.WriteStart(feed);
foreach (var video in Videos)
{
var oDataEntry = new ODataEntry() {};
var atom = oDataEntry.Atom();
atom.Title = "Video : " + video.Link.Title;
atom.Summary = video.Description;
entryWriter.WriteStart(oDataEntry);
entryWriter.WriteEnd();
}
foreach (var item in Community)
{
var oDataEntry = new ODataEntry() { };
var atom = oDataEntry.Atom();
atom.Title = "Community : " + item.Link.Title;
atom.Summary = item.Description;
entryWriter.WriteStart(oDataEntry);
entryWriter.WriteEnd();
}
entryWriter.WriteEnd();
entryWriter.Flush();
oDataResponse.GetStream().Position = 0;
return oDataResponse;
}
开发者ID:ConceptFirst,项目名称:HypermediaApiSite,代码行数:42,代码来源:LearningViewModel.cs
示例9: WriteEntry
private void WriteEntry(object graph, IEnumerable<ODataProperty> propertyBag, ODataWriter writer, ODataSerializerContext writeContext)
{
IEdmEntityType entityType = _edmEntityTypeReference.EntityDefinition();
EntityInstanceContext entityInstanceContext = new EntityInstanceContext(SerializerProvider.EdmModel, writeContext.EntitySet, entityType, writeContext.UrlHelper, graph, writeContext.SkipExpensiveAvailabilityChecks);
ODataEntry entry = new ODataEntry
{
TypeName = _edmEntityTypeReference.FullName(),
Properties = propertyBag,
Actions = CreateActions(entityInstanceContext)
};
if (writeContext.EntitySet != null)
{
IEntitySetLinkBuilder linkBuilder = SerializerProvider.EdmModel.GetEntitySetLinkBuilder(writeContext.EntitySet);
string idLink = linkBuilder.BuildIdLink(entityInstanceContext);
if (idLink != null)
{
entry.Id = idLink;
}
Uri readLink = linkBuilder.BuildReadLink(entityInstanceContext);
if (readLink != null)
{
entry.ReadLink = readLink;
}
Uri editLink = linkBuilder.BuildEditLink(entityInstanceContext);
if (editLink != null)
{
entry.EditLink = editLink;
}
}
writer.WriteStart(entry);
WriteNavigationLinks(entityInstanceContext, writer, writeContext);
writer.WriteEnd();
}
开发者ID:marojeri,项目名称:aspnetwebstack,代码行数:39,代码来源:ODataEntityTypeSerializer.cs
示例10: AddTypeNameAnnotationAsNeeded
internal static void AddTypeNameAnnotationAsNeeded(ODataEntry entry, IEdmEntitySet entitySet,
ODataMetadataLevel metadataLevel)
{
// ODataLib normally has the caller decide whether or not to serialize properties by leaving properties
// null when values should not be serialized. The TypeName property is different and should always be
// provided to ODataLib to enable model validation. A separate annotation is used to decide whether or not
// to serialize the type name (a null value prevents serialization).
// Note that this annotation should not be used for Atom or JSON verbose formats, as it will interfere with
// the correct default behavior for those formats.
Contract.Assert(entry != null);
// Only add an annotation if we want to override ODataLib's default type name serialization behavior.
if (ShouldAddTypeNameAnnotation(metadataLevel))
{
string typeName;
// Provide the type name to serialize (or null to force it not to serialize).
if (ShouldSuppressTypeNameSerialization(entry, entitySet, metadataLevel))
{
typeName = null;
}
else
{
typeName = entry.TypeName;
}
entry.SetAnnotation<SerializationTypeNameAnnotation>(new SerializationTypeNameAnnotation
{
TypeName = typeName
});
}
}
开发者ID:balajivasudevan,项目名称:aspnetwebstack,代码行数:34,代码来源:ODataEntityTypeSerializer.cs
示例11: WriteOdataEntity
private static void WriteOdataEntity(ITableEntity entity, TableOperationType operationType, OperationContext ctx, ODataWriter writer, TableRequestOptions options)
{
ODataEntry entry = new ODataEntry()
{
Properties = GetPropertiesWithKeys(entity, ctx, operationType, options),
TypeName = "account.sometype"
};
entry.SetAnnotation(new SerializationTypeNameAnnotation { TypeName = null });
writer.WriteStart(entry);
writer.WriteEnd();
writer.Flush();
}
开发者ID:renlesterdg,项目名称:azure-storage-net,代码行数:13,代码来源:TableOperationHttpRequestFactory.cs
示例12: CreateEntry
/// <summary>
/// Creates the <see cref="ODataEntry"/> to be written while writing this entity.
/// </summary>
/// <param name="selectExpandNode">The <see cref="SelectExpandNode"/> describing the response graph.</param>
/// <param name="entityInstanceContext">The context for the entity instance being written.</param>
/// <returns>The created <see cref="ODataEntry"/>.</returns>
public virtual ODataEntry CreateEntry(SelectExpandNode selectExpandNode, EntityInstanceContext entityInstanceContext)
{
if (selectExpandNode == null)
{
throw Error.ArgumentNull("selectExpandNode");
}
if (entityInstanceContext == null)
{
throw Error.ArgumentNull("entityInstanceContext");
}
string typeName = EntityType.FullName();
ODataEntry entry = new ODataEntry
{
TypeName = typeName,
Properties = CreateStructuralPropertyBag(selectExpandNode.SelectedStructuralProperties, entityInstanceContext),
Actions = CreateODataActions(selectExpandNode.SelectedActions, entityInstanceContext)
};
AddTypeNameAnnotationAsNeeded(entry, entityInstanceContext.EntitySet, entityInstanceContext.SerializerContext.MetadataLevel);
if (entityInstanceContext.EntitySet != null)
{
IEdmModel model = entityInstanceContext.SerializerContext.Model;
EntitySetLinkBuilderAnnotation linkBuilder = model.GetEntitySetLinkBuilder(entityInstanceContext.EntitySet);
EntitySelfLinks selfLinks = linkBuilder.BuildEntitySelfLinks(entityInstanceContext, entityInstanceContext.SerializerContext.MetadataLevel);
if (selfLinks.IdLink != null)
{
entry.Id = selfLinks.IdLink;
}
if (selfLinks.ReadLink != null)
{
entry.ReadLink = selfLinks.ReadLink;
}
if (selfLinks.EditLink != null)
{
entry.EditLink = selfLinks.EditLink;
}
}
return entry;
}
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:52,代码来源:ODataEntityTypeSerializer.cs
示例13: AddTypeNameAnnotationAsNeeded_AddsAnnotation_InJsonLightMetadataMode
public void AddTypeNameAnnotationAsNeeded_AddsAnnotation_InJsonLightMetadataMode()
{
// Arrange
string expectedTypeName = "TypeName";
ODataEntry entry = new ODataEntry
{
TypeName = expectedTypeName
};
// Act
ODataEntityTypeSerializer.AddTypeNameAnnotationAsNeeded(entry, null, ODataMetadataLevel.MinimalMetadata);
// Assert
SerializationTypeNameAnnotation annotation = entry.GetAnnotation<SerializationTypeNameAnnotation>();
Assert.NotNull(annotation); // Guard
Assert.Equal(expectedTypeName, annotation.TypeName);
}
开发者ID:RhysC,项目名称:aspnetwebstack,代码行数:17,代码来源:ODataEntityTypeSerializerTests.cs
示例14: WriteObjectInline_WritesODataEntryFrom_CreateEntry
public void WriteObjectInline_WritesODataEntryFrom_CreateEntry()
{
// Arrange
ODataEntry entry = new ODataEntry();
Mock<ODataEntityTypeSerializer> serializer = new Mock<ODataEntityTypeSerializer>(_serializer.EdmType, _serializerProvider);
Mock<ODataWriter> writer = new Mock<ODataWriter>();
serializer.Setup(s => s.CreateEntry(It.IsAny<SelectExpandNode>(), It.IsAny<EntityInstanceContext>())).Returns(entry);
serializer.CallBase = true;
writer.Setup(s => s.WriteStart(entry)).Verifiable();
// Act
serializer.Object.WriteObjectInline(_customer, writer.Object, _writeContext);
// Assert
writer.Verify();
}
开发者ID:RhysC,项目名称:aspnetwebstack,代码行数:18,代码来源:ODataEntityTypeSerializerTests.cs
示例15: VerifyCanWriteStartEntry
/// <summary>
/// Verifies that calling WriteStart entry is valid.
/// </summary>
/// <param name="synchronousCall">true if the call is to be synchronous; false otherwise.</param>
/// <param name="entry">Entry/item to write.</param>
private void VerifyCanWriteStartEntry(bool synchronousCall, ODataEntry entry)
{
this.VerifyNotDisposed();
this.VerifyCallAllowed(synchronousCall);
if (this.State != WriterState.NavigationLink)
{
ExceptionUtils.CheckArgumentNotNull(entry, "entry");
}
}
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:15,代码来源:ODataWriterCore.cs
示例16: EndEntry
/// <summary>
/// Finish writing an entry.
/// </summary>
/// <param name="entry">The entry to write.</param>
protected abstract void EndEntry(ODataEntry entry);
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:5,代码来源:ODataWriterCore.cs
示例17: CreateEntryScope
/// <summary>
/// Create a new entry scope.
/// </summary>
/// <param name="entry">The entry for the new scope.</param>
/// <param name="skipWriting">true if the content of the scope to create should not be written.</param>
/// <returns>The newly create scope.</returns>
protected abstract EntryScope CreateEntryScope(ODataEntry entry, bool skipWriting);
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:7,代码来源:ODataWriterCore.cs
示例18: WriteObjectInline_WritesODataNavigationLinksFrom_CreateNavigationLinks
public void WriteObjectInline_WritesODataNavigationLinksFrom_CreateNavigationLinks()
{
// Arrange
ODataNavigationLink[] navigationLinks = new[] { new ODataNavigationLink(), new ODataNavigationLink() };
ODataEntry entry = new ODataEntry();
Mock<ODataWriter> writer = new Mock<ODataWriter>();
Mock<ODataEntityTypeSerializer> serializer = new Mock<ODataEntityTypeSerializer>(_serializer.EdmType, new DefaultODataSerializerProvider());
writer.Setup(s => s.WriteStart(navigationLinks[0])).Verifiable();
writer.Setup(s => s.WriteStart(navigationLinks[1])).Verifiable();
serializer.Setup(s => s.CreateEntry(It.IsAny<EntityInstanceContext>(), _writeContext)).Returns(new ODataEntry());
serializer.Setup(s => s.CreateNavigationLinks(It.IsAny<EntityInstanceContext>(), _writeContext)).Returns(navigationLinks);
serializer.CallBase = true;
// Act
serializer.Object.WriteObjectInline(new object(), writer.Object, _writeContext);
// Assert
writer.Verify();
}
开发者ID:balajivasudevan,项目名称:aspnetwebstack,代码行数:20,代码来源:ODataEntityTypeSerializerTests.cs
示例19: WriteStartEntryImplementation
/// <summary>
/// Start writing an entry - implementation of the actual functionality.
/// </summary>
/// <param name="entry">Entry/item to write.</param>
private void WriteStartEntryImplementation(ODataEntry entry)
{
this.StartPayloadInStartState();
this.CheckForNavigationLinkWithContent(ODataPayloadKind.Entry);
this.EnterScope(WriterState.Entry, entry);
if (!this.SkipWriting)
{
this.IncreaseEntryDepth();
this.InterceptException(() =>
{
if (entry != null)
{
IEdmEntityType entityType = WriterValidationUtils.ValidateEntityTypeName(this.outputContext.Model, entry.TypeName);
// By default validate media resource
// In WCF DS Server mode, validate media resource (in writers)
// In WCF DS Client mode, do not validate media resource
bool validateMediaResource = this.outputContext.UseDefaultFormatBehavior || this.outputContext.UseServerFormatBehavior;
ValidationUtils.ValidateEntryMetadata(entry, entityType, this.outputContext.Model, validateMediaResource);
NavigationLinkScope parentNavigationLinkScope = this.ParentNavigationLinkScope;
if (parentNavigationLinkScope != null)
{
WriterValidationUtils.ValidateEntryInExpandedLink(entityType, parentNavigationLinkScope.NavigationPropertyType);
}
// Validate the consistenty of entity types in feeds
if (this.CurrentFeedValidator != null)
{
this.CurrentFeedValidator.ValidateEntry(entityType);
}
((EntryScope)this.CurrentScope).EntityType = entityType;
WriterValidationUtils.ValidateEntryAtStart(entry);
}
this.StartEntry(entry);
});
}
}
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:45,代码来源:ODataWriterCore.cs
示例20: CreateODataEntry
private ODataEntry CreateODataEntry(IGraph resultsGraph, string entryResource, string entryType)
{
var idPrefix = _map.GetResourceUriPrefix(entryType);
if (!entryResource.StartsWith(idPrefix))
{
// Now we have a problem
throw new Exception("Cannot create entry feed for resource " + entryResource +
". Resource URI does not start with the expected prefix " + idPrefix);
}
var resourceId = entryResource.Substring(idPrefix.Length);
var odataLink = _baseUri + _map.GetTypeSet(entryType) + "('" + resourceId + "')";
var entry = new ODataEntry
{
TypeName = entryType,
ReadLink = new Uri(odataLink),
Id = odataLink
};
var subject = resultsGraph.CreateUriNode(UriFactory.Create(entryResource));
var properties = new List<ODataProperty>();
var identifierPropertyMapping = _map.GetIdentifierPropertyMapping(entryType);
if (identifierPropertyMapping != null)
{
properties.Add(new ODataProperty{Name=identifierPropertyMapping.Name, Value=resourceId});
}
foreach (var propertyMapping in _map.GetStructuralPropertyMappings(entryType))
{
var predicate = resultsGraph.CreateUriNode(UriFactory.Create(propertyMapping.Uri));
var match = resultsGraph.GetTriplesWithSubjectPredicate(subject, predicate).FirstOrDefault();
if (match != null)
{
if (match.Object is LiteralNode)
{
var newProperty = new ODataProperty
{
Name = propertyMapping.Name,
Value = GetValue(match.Object, propertyMapping.PropertyType)
};
properties.Add(newProperty);
}
else if (match.Object is UriNode && propertyMapping.PropertyType.IsPrimitive())
{
var newProperty = new ODataProperty()
{
Name = propertyMapping.Name,
Value = GetValue(match.Object, propertyMapping.PropertyType)
};
properties.Add(newProperty);
}
}
}
if (_writerSettings.Version == null || _writerSettings.Version >= ODataVersion.V3)
{
var associationLinks = new List<ODataAssociationLink>();
foreach (var assocMap in _map.GetAssociationPropertyMappings(entryType))
{
var predicate = resultsGraph.CreateUriNode(UriFactory.Create(assocMap.Uri));
bool hasMatch = false;
if (assocMap.IsInverse)
{
hasMatch = resultsGraph.GetTriplesWithPredicateObject(predicate, subject).Any();
}
else
{
hasMatch = resultsGraph.GetTriplesWithSubjectPredicate(subject, predicate).Any();
}
// TODO: May need to be more specific here to catch inverse/forward versions of the same
// RDF property being mapped to two different OData properties (e.g. broader and narrower on a category)
// This quick hack will work for now though:
//bool hasMatch = resultsGraph.GetTriplesWithPredicate(resultsGraph.CreateUriNode(UriFactory.Create(assocMap.Uri))).Any();
if (hasMatch)
{
associationLinks.Add(new ODataAssociationLink
{
Name = assocMap.Name,
Url = new Uri(odataLink + "/$links/" + assocMap.Name)
});
}
}
entry.AssociationLinks = associationLinks;
}
entry.Properties = properties;
return entry;
}
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:89,代码来源:ODataFeedGenerator.cs
注:本文中的Microsoft.Data.OData.ODataEntry类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论