當前位置: 首頁>>代碼示例>>C#>>正文


C# Library.EdmFunction類代碼示例

本文整理匯總了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"]);
        }
開發者ID:huangw-t,項目名稱:aspnetwebstack,代碼行數:32,代碼來源:BoundFunctionPathSegmentTemplateTest.cs

示例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");
 }
開發者ID:rossjempson,項目名稱:odata.net,代碼行數:7,代碼來源:EdmUtilTests.cs

示例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;
        }
開發者ID:AlineGuan,項目名稱:odata.net,代碼行數:35,代碼來源:FindMethodsTestModelBuilder.cs

示例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);
        }
開發者ID:rossjempson,項目名稱:odata.net,代碼行數:32,代碼來源:OperationSegmentUnitTests.cs

示例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;
        }
開發者ID:quentez,項目名稱:aspnetwebstack,代碼行數:33,代碼來源:FunctionResolverTest.cs

示例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();
 }
開發者ID:rossjempson,項目名稱:odata.net,代碼行數:8,代碼來源:EdmFunctionTests.cs

示例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);
        }
開發者ID:larsenjo,項目名稱:odata.net,代碼行數:10,代碼來源:EdmEntityContainerTests.cs

示例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();
 }
開發者ID:rossjempson,項目名稱:odata.net,代碼行數:11,代碼來源:EdmFunctionTests.cs

示例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);
        }
開發者ID:AlineGuan,項目名稱:odata.net,代碼行數:12,代碼來源:DuplicateOperationValidatorTests.cs

示例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"));
        }
開發者ID:AlineGuan,項目名稱:odata.net,代碼行數:12,代碼來源:DuplicateOperationValidatorTests.cs

示例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();
        }
開發者ID:AlineGuan,項目名稱:odata.net,代碼行數:13,代碼來源:ValidationHelperTests.cs

示例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();
 }
開發者ID:rossjempson,項目名稱:odata.net,代碼行數:13,代碼來源:EdmFunctionTests.cs

示例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();
        }
開發者ID:AlineGuan,項目名稱:odata.net,代碼行數:13,代碼來源:ValidationHelperTests.cs

示例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();
        }
開發者ID:AlineGuan,項目名稱:odata.net,代碼行數:13,代碼來源:ValidationHelperTests.cs

示例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);
        }
開發者ID:ZhaoYngTest01,項目名稱:WebApi,代碼行數:13,代碼來源:BoundFunctionPathSegmentTest.cs


注:本文中的Microsoft.OData.Edm.Library.EdmFunction類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。