本文整理汇总了C#中ODataEntry.AddAction方法的典型用法代码示例。如果您正苦于以下问题:C# ODataEntry.AddAction方法的具体用法?C# ODataEntry.AddAction怎么用?C# ODataEntry.AddAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ODataEntry
的用法示例。
在下文中一共展示了ODataEntry.AddAction方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InjectMetadataBuilderShouldNotSetBuilderOnEntryActions
public void InjectMetadataBuilderShouldNotSetBuilderOnEntryActions()
{
var entry = new ODataEntry();
var builder = new TestEntityMetadataBuilder(entry);
var action1 = new ODataAction { Metadata = new Uri("http://service/$metadata#action1", UriKind.Absolute) };
var action2 = new ODataAction { Metadata = new Uri("http://service/$metadata#action2", UriKind.Absolute) };
entry.AddAction(action1);
entry.AddAction(action2);
testSubject.InjectMetadataBuilder(entry, builder);
action1.GetMetadataBuilder().Should().BeNull();
action2.GetMetadataBuilder().Should().BeNull();
}
示例2: InjectMetadataBuilderShouldSetBuilderOnEntryActions
public void InjectMetadataBuilderShouldSetBuilderOnEntryActions()
{
var entry = new ODataEntry();
var builder = new TestEntityMetadataBuilder(entry);
var action1 = new ODataAction { Metadata = new Uri(MetadataDocumentUri, "#action1") };
var action2 = new ODataAction { Metadata = new Uri(MetadataDocumentUri, "#action2") };
entry.AddAction(action1);
entry.AddAction(action2);
testSubject.InjectMetadataBuilder(entry, builder);
action1.GetMetadataBuilder().Should().BeSameAs(builder);
action2.GetMetadataBuilder().Should().BeSameAs(builder);
}
示例3: ShouldWriteActionForRequestEntryPayloadWithUserModel
public void ShouldWriteActionForRequestEntryPayloadWithUserModel()
{
ODataEntry entry = new ODataEntry { TypeName = "NS.MyDerivedEntityType" };
entry.AddAction(new ODataAction { Metadata = new Uri("#Action1", UriKind.Relative) });
const string expectedPayload = "{\"@odata.type\":\"#NS.MyDerivedEntityType\",\"#Action1\":{}}";
Action action = () => this.WriteNestedItemsAndValidatePayload(entitySet: null, entityType: null, nestedItemToWrite: new[] { entry }, expectedPayload: expectedPayload, writingResponse: false);
action.ShouldThrow<ODataException>().WithMessage(Strings.WriterValidationUtils_OperationInRequest("#Action1"));
}
示例4: NoOpMetadataBuilderShouldReturnActionsSetByUser
public void NoOpMetadataBuilderShouldReturnActionsSetByUser()
{
ODataAction action = new ODataAction()
{
Metadata = new Uri("http://example.com/$metadata#Action"),
Target = new Uri("http://example.com/Action"),
Title = "ActionTitle"
};
ODataEntry entry = new ODataEntry();
entry.AddAction(action);
new NoOpEntityMetadataBuilder(entry).GetActions()
.Should().ContainSingle(a => a == action);
// Verify that the action information wasn't removed or changed.
action.Metadata.Should().Be(new Uri("http://example.com/$metadata#Action"));
action.Target.Should().Be(new Uri("http://example.com/Action"));
action.Title.Should().Be("ActionTitle");
}
示例5: ShouldWriteActionForResponseEntryPayloadWithUserModel
public void ShouldWriteActionForResponseEntryPayloadWithUserModel()
{
ODataEntry entry = new ODataEntry { TypeName = "NS.MyDerivedEntityType" };
entry.AddAction(new ODataAction { Metadata = new Uri("#Action1", UriKind.Relative) });
const string expectedPayload = "{\"@odata.context\":\"http://odata.org/test/$metadata#MySet/$entity\",\"@odata.type\":\"#NS.MyDerivedEntityType\",\"#Action1\":{}}";
this.WriteNestedItemsAndValidatePayload(entitySet: this.entitySet, entityType: null, nestedItemToWrite: new[] { entry }, expectedPayload: expectedPayload, writingResponse: true);
}