本文整理汇总了C#中Microsoft.OData.Edm.Library.EdmAction类的典型用法代码示例。如果您正苦于以下问题:C# EdmAction类的具体用法?C# EdmAction怎么用?C# EdmAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EdmAction类属于Microsoft.OData.Edm.Library命名空间,在下文中一共展示了EdmAction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VerifyNullableIsWrittenInChildReturnTypeElementForCollectionElementType
public void VerifyNullableIsWrittenInChildReturnTypeElementForCollectionElementType()
{
var action = new EdmAction("Default.Namespace", "Checkout", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetString(isUnbounded: false, maxLength: 10, isUnicode: false, isNullable: false)));
VisitAndVerifyXml(
(visitor) => visitor.VisitSchemaElement(action),
@"<Action Name=""Checkout""><ReturnType Type=""Collection(Edm.String)"" Nullable=""false"" MaxLength=""10"" Unicode=""false"" /></Action>");
}
示例2: VerifyNoReturnTypeElementIsWrittenWhenNoReturnTypeIsProvided
public void VerifyNoReturnTypeElementIsWrittenWhenNoReturnTypeIsProvided()
{
var action = new EdmAction("Default.Namespace", "Checkout", null);
VisitAndVerifyXml(
(visitor) => visitor.VisitSchemaElement(action),
@"<Action Name=""Checkout"" />");
}
示例3: VerifyPrimitiveReturnTypeDefinedInChildReturnTypeElement
public void VerifyPrimitiveReturnTypeDefinedInChildReturnTypeElement()
{
var action = new EdmAction("Default.Namespace", "Checkout", EdmCoreModel.Instance.GetString(false));
VisitAndVerifyXml(
(visitor) => visitor.VisitSchemaElement(action),
@"<Action Name=""Checkout""><ReturnType Type=""Edm.String"" Nullable=""false"" /></Action>");
}
示例4: EdmActionConstructorWithNullReturnTypeShouldNotThrow
public void EdmActionConstructorWithNullReturnTypeShouldNotThrow()
{
var edmAction = new EdmAction(defaultNamespaceName, checkout, null);
edmAction.Namespace.Should().Be(defaultNamespaceName);
edmAction.Name.Should().Be(checkout);
edmAction.ReturnType.Should().BeNull();
}
示例5: ExtendModelAsync
public Task ExtendModelAsync(
ModelContext context,
CancellationToken cancellationToken)
{
var model = context.Model;
var entityContainer = model.EntityContainer as EdmEntityContainer;
foreach (ActionMethodInfo actionInfo in this.ActionInfos)
{
var returnTypeReference = ConventionalActionProvider.GetReturnTypeReference(actionInfo.Method.ReturnType);
var action = new EdmAction(entityContainer.Namespace, actionInfo.ActionName, returnTypeReference);
foreach (ParameterInfo parameter in actionInfo.Method.GetParameters())
{
EdmOperationParameter actionParam = new EdmOperationParameter(
action,
parameter.Name,
ConventionalActionProvider.GetTypeReference(parameter.ParameterType));
action.AddParameter(actionParam);
}
model.AddElement(action);
if (!action.IsBound)
{
EdmActionImport actionImport = new EdmActionImport(entityContainer, action.Name, action);
entityContainer.AddElement(actionImport);
}
}
return Task.FromResult<object>(null);
}
示例6: VerifyOperationParameterWritten
public void VerifyOperationParameterWritten()
{
var action = new EdmAction("Default.Namespace", "Checkout", null);
action.AddParameter("firstParameter", EdmCoreModel.Instance.GetSingle(true));
VisitAndVerifyXml(
(visitor) => visitor.VisitSchemaElement(action),
@"<Action Name=""Checkout""><Parameter Name=""firstParameter"" Type=""Edm.Single"" /></Action>");
}
示例7: VerifyEntityReturnTypeDefinedInChildReturnTypeElement
public void VerifyEntityReturnTypeDefinedInChildReturnTypeElement()
{
var entityType = new EdmEntityType("NS.ds", "EntityType");
var action = new EdmAction("Default.Namespace", "Checkout", new EdmEntityTypeReference(entityType, false));
VisitAndVerifyXml(
(visitor) => visitor.VisitSchemaElement(action),
@"<Action Name=""Checkout""><ReturnType Type=""NS.ds.EntityType"" Nullable=""false"" /></Action>");
}
示例8: ODataJsonLightParameterReaderTests
public ODataJsonLightParameterReaderTests()
{
referencedModel = new EdmModel();
referencedModel.Fixup();
this.action = new EdmAction("FQ.NS", "ActionImport", null);
referencedModel.AddElement(this.action);
this.model = TestUtils.WrapReferencedModelsToMainModel("TestModel", "DefaultContainer", referencedModel);
}
示例9: Init
public void Init()
{
referencedModel = new EdmModel();
referencedModel.Fixup();
this.action = new EdmAction("FQ.NS", "ActionImport", null);
referencedModel.AddElement(this.action);
this.model = TestUtils.WrapReferencedModelsToMainModel("TestModel", "DefaultContainer", referencedModel);
}
示例10: EdmActionImportConstructorShouldDefaultNonSpecifiedPropertiesCorrectly
public void EdmActionImportConstructorShouldDefaultNonSpecifiedPropertiesCorrectly()
{
var edmAction = new EdmAction("DefaultNamespace", "Checkout", this.boolType);
var edmActionImport = new EdmActionImport(this.entityContainer, "CheckoutImport", edmAction, null);
edmActionImport.Name.Should().Be("CheckoutImport");
edmActionImport.EntitySet.Should().BeNull();
edmActionImport.Container.Should().Be(this.entityContainer);
edmActionImport.Action.Should().Be(edmAction);
}
示例11: GetActionLinkBuilder_ReturnsDefaultActionLinkBuilder_IfNotSet
public void GetActionLinkBuilder_ReturnsDefaultActionLinkBuilder_IfNotSet()
{
// Arrange
IEdmModel model = new EdmModel();
IEdmEntityContainer container = new EdmEntityContainer("NS", "Container");
IEdmAction action = new EdmAction("NS", "Action", returnType: null);
Assert.NotNull(model.GetActionLinkBuilder(action));
}
示例12: CreateServiceEdmModel
public static IEdmModel CreateServiceEdmModel(string ns)
{
EdmModel model = new EdmModel();
var defaultContainer = new EdmEntityContainer(ns, "PerfInMemoryContainer");
model.AddElement(defaultContainer);
var personType = new EdmEntityType(ns, "Person");
var personIdProperty = new EdmStructuralProperty(personType, "PersonID", EdmCoreModel.Instance.GetInt32(false));
personType.AddProperty(personIdProperty);
personType.AddKeys(new IEdmStructuralProperty[] { personIdProperty });
personType.AddProperty(new EdmStructuralProperty(personType, "FirstName", EdmCoreModel.Instance.GetString(false)));
personType.AddProperty(new EdmStructuralProperty(personType, "LastName", EdmCoreModel.Instance.GetString(false)));
personType.AddProperty(new EdmStructuralProperty(personType, "MiddleName", EdmCoreModel.Instance.GetString(true)));
personType.AddProperty(new EdmStructuralProperty(personType, "Age", EdmCoreModel.Instance.GetInt32(false)));
model.AddElement(personType);
var simplePersonSet = new EdmEntitySet(defaultContainer, "SimplePeopleSet", personType);
defaultContainer.AddElement(simplePersonSet);
var largetPersonSet = new EdmEntitySet(defaultContainer, "LargePeopleSet", personType);
defaultContainer.AddElement(largetPersonSet);
var addressType = new EdmComplexType(ns, "Address");
addressType.AddProperty(new EdmStructuralProperty(addressType, "Street", EdmCoreModel.Instance.GetString(false)));
addressType.AddProperty(new EdmStructuralProperty(addressType, "City", EdmCoreModel.Instance.GetString(false)));
addressType.AddProperty(new EdmStructuralProperty(addressType, "PostalCode", EdmCoreModel.Instance.GetString(false)));
model.AddElement(addressType);
var companyType = new EdmEntityType(ns, "Company");
var companyId = new EdmStructuralProperty(companyType, "CompanyID", EdmCoreModel.Instance.GetInt32(false));
companyType.AddProperty(companyId);
companyType.AddKeys(companyId);
companyType.AddProperty(new EdmStructuralProperty(companyType, "Name", EdmCoreModel.Instance.GetString(true)));
companyType.AddProperty(new EdmStructuralProperty(companyType, "Address", new EdmComplexTypeReference(addressType, true)));
companyType.AddProperty(new EdmStructuralProperty(companyType, "Revenue", EdmCoreModel.Instance.GetInt32(false)));
model.AddElement(companyType);
var companySet = new EdmEntitySet(defaultContainer, "CompanySet", companyType);
defaultContainer.AddElement(companySet);
var companyEmployeeNavigation = companyType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo()
{
Name = "Employees",
Target = personType,
TargetMultiplicity = EdmMultiplicity.Many
});
companySet.AddNavigationTarget(companyEmployeeNavigation, largetPersonSet);
// ResetDataSource
var resetDataSourceAction = new EdmAction(ns, "ResetDataSource", null, false, null);
model.AddElement(resetDataSourceAction);
defaultContainer.AddActionImport(resetDataSourceAction);
return model;
}
示例13: EnsureActionImportIsAddedAndWithCorrectSuppliedName
public void EnsureActionImportIsAddedAndWithCorrectSuppliedName()
{
EdmEntityContainer container = new EdmEntityContainer("Default", "Container");
EdmAction action = new EdmAction("DS", "TestAction", EdmCoreModel.Instance.GetBoolean(false));
var actionImport = container.AddActionImport("OtherName", action);
actionImport.Action.Should().Be(action);
actionImport.Name.Should().Be("OtherName");
container.Elements.ToArray()[0].Should().Be(actionImport);
}
示例14: EdmActionConstructorShouldDefaultNonSpecifiedPropertiesCorrectly
public void EdmActionConstructorShouldDefaultNonSpecifiedPropertiesCorrectly()
{
var edmAction = new EdmAction(defaultNamespaceName, checkout, this.boolType);
edmAction.Namespace.Should().Be(defaultNamespaceName);
edmAction.Name.Should().Be(checkout);
edmAction.ReturnType.Should().Be(this.boolType);
edmAction.EntitySetPath.Should().BeNull();
edmAction.IsBound.Should().BeFalse();
edmAction.SchemaElementKind.Should().Be(EdmSchemaElementKind.Action);
}
示例15: EdmActionConstructorShouldHaveSpecifiedConstructorValues
public void EdmActionConstructorShouldHaveSpecifiedConstructorValues()
{
var entitySetPath = new EdmPathExpression("Param1/Nav");
var edmAction = new EdmAction(defaultNamespaceName, checkout, this.boolType, true, entitySetPath);
edmAction.AddParameter(new EdmOperationParameter(edmAction, "Param1", new EdmEntityTypeReference(personType, false)));
edmAction.Namespace.Should().Be(defaultNamespaceName);
edmAction.Name.Should().Be(checkout);
edmAction.ReturnType.Should().Be(this.boolType);
edmAction.EntitySetPath.Should().Be(entitySetPath);
edmAction.IsBound.Should().BeTrue();
edmAction.SchemaElementKind.Should().Be(EdmSchemaElementKind.Action);
}