コード例 #1
0
ファイル: CsdlBuilder.cs プロジェクト: larsenjo/odata.net
        internal static CsdlEntityContainer EntityContainer(
            string name,
            string extends = null,
            CsdlEntitySet[] entitySets = default(CsdlEntitySet[]),
            CsdlSingleton[] singletons = default(CsdlSingleton[]),
            CsdlOperationImport[] operationImports = default(CsdlOperationImport[]),
            CsdlDocumentation documentation = null,
            CsdlLocation location = null)
        {
            if (entitySets == null)
            {
                entitySets = new CsdlEntitySet[] { };
            }

            if (operationImports == null)
            {
                operationImports = new CsdlOperationImport[] { };
            }

            if (singletons == null)
            {
                singletons = new CsdlSingleton[] { };
            }

            return new CsdlEntityContainer(
                name,
                extends,
                entitySets,
                singletons,
                operationImports,
                documentation,
                location);
        }
コード例 #2
0
 protected CsdlSemanticsOperationImport(CsdlSemanticsEntityContainer container, CsdlOperationImport operationImport, IEdmOperation operation)
     : base(operationImport)
 {
     this.container = container;
     this.operationImport = operationImport;
     this.Operation = operation;
 }
コード例 #3
0
        private void AddOperationImport(CsdlOperationImport operationImport, List<IEdmEntityContainerElement> elements)
        {
            var functionImport = operationImport as CsdlFunctionImport;
            var actionImport = operationImport as CsdlActionImport;
            CsdlSemanticsOperationImport semanticsOperation = null;
            EdmSchemaElementKind filterKind = EdmSchemaElementKind.Action;
            if (functionImport != null)
            {
                filterKind = EdmSchemaElementKind.Function;
            }

            // OperationImports only work with non-bound operations hence this extra logic in the where clause
            var operations = this.context.FindOperations(operationImport.SchemaOperationQualifiedTypeName).Where(o => o.SchemaElementKind == filterKind && !o.IsBound);

            int operationsCount = 0;
            foreach (IEdmOperation operation in operations)
            {
                if (functionImport != null)
                {
                    semanticsOperation = new CsdlSemanticsFunctionImport(this, functionImport, (IEdmFunction)operation);
                }
                else
                {
                    Debug.Assert(actionImport != null, "actionImport should not be null");
                    semanticsOperation = new CsdlSemanticsActionImport(this, actionImport, (IEdmAction)operation);
                }

                operationsCount++;
                elements.Add(semanticsOperation);
            }

            // If none have been created then its an unresolved operation.
            if (operationsCount == 0)
            {
                if (filterKind == EdmSchemaElementKind.Action)
                {
                    var action = new UnresolvedAction(operationImport.SchemaOperationQualifiedTypeName, Edm.Strings.Bad_UnresolvedOperation(operationImport.SchemaOperationQualifiedTypeName), operationImport.Location);
                    semanticsOperation = new CsdlSemanticsActionImport(this, actionImport, action);
                }
                else
                {
                    Debug.Assert(filterKind == EdmSchemaElementKind.Function, "Should be a function");
                    var function = new UnresolvedFunction(operationImport.SchemaOperationQualifiedTypeName, Edm.Strings.Bad_UnresolvedOperation(operationImport.SchemaOperationQualifiedTypeName), operationImport.Location);
                    semanticsOperation = new CsdlSemanticsFunctionImport(this, functionImport, function);
                }

                elements.Add(semanticsOperation);
            }
        }