Example #1
0
 /// <summary>
 /// Adds a new Return Type to this function
 /// </summary>
 /// <param name="returnType">The parameter to be added</param>
 public void Add(FunctionImportReturnType returnType)
 {
     this.ReturnTypes.Add(returnType);
 }
Example #2
0
        private FunctionImport ParseFunctionImport(XElement functionImportElement)
        {
            string functionImportName = functionImportElement.GetRequiredAttributeValue("Name");

            var functionImport = new FunctionImport(functionImportName);

            bool isComposable = XmlConvert.ToBoolean(functionImportElement.GetOptionalAttributeValue("IsComposable", "false"));
            functionImport.IsComposable = isComposable;

            bool isBindable = XmlConvert.ToBoolean(functionImportElement.GetOptionalAttributeValue("IsBindable", "false"));
            functionImport.IsBindable = isBindable;

            bool isSideEffecting = XmlConvert.ToBoolean(functionImportElement.GetOptionalAttributeValue("IsSideEffecting", "true"));
            functionImport.IsSideEffecting = isSideEffecting;

            string entitySetPath = functionImportElement.GetOptionalAttributeValue("EntitySetPath", null);
            if (entitySetPath != null)
            {
                functionImport.Annotations.Add(new EntitySetPathAnnotation(entitySetPath));
            }

            foreach (var parameterElement in functionImportElement.Elements().Where(el => this.IsXsdlElement(el, "Parameter")))
            {
                functionImport.Parameters.Add(this.ParseFunctionParameter(parameterElement));
            }

            string returnTypeName = functionImportElement.GetOptionalAttributeValue("ReturnType", null);

            if (returnTypeName != null)
            {
                bool isNullable = XmlConvert.ToBoolean(functionImportElement.GetOptionalAttributeValue("Nullable", "true"));
                var returnType = new FunctionImportReturnType(this.ParseType(returnTypeName, isNullable, null));
                string entitySetName = functionImportElement.GetOptionalAttributeValue("EntitySet", null);
                if (entitySetName != null)
                {
                    returnType.EntitySet = new EntitySetReference(entitySetName);
                }

                functionImport.Add(returnType);
            }

            foreach (var returnTypeElement in functionImportElement.Elements().Where(el => this.IsXsdlElement(el, "ReturnType")))
            {
                var type = returnTypeElement.GetRequiredAttributeValue("Type");
                var returnType = new FunctionImportReturnType(this.ParseType(type, true, null));
                var entitySet = returnTypeElement.GetOptionalAttributeValue("EntitySet", null);
                if (entitySet != null)
                {
                    returnType.EntitySet = new EntitySetReference(entitySet);
                }

                functionImport.ReturnTypes.Add(returnType);
            }

            string methodaccess = functionImportElement.GetOptionalAttributeValue(EdmConstants.CodegenNamespace + "MethodAccess", null);
            if (methodaccess != null)
            {
                functionImport.Annotations.Add(new MethodAccessModifierAnnotation(this.GetAccessModifier(methodaccess)));
            }

            this.ParseAnnotations(functionImport, functionImportElement);
            return functionImport;
        }
        private FunctionImport ConvertToTaupoFunctionImport(IEdmOperationImport edmFunctionImport)
        {
            var taupoFunctionImport = new FunctionImport(edmFunctionImport.Name);
            var functionImportReturnType = new FunctionImportReturnType();
            var addReturnType = false;
            if (edmFunctionImport.EntitySet != null)
            {
                IEdmEntitySet entitySet;
                if (edmFunctionImport.TryGetStaticEntitySet(out entitySet))
                {
                    functionImportReturnType.EntitySet = new EntitySetReference(entitySet.Name);
                    addReturnType = true;
                }
                else
                {
                    throw new NotSupportedException("Function import with entity set path is not supported.");
                }
            }

            if (edmFunctionImport.Operation.ReturnType != null)
            {
                functionImportReturnType.DataType = this.ConvertToTaupoDataType(edmFunctionImport.Operation.ReturnType);
                addReturnType = true;
            }

            if (addReturnType)
            {
                taupoFunctionImport.Add(functionImportReturnType);
            }

            foreach (var edmFunctionParameter in edmFunctionImport.Operation.Parameters)
            {
                FunctionParameter taupoFunctionParameter = this.ConvertToTaupoFunctionParameter(edmFunctionParameter);
                taupoFunctionImport.Parameters.Add(taupoFunctionParameter);
            }

            this.ConvertAnnotationsIntoTaupo(edmFunctionImport, taupoFunctionImport);
            return taupoFunctionImport;
        }
Example #4
0
 /// <summary>
 /// Adds a new Return Type to this function
 /// </summary>
 /// <param name="returnType">The parameter to be added</param>
 public void Add(FunctionImportReturnType returnType)
 {
     this.ReturnTypes.Add(returnType);
 }