本文整理汇总了C#中Microsoft.OData.Edm.Library.EdmFunction类的典型用法代码示例。如果您正苦于以下问题:C# EdmFunction类的具体用法?C# EdmFunction怎么用?C# EdmFunction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EdmFunction类属于Microsoft.OData.Edm.Library命名空间,在下文中一共展示了EdmFunction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryMatch_ReturnTrue_IfSameFunction
public void TryMatch_ReturnTrue_IfSameFunction()
{
// Arrange
IEdmEntityType returnType = new Mock<IEdmEntityType>().Object;
EdmFunction function = new EdmFunction("NS", "Function", new EdmEntityTypeReference(returnType, isNullable: false));
Dictionary<string, string> parameterValues = new Dictionary<string, string>()
{
{ "Parameter1", "1" },
{ "Parameter2", "2" }
};
Dictionary<string, string> parameterMappings = new Dictionary<string, string>()
{
{ "Parameter1", "{param1}" },
{ "Parameter2", "{param2}" }
};
BoundFunctionPathSegment segment = new BoundFunctionPathSegment(function, model: null, parameterValues: parameterValues);
BoundFunctionPathSegmentTemplate template = new BoundFunctionPathSegmentTemplate(
new BoundFunctionPathSegment(function, model: null, parameterValues: parameterMappings));
// Act
Dictionary<string, object> values = new Dictionary<string,object>();
bool result = template.TryMatch(segment, values);
// Assert
Assert.True(result);
Assert.Equal(2, values.Count);
Assert.Equal("1", values["param1"]);
Assert.Equal("2", values["param2"]);
}
示例2: FunctionImportShouldProduceCorrectFullyQualifiedNameAndNotHaveParameters
public void FunctionImportShouldProduceCorrectFullyQualifiedNameAndNotHaveParameters()
{
var function = new EdmFunction("d.s", "testFunction", EdmCoreModel.Instance.GetString(true));
function.AddParameter("param1", EdmCoreModel.Instance.GetString(false));
var functionImport = new EdmFunctionImport(new EdmEntityContainer("d.s", "container"), "testFunction", function);
EdmUtil.FullyQualifiedName(functionImport).Should().Be("d.s.container/testFunction");
}
示例3: MultipleSchemasWithDifferentNamespacesEdm
public static IEdmModel MultipleSchemasWithDifferentNamespacesEdm()
{
var namespaces = new string[]
{
"FindMethodsTestModelBuilder.MultipleSchemasWithDifferentNamespaces.first",
"FindMethodsTestModelBuilder.MultipleSchemasWithDifferentNamespaces.second"
};
var model = new EdmModel();
foreach (var namespaceName in namespaces)
{
var entityType1 = new EdmEntityType(namespaceName, "validEntityType1");
entityType1.AddKeys(entityType1.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32));
var entityType2 = new EdmEntityType(namespaceName, "VALIDeNTITYtYPE2");
entityType2.AddKeys(entityType2.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32));
var entityType3 = new EdmEntityType(namespaceName, "VALIDeNTITYtYPE3");
entityType3.AddKeys(entityType3.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32));
entityType1.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo {Name = "Mumble", Target = entityType2, TargetMultiplicity = EdmMultiplicity.Many});
var complexType = new EdmComplexType(namespaceName, "ValidNameComplexType1");
complexType.AddStructuralProperty("aPropertyOne", new EdmComplexTypeReference(complexType, false));
model.AddElements(new IEdmSchemaElement[] { entityType1, entityType2, entityType3, complexType });
var function1 = new EdmFunction(namespaceName, "ValidFunction1", EdmCoreModel.Instance.GetSingle(false));
var function2 = new EdmFunction(namespaceName, "ValidFunction1", EdmCoreModel.Instance.GetSingle(false));
function2.AddParameter("param1", new EdmEntityTypeReference(entityType1, false));
var function3 = new EdmFunction(namespaceName, "ValidFunction1", EdmCoreModel.Instance.GetSingle(false));
function3.AddParameter("param1", EdmCoreModel.Instance.GetSingle(false));
model.AddElements(new IEdmSchemaElement[] {function1, function2, function3});
}
return model;
}
示例4: OperationImportSegmentUnitTests
public OperationImportSegmentUnitTests()
{
nullableIntType = new EdmPrimitiveTypeReference(EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.Int32), true);
nullableDecimalType = new EdmPrimitiveTypeReference(EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.Decimal), true);
nullableBinaryType = new EdmPrimitiveTypeReference(EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.Binary), true);
nullableStringType = new EdmPrimitiveTypeReference(EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.String), true);
container = ModelBuildingHelpers.BuildValidEntityContainer();
model = new EdmModel();
model.AddElement(container);
this.functionIntToInt = new EdmFunction("Name.Space", "Function", this.nullableIntType);
this.functionIntToInt.AddParameter("Parameter1", this.nullableIntType);
this.functionImportIntToInt = new EdmFunctionImport(this.container, "Function", this.functionIntToInt);
this.functionDecimalToInt = new EdmFunction("Name.Space", "Function", this.nullableIntType);
this.functionDecimalToInt.AddParameter("Parameter1", this.nullableDecimalType);
this.functionImportDecimalToInt = new EdmFunctionImport(this.container, "Function", this.functionDecimalToInt);
this.functionBinaryToInt = new EdmFunction("Name.Space", "Function", this.nullableIntType);
this.functionBinaryToInt.AddParameter("Parameter1", this.nullableBinaryType);
this.functionImportBinaryToInt = new EdmFunctionImport(this.container, "Function", this.functionBinaryToInt);
this.functionIntToString = new EdmFunction("Name.Space", "Function", this.nullableStringType);
this.functionIntToString.AddParameter("Parameter1", this.nullableIntType);
this.functionImportIntToString = new EdmFunctionImport(this.container, "Function", this.functionIntToString);
model.AddElement(functionIntToInt);
model.AddElement(functionDecimalToInt);
model.AddElement(functionBinaryToInt);
model.AddElement(functionIntToString);
}
示例5: GetEdmModel
private IEdmModel GetEdmModel()
{
EdmModel model = new EdmModel();
EdmEntityContainer container = new EdmEntityContainer("NS", "Name");
model.AddElement(container);
IEdmTypeReference returnType = EdmCoreModel.Instance.GetPrimitive(EdmPrimitiveTypeKind.Boolean, isNullable: false);
IEdmTypeReference parameterType = EdmCoreModel.Instance.GetPrimitive(EdmPrimitiveTypeKind.Boolean, isNullable: false);
container.AddFunctionImport(new EdmFunction("NS", "FunctionWithoutParams", returnType));
var functionWithOneParam = new EdmFunction("NS", "FunctionWithOneParam", returnType);
functionWithOneParam.AddParameter("Parameter", parameterType);
container.AddFunctionImport(functionWithOneParam);
var functionWithMultipleParams = new EdmFunction("NS", "FunctionWithMultipleParams", returnType);
functionWithMultipleParams.AddParameter("Parameter1", parameterType);
functionWithMultipleParams.AddParameter("Parameter2", parameterType);
functionWithMultipleParams.AddParameter("Parameter3", parameterType);
container.AddFunctionImport(functionWithMultipleParams);
container.AddFunctionImport(new EdmFunction("NS", "FunctionWithOverloads", returnType));
var functionWithOverloads2 = new EdmFunction("NS", "FunctionWithOverloads", returnType);
functionWithOverloads2.AddParameter("Parameter", parameterType);
container.AddFunctionImport(functionWithOverloads2);
var functionWithOverloads3 = new EdmFunction("NS", "FunctionWithOverloads", returnType);
functionWithOverloads3.AddParameter("Parameter1", parameterType);
functionWithOverloads3.AddParameter("Parameter2", parameterType);
functionWithOverloads3.AddParameter("Parameter3", parameterType);
container.AddFunctionImport(functionWithOverloads3);
return model;
}
示例6: EdmFunctionConstructorWithNullReturnTypeShouldNotThrow
public void EdmFunctionConstructorWithNullReturnTypeShouldNotThrow()
{
var edmFunction = new EdmFunction(defaultNamespaceName, checkout, this.boolType);
edmFunction.Namespace.Should().Be(defaultNamespaceName);
edmFunction.Name.Should().Be(checkout);
edmFunction.ReturnType.Should().Be(this.boolType);
edmFunction.IsComposable.Should().BeFalse();
}
示例7: EnsureFunctionImportIsAddedAndWithCorrectSuppliedName
public void EnsureFunctionImportIsAddedAndWithCorrectSuppliedName()
{
EdmEntityContainer container = new EdmEntityContainer("Default", "Container");
EdmFunction function = new EdmFunction("DS", "TestAction", EdmCoreModel.Instance.GetBoolean(false));
var functionImport = container.AddFunctionImport("OtherName", function);
functionImport.Function.Should().Be(function);
functionImport.Name.Should().Be("OtherName");
container.Elements.ToArray()[0].Should().Be(functionImport);
}
示例8: EdmFunctionConstructorShouldDefaultNonSpecifiedPropertiesCorrectly
public void EdmFunctionConstructorShouldDefaultNonSpecifiedPropertiesCorrectly()
{
var edmFunction = new EdmFunction(defaultNamespaceName, checkout, this.boolType);
edmFunction.Namespace.Should().Be(defaultNamespaceName);
edmFunction.Name.Should().Be(checkout);
edmFunction.ReturnType.Should().Be(this.boolType);
edmFunction.EntitySetPath.Should().BeNull();
edmFunction.IsBound.Should().BeFalse();
edmFunction.SchemaElementKind.Should().Be(EdmSchemaElementKind.Function);
edmFunction.IsComposable.Should().BeFalse();
}
示例9: DuplicateFunctionOverloadsWithDifferentBindingTypesAndSameNameWithDifferentReturnTypesShouldNotError
public void DuplicateFunctionOverloadsWithDifferentBindingTypesAndSameNameWithDifferentReturnTypesShouldNotError()
{
var edmFunction = new EdmFunction("n.s", "GetStuff", EdmCoreModel.Instance.GetString(true), true /*isBound*/, null /*entitySetPath*/, false /*isComposable*/);
edmFunction.AddParameter("bindingParameter", EdmCoreModel.Instance.GetInt16(true));
var edmFunction2 = new EdmFunction("n.s", "GetStuff", EdmCoreModel.Instance.GetInt16(true), true /*isBound*/, null /*entitySetPath*/, false /*isComposable*/);
edmFunction2.AddParameter("bindingParameter", EdmCoreModel.Instance.GetInt32(true));
EdmModel model = new EdmModel();
model.AddElement(edmFunction);
model.AddElement(edmFunction2);
ValidateNoError(model);
}
示例10: DuplicateUnBoundFunctionOverloadsSameParameterNamesShouldError
public void DuplicateUnBoundFunctionOverloadsSameParameterNamesShouldError()
{
var edmFunction = new EdmFunction("n.s", "GetStuff", EdmCoreModel.Instance.GetString(true), false /*isBound*/, null /*entitySetPath*/, false /*isComposable*/);
edmFunction.AddParameter("bindingParameter1", EdmCoreModel.Instance.GetInt16(true));
var edmFunction2 = new EdmFunction("n.s", "GetStuff", EdmCoreModel.Instance.GetInt16(true), false /*isBound*/, null /*entitySetPath*/, false /*isComposable*/);
edmFunction2.AddParameter("bindingParameter1", EdmCoreModel.Instance.GetInt32(true));
EdmModel model = new EdmModel();
model.AddElement(edmFunction);
model.AddElement(edmFunction2);
ValidateError(model, EdmErrorCode.DuplicateFunctions, Strings.EdmModel_Validator_Semantic_ModelDuplicateUnBoundFunctionsParameterNames("n.s.GetStuff"));
}
示例11: EnsureDuplicateTermAndFunctionReturnTrue
public void EnsureDuplicateTermAndFunctionReturnTrue()
{
EdmModel model = new EdmModel();
var edmFunction = new EdmFunction("n.s", "GetStuff", EdmCoreModel.Instance.GetString(true), false /*isBound*/, null /*entitySetPath*/, false /*isComposable*/);
model.AddElement(edmFunction);
EdmModel otherModel = new EdmModel();
var edmTerm = new EdmTerm("n.s", "GetStuff", EdmPrimitiveTypeKind.Int32);
otherModel.AddElement(edmTerm);
model.AddReferencedModel(otherModel);
model.OperationOrNameExistsInReferencedModel(edmFunction, edmFunction.FullName()).Should().BeTrue();
}
示例12: EdmFunctionConstructorShouldHaveSpecifiedConstructorValues
public void EdmFunctionConstructorShouldHaveSpecifiedConstructorValues()
{
var entitySetPath = new EdmPathExpression("Param1/Nav");
var edmFunction = new EdmFunction(defaultNamespaceName, checkout, this.boolType, true, entitySetPath, true /*IsComposable*/);
edmFunction.AddParameter(new EdmOperationParameter(edmFunction, "Param1", new EdmEntityTypeReference(personType, false)));
edmFunction.Namespace.Should().Be(defaultNamespaceName);
edmFunction.Name.Should().Be(checkout);
edmFunction.ReturnType.Should().Be(this.boolType);
edmFunction.EntitySetPath.Should().Be(entitySetPath);
edmFunction.IsBound.Should().BeTrue();
edmFunction.SchemaElementKind.Should().Be(EdmSchemaElementKind.Function);
edmFunction.IsComposable.Should().BeTrue();
}
示例13: EnsureNoDuplicateFoundForFunctionShouldReturnFalse
public void EnsureNoDuplicateFoundForFunctionShouldReturnFalse()
{
EdmModel otherModel = new EdmModel();
var entityType = new EdmEntityType("n.s", "GetStuff2");
otherModel.AddElement(entityType);
var edmFunction = new EdmFunction("n.s", "GetStuff", new EdmEntityTypeReference(entityType, false), false /*isBound*/, null /*entitySetPath*/, false /*isComposable*/);
EdmModel model = new EdmModel();
model.AddElement(edmFunction);
model.AddReferencedModel(otherModel);
model.OperationOrNameExistsInReferencedModel(edmFunction, edmFunction.FullName()).Should().BeFalse();
}
示例14: EnsureDuplicateContainerFunctionReturnTrue
public void EnsureDuplicateContainerFunctionReturnTrue()
{
EdmModel model = new EdmModel();
var edmFunction = new EdmFunction("n.s", "GetStuff", EdmCoreModel.Instance.GetString(true), false /*isBound*/, null /*entitySetPath*/, false /*isComposable*/);
model.AddElement(edmFunction);
EdmModel otherModel = new EdmModel();
EdmEntityContainer container = new EdmEntityContainer("n.s", "GetStuff");
otherModel.AddElement(container);
model.AddReferencedModel(otherModel);
model.OperationOrNameExistsInReferencedModel(edmFunction, edmFunction.FullName()).Should().BeTrue();
}
示例15: GetEdmType_Returns_FunctionReturnType
public void GetEdmType_Returns_FunctionReturnType()
{
// Arrange
IEdmEntityType returnType = new Mock<IEdmEntityType>().Object;
EdmFunction function = new EdmFunction("NS", "Function", new EdmEntityTypeReference(returnType, isNullable: false));
BoundFunctionPathSegment segment = new BoundFunctionPathSegment(function, model: null, parameterValues: null);
// Act
var result = segment.GetEdmType(returnType);
// Assert
Assert.Same(returnType, result);
}