private void CloneContainerContents(EntityContainer baseContainer, EntityContainer extendedContainer) { foreach (var entitySet in baseContainer.EntitySets) { var clonedEntitySet = new EntitySet(entitySet.Name, entitySet.EntityType); extendedContainer.Add(clonedEntitySet); } foreach (var associationSet in baseContainer.AssociationSets) { var clonedAssociationSet = new AssociationSet(associationSet.Name, associationSet.AssociationType); foreach (var setEnd in associationSet.Ends) { clonedAssociationSet.Add(new AssociationSetEnd(setEnd.AssociationEnd, setEnd.EntitySet.Name)); } extendedContainer.Add(clonedAssociationSet); } foreach (var functionImport in baseContainer.FunctionImports) { var clonedFunctionImport = new FunctionImport(functionImport.Name); foreach (var returnType in functionImport.ReturnTypes) { clonedFunctionImport.ReturnTypes.Add(returnType); } foreach (var parameter in functionImport.Parameters) { clonedFunctionImport.Add(new FunctionParameter(parameter.Name, parameter.DataType, parameter.Mode)); } extendedContainer.Add(clonedFunctionImport); } }
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); }
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); }