本文整理汇总了C#中Microsoft.OData.Core.ODataEntry类的典型用法代码示例。如果您正苦于以下问题:C# ODataEntry类的具体用法?C# ODataEntry怎么用?C# ODataEntry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ODataEntry类属于Microsoft.OData.Core命名空间,在下文中一共展示了ODataEntry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: MaterializedEntityArgs
/// <summary>
/// Initializes a new instance of the <see cref="MaterializedEntityArgs"/> class.
/// </summary>
/// <param name="entry">The entry.</param>
/// <param name="entity">The entity.</param>
public MaterializedEntityArgs(ODataEntry entry, object entity)
{
Util.CheckArgumentNull(entry, "entry");
Util.CheckArgumentNull(entity, "entity");
this.Entry = entry;
this.Entity = entity;
}
开发者ID:AlineGuan,项目名称:odata.net,代码行数:12,代码来源:MaterializedEntityArgs.cs
示例2: TestInit
public void TestInit()
{
this.entry = new ODataEntry {TypeName = ActualEntityType.FullName()};
this.typeContext = new TestFeedAndEntryTypeContext();
this.entryMetadataContextWithoutModel = ODataEntryMetadataContext.Create(this.entry, this.typeContext, new ODataFeedAndEntrySerializationInfo(), /*actualEntityType*/null, new TestMetadataContext(), SelectedPropertiesNode.EntireSubtree);
this.entryMetadataContextWithModel = ODataEntryMetadataContext.Create(this.entry, this.typeContext, /*serializationInfo*/null, ActualEntityType, new TestMetadataContext(), SelectedPropertiesNode.EntireSubtree);
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:7,代码来源:ODataEntryMetadataContextTest.cs
示例3: CreateEntryWithKeyAsSegmentConvention
private static ODataEntry CreateEntryWithKeyAsSegmentConvention(bool addAnnotation, bool? useKeyAsSegment)
{
var model = new EdmModel();
var container = new EdmEntityContainer("Fake", "Container");
model.AddElement(container);
if (addAnnotation)
{
model.AddVocabularyAnnotation(new EdmAnnotation(container, UrlConventionsConstants.ConventionTerm, UrlConventionsConstants.KeyAsSegmentAnnotationValue));
}
EdmEntityType entityType = new EdmEntityType("Fake", "FakeType");
entityType.AddKeys(entityType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32));
model.AddElement(entityType);
var entitySet = new EdmEntitySet(container, "FakeSet", entityType);
container.AddElement(entitySet);
var metadataContext = new ODataMetadataContext(
true,
ODataReaderBehavior.DefaultBehavior.OperationsBoundToEntityTypeMustBeContainerQualified,
new EdmTypeReaderResolver(model, ODataReaderBehavior.DefaultBehavior),
model,
new Uri("http://temp.org/$metadata"),
null /*requestUri*/);
var thing = new ODataEntry {Properties = new[] {new ODataProperty {Name = "Id", Value = 1}}};
thing.SetAnnotation(new ODataTypeAnnotation(entitySet, entityType));
thing.MetadataBuilder = metadataContext.GetEntityMetadataBuilderForReader(new TestJsonLightReaderEntryState { Entry = thing, SelectedProperties = new SelectedPropertiesNode("*")}, useKeyAsSegment);
return thing;
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:30,代码来源:KeyAsSegmentTemplateIntegrationTests.cs
示例4: CreateODataEntry
/// <summary>
/// Creates a new ODataEntry from the specified entity set, instance, and type.
/// </summary>
/// <param name="entitySet">Entity set for the new entry.</param>
/// <param name="value">Entity instance for the new entry.</param>
/// <param name="entityType">Entity type for the new entry.</param>
/// <returns>New ODataEntry with the specified entity set and type, property values from the specified instance.</returns>
internal static ODataEntry CreateODataEntry(IEdmEntitySet entitySet, IEdmStructuredValue value, IEdmEntityType entityType)
{
var entry = new ODataEntry();
entry.SetAnnotation(new ODataTypeAnnotation(entitySet, entityType));
entry.Properties = value.PropertyValues.Select(p =>
{
object propertyValue;
if (p.Value.ValueKind == EdmValueKind.Null)
{
propertyValue = null;
}
else if (p.Value is IEdmPrimitiveValue)
{
propertyValue = ((IEdmPrimitiveValue)p.Value).ToClrValue();
}
else
{
Assert.Fail("Test only currently supports creating ODataEntry from IEdmPrimitiveValue instances.");
return null;
}
return new ODataProperty() { Name = p.Name, Value = propertyValue };
});
return entry;
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:33,代码来源:TestUtils.cs
示例5: ConvertToODataEntry
/// <summary>
/// Converts an item from the data store into an ODataEntry.
/// </summary>
/// <param name="element">The item to convert.</param>
/// <param name="entitySet">The entity set 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, IEdmEntitySet entitySet, ODataVersion targetVersion)
{
IEdmEntityType entityType = entitySet.EntityType();
Uri entryUri = BuildEntryUri(element, entitySet, targetVersion);
var entry = new ODataEntry
{
// writes out the edit link including the service base uri , e.g.: http://<serviceBase>/Customers('ALFKI')
EditLink = entryUri,
// writes out the self link including the service base uri , e.g.: http://<serviceBase>/Customers('ALFKI')
ReadLink = entryUri,
// we use the EditLink as the Id for this entity to maintain convention,
Id = entryUri,
// writes out the <category term='Customer'/> element
TypeName = element.GetType().Namespace + "." + entityType.Name,
Properties = entityType.StructuralProperties().Select(p => ConvertToODataProperty(element, p.Name)),
};
return entry;
}
开发者ID:AlineGuan,项目名称:odata.net,代码行数:32,代码来源:ODataObjectModelConverter.cs
示例6: DataServiceODataWriterEntryArgs
/// <summary>
/// Creates a new instance of DataServiceODataWriterEntryArgs
/// </summary>
/// <param name="entry">ODataEntry instance.</param>
/// <param name="entityInstance">Entity instance that is getting serialized.</param>
/// <param name="operationContext">DataServiceOperationContext instance.</param>
public DataServiceODataWriterEntryArgs(ODataEntry entry, object entityInstance, DataServiceOperationContext operationContext)
{
Debug.Assert(operationContext != null, "operationContext != null");
this.Entry = entry;
this.Instance = entityInstance;
this.OperationContext = operationContext;
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:13,代码来源:DataServiceODataWriterEntryArgs.cs
示例7: Run
/// <summary>Runs this plan.</summary>
/// <param name="materializer">Materializer under which materialization should happen.</param>
/// <param name="entry">Root entry to materialize.</param>
/// <param name="expectedType">Expected type for the <paramref name="entry"/>.</param>
/// <returns>The materialized object.</returns>
internal object Run(ODataEntityMaterializer materializer, ODataEntry entry, Type expectedType)
{
Debug.Assert(materializer != null, "materializer != null");
Debug.Assert(entry != null, "entry != null");
return this.Plan(materializer, entry, expectedType);
}
开发者ID:AlineGuan,项目名称:odata.net,代码行数:12,代码来源:ProjectionPlan.cs
示例8: CustomizeEntry
/// <summary>
/// This method is used to do some customerization according to the incoming headers.
/// </summary>
/// <param name="incomingHeaders">The headers in the request.</param>
/// <param name="entry">The entry that need to customize.</param>
private static void CustomizeEntry(Dictionary<string, string> incomingHeaders, ODataEntry entry)
{
if (null != incomingHeaders)
{
var stringOfKey = "Test_ODataEntryFieldToModify";
if (incomingHeaders.ContainsKey(stringOfKey))
{
var longOfCurrentTime = DateTime.UtcNow.Ticks;
var uri = new Uri("http://potato" + longOfCurrentTime);//create a URL that points to a none exist host
var stringOfValue = incomingHeaders[stringOfKey];
if (stringOfValue.Equals("EditLink", StringComparison.CurrentCultureIgnoreCase))
{
entry.EditLink = uri;
}
else if (stringOfValue.Equals("ReadLink", StringComparison.CurrentCultureIgnoreCase))
{
entry.ReadLink = uri;
}
else if (stringOfValue.Equals("Id", StringComparison.CurrentCultureIgnoreCase))
{
entry.Id = uri;
}
else if (stringOfValue.Equals("IsTransient", StringComparison.CurrentCultureIgnoreCase))
{
entry.IsTransient = true;
}
else if (stringOfValue.Equals("ReadOnly", StringComparison.CurrentCultureIgnoreCase))
{
entry.ReadLink = new Uri("People(1)", UriKind.Relative);
entry.EditLink = null;
}
}
}
}
开发者ID:vebin,项目名称:odata.net,代码行数:39,代码来源:ResponseWriter.cs
示例9: WritingEntryArgs
/// <summary>
/// Initializes a new instance of the <see cref="WritingEntryArgs"/> class.
/// </summary>
/// <param name="entry">The entry.</param>
/// <param name="entity">The entity.</param>
public WritingEntryArgs(ODataEntry entry, object entity)
{
Util.CheckArgumentNull(entry, "entry");
Util.CheckArgumentNull(entity, "entity");
this.Entry = entry;
this.Entity = entity;
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:12,代码来源:WritingEntryArgs.cs
示例10: InjectMetadataBuilderShouldSetBuilderOnEntry
public void InjectMetadataBuilderShouldSetBuilderOnEntry()
{
var entry = new ODataEntry();
var builder = new TestEntityMetadataBuilder(entry);
testSubject.InjectMetadataBuilder(entry, builder);
entry.MetadataBuilder.Should().BeSameAs(builder);
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:7,代码来源:JsonNoMetadataLevelTests.cs
示例11: ReadLinkShouldNotBeOmittedWhenNotIdenticalToEditLink
public void ReadLinkShouldNotBeOmittedWhenNotIdenticalToEditLink()
{
DateTimeOffset updatedTime = DateTimeOffset.UtcNow;
var entry = new ODataEntry
{
Id = new Uri("http://test.org/EntitySet('1')"),
EditLink = new Uri("http://test.org/EntitySet('1')/edit"),
ReadLink = new Uri("http://test.org/EntitySet('1')/read")
};
entry.SetAnnotation(new AtomEntryMetadata() { Updated = updatedTime });
string actual = this.WriteAtomEntry(entry);
string expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<entry xmlns=\"http://www.w3.org/2005/Atom\" xmlns:d=\"http://docs.oasis-open.org/odata/ns/data\" xmlns:m=\"http://docs.oasis-open.org/odata/ns/metadata\" xmlns:georss=\"http://www.georss.org/georss\" xmlns:gml=\"http://www.opengis.net/gml\" m:context=\"http://temp.org/$metadata#EntitySet/$entity\">" +
"<id>http://test.org/EntitySet('1')</id>" +
"<link rel=\"edit\" href=\"http://test.org/EntitySet('1')/edit\" />" +
"<link rel=\"self\" href=\"http://test.org/EntitySet('1')/read\" />" +
"<title />" +
"<updated>" + ODataAtomConvert.ToAtomString(updatedTime) + "</updated>" +
"<author>" +
"<name />" +
"</author>" +
"<content type=\"application/xml\" />" +
"</entry>";
Assert.AreEqual(expected, actual);
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:25,代码来源:ODataAtomWriterIntegrationTests.cs
示例12: WriteCompletedAsyncResponse
public void WriteCompletedAsyncResponse()
{
var asyncWriter = this.TestInit();
var innerMessage = asyncWriter.CreateResponseMessage();
innerMessage.StatusCode = 200;
innerMessage.SetHeader("Content-Type", "application/json");
var settings = new ODataMessageWriterSettings();
settings.SetServiceDocumentUri(new Uri(ServiceDocumentUri));
settings.DisableMessageStreamDisposal = true;
using (var innerMessageWriter = new ODataMessageWriter(innerMessage, settings, this.userModel))
{
var entryWriter = innerMessageWriter.CreateODataEntryWriter(singleton, testType);
var entry = new ODataEntry() {TypeName = "NS.Test", Properties = new[] {new ODataProperty() {Name = "Id", Value = 1}}};
entryWriter.WriteStart(entry);
entryWriter.WriteEnd();
}
asyncWriter.Flush();
var payload = this.TestFinish();
Assert.AreEqual("HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nOData-Version: 4.0\r\n\r\n{\"@odata.context\":\"http://host/service/$metadata#MySingleton\",\"Id\":1}", payload);
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:25,代码来源:ODataAsyncWriterTests.cs
示例13: ShortIntegrationTestToValidateEntryShouldBeRead
public void ShortIntegrationTestToValidateEntryShouldBeRead()
{
var odataEntry = new ODataEntry() { Id = new Uri("http://services.odata.org/OData/OData.svc/Customers(0)") };
odataEntry.Properties = new ODataProperty[] { new ODataProperty() { Name = "ID", Value = 0 }, new ODataProperty() { Name = "Description", Value = "Simple Stuff" } };
var clientEdmModel = new ClientEdmModel(ODataProtocolVersion.V4);
var context = new DataServiceContext();
MaterializerEntry.CreateEntry(odataEntry, ODataFormat.Atom, true, clientEdmModel);
var materializerContext = new TestMaterializerContext() {Model = clientEdmModel, Context = context};
var adapter = new EntityTrackingAdapter(new TestEntityTracker(), MergeOption.OverwriteChanges, clientEdmModel, context);
QueryComponents components = new QueryComponents(new Uri("http://foo.com/Service"), new Version(4, 0), typeof(Customer), null, new Dictionary<Expression, Expression>());
var entriesMaterializer = new ODataEntriesEntityMaterializer(new ODataEntry[] { odataEntry }, materializerContext, adapter, components, typeof(Customer), null, ODataFormat.Atom);
var customersRead = new List<Customer>();
// This line will call ODataEntityMaterializer.ReadImplementation() which will reconstruct the entity, and will get non-public setter called.
while (entriesMaterializer.Read())
{
customersRead.Add(entriesMaterializer.CurrentValue as Customer);
}
customersRead.Should().HaveCount(1);
customersRead[0].ID.Should().Be(0);
customersRead[0].Description.Should().Be("Simple Stuff");
}
开发者ID:TomDu,项目名称:odata.net,代码行数:26,代码来源:ODataEntriesEntityMaterializerUnitTests.cs
示例14: InitTest
public void InitTest()
{
this.navigationLink = new ODataNavigationLink();
var entry = new ODataEntry
{
TypeName = "ns.DerivedType",
Properties = new[]
{
new ODataProperty{Name = "Id", Value = 1, SerializationInfo = new ODataPropertySerializationInfo{PropertyKind = ODataPropertyKind.Key}},
new ODataProperty{Name = "Name", Value = "Bob", SerializationInfo = new ODataPropertySerializationInfo{PropertyKind = ODataPropertyKind.ETag}}
}
};
var serializationInfo = new ODataFeedAndEntrySerializationInfo { NavigationSourceName = "Set", NavigationSourceEntityTypeName = "ns.BaseType", ExpectedTypeName = "ns.BaseType" };
var typeContext = ODataFeedAndEntryTypeContext.Create(serializationInfo, null, null, null, EdmCoreModel.Instance, true);
var metadataContext = new TestMetadataContext();
var entryMetadataContext = ODataEntryMetadataContext.Create(entry, typeContext, serializationInfo, null, metadataContext, SelectedPropertiesNode.EntireSubtree);
var metadataBuilder = new ODataConventionalEntityMetadataBuilder(entryMetadataContext, metadataContext, new ODataConventionalUriBuilder(ServiceUri, UrlConvention.CreateWithExplicitValue(false)));
this.navigationLinkWithFullBuilder = new ODataNavigationLink { Name = "NavProp" };
this.navigationLinkWithFullBuilder.MetadataBuilder = metadataBuilder;
this.navigationLinkWithNoOpBuilder = new ODataNavigationLink { Name = "NavProp" };
this.navigationLinkWithNoOpBuilder.MetadataBuilder = new NoOpEntityMetadataBuilder(entry);
this.navigationLinkWithNullBuilder = new ODataNavigationLink { Name = "NavProp" };
this.navigationLinkWithNullBuilder.MetadataBuilder = ODataEntityMetadataBuilder.Null;
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:28,代码来源:ODataNavigationLinkTests.cs
示例15: EntryMetadataUrlRoundTrip
public void EntryMetadataUrlRoundTrip()
{
var stream = new MemoryStream();
var writerRequestMemoryMessage = new InMemoryMessage();
writerRequestMemoryMessage.Stream = stream;
writerRequestMemoryMessage.SetHeader("Content-Type", "application/json");
var writerSettings = new ODataMessageWriterSettings() {Version = ODataVersion.V4, DisableMessageStreamDisposal = true};
writerSettings.ODataUri = new ODataUri() {ServiceRoot = new Uri("http://christro.svc/")};
var messageWriter = new ODataMessageWriter((IODataResponseMessage)writerRequestMemoryMessage, writerSettings, this.model);
var organizationSetWriter = messageWriter.CreateODataEntryWriter(this.organizationsSet);
var odataEntry = new ODataEntry(){ TypeName = ModelNamespace + ".Corporation" };
odataEntry.Property("Id", 1);
odataEntry.Property("Name", "");
odataEntry.Property("TickerSymbol", "MSFT");
organizationSetWriter.WriteStart(odataEntry);
organizationSetWriter.WriteEnd();
var readerPayloadInput = Encoding.UTF8.GetString(stream.GetBuffer());
Console.WriteLine(readerPayloadInput);
var readerResponseMemoryMessage = new InMemoryMessage();
readerResponseMemoryMessage.Stream = new MemoryStream(stream.GetBuffer());
readerResponseMemoryMessage.SetHeader("Content-Type", "application/json");
var messageReader = new ODataMessageReader((IODataResponseMessage)readerResponseMemoryMessage, new ODataMessageReaderSettings() {MaxProtocolVersion = ODataVersion.V4, DisableMessageStreamDisposal = true}, this.model);
var organizationReader = messageReader.CreateODataEntryReader(this.organizationsSet, this.organizationsSet.EntityType());
organizationReader.Read().Should().Be(true);
organizationReader.Item.As<ODataEntry>();
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:32,代码来源:MetadataUriRoundTripTests.cs
示例16: CreateEntry
private ODataEntry CreateEntry(int dataSizeKb)
{
var entry = new ODataEntry
{
Id = new Uri("http://www.odata.org/Perf.svc/Item(1)"),
EditLink = new Uri("Item(1)", UriKind.Relative),
ReadLink = new Uri("Item(1)", UriKind.Relative),
TypeName = "PerformanceServices.Edm.ExchangeAttachment.Item",
Properties = new[]
{
new ODataProperty{ Name = "HasAttachments", Value = false},
new ODataProperty{ Name = "Attachments", Value = new ODataCollectionValue
{
TypeName = "Collection(PerformanceServices.Edm.ExchangeAttachment.Attachment)",
Items = dataSizeKb == 0 ? new ODataComplexValue[0]:
Enumerable.Range(0, 1).Select(n => new ODataComplexValue
{
TypeName = "PerformanceServices.Edm.ExchangeAttachment.Attachment",
Properties = new[]
{
new ODataProperty { Name = "Name", Value = "attachment" },
new ODataProperty { Name = "IsInline", Value = false },
new ODataProperty { Name = "LastModifiedTime", Value = new DateTimeOffset(1987, 6, 5, 4, 3, 21, 0, new TimeSpan(0, 0, 3, 0)) },
new ODataProperty { Name = "Content", Value = new byte[dataSizeKb * 1024]},
}
})
}}
}
};
return entry;
}
开发者ID:jetshi0125,项目名称:odata.net,代码行数:32,代码来源:BinaryDataScaleTests.cs
示例17: InjectMetadataBuilderShouldNotSetBuilderOnEntry
public void InjectMetadataBuilderShouldNotSetBuilderOnEntry()
{
var entry = new ODataEntry();
var builder = new TestEntityMetadataBuilder(entry);
testSubject.InjectMetadataBuilder(entry, builder);
entry.MetadataBuilder.Should().BeOfType<NoOpEntityMetadataBuilder>();
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:7,代码来源:JsonMinimalMetadataLevelTests.cs
示例18: SetId
internal void SetId(ODataEntry entry, Func<Uri> computeIdentity)
{
Debug.Assert(entry != null, "entry != null");
if (this.interpreter.ShouldIncludeEntryMetadata(PayloadMetadataKind.Entry.Id))
{
entry.Id = computeIdentity();
}
}
开发者ID:AlineGuan,项目名称:odata.net,代码行数:8,代码来源:PayloadMetadataPropertyManager.cs
示例19: SetETag
internal void SetETag(ODataEntry entry, Func<string> computeETag)
{
Debug.Assert(entry != null, "entry != null");
if (this.interpreter.ShouldIncludeEntryMetadata(PayloadMetadataKind.Entry.ETag))
{
entry.ETag = computeETag();
}
}
开发者ID:AlineGuan,项目名称:odata.net,代码行数:8,代码来源:PayloadMetadataPropertyManager.cs
示例20: ShouldBeAbleToWriteTransientEntry
public void ShouldBeAbleToWriteTransientEntry()
{
IEdmEntityType entityType = GetEntityType();
IEdmEntitySet entitySet = GetEntitySet(entityType);
ODataEntry transientEntry = new ODataEntry() { IsTransient = true };
var actual = WriteJsonLightEntry(true, null, false, transientEntry, entitySet, entityType);
actual.Should().Contain("\"@odata.id\":null");
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:8,代码来源:JsonLightWriterIntegrationTests.cs
注:本文中的Microsoft.OData.Core.ODataEntry类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论