Exemple #1
0
 private static void AddOperationParameters(EdmOperation operation, OperationConfiguration operationConfiguration, Dictionary <Type, IEdmType> edmTypeMap)
 {
     foreach (ParameterConfiguration parameter in operationConfiguration.Parameters)
     {
         bool isParameterNullable = parameter.Nullable;
         IEdmTypeReference      parameterTypeReference = GetEdmTypeReference(edmTypeMap, parameter.TypeConfiguration, nullable: isParameterNullable);
         IEdmOperationParameter operationParameter     = new EdmOperationParameter(operation, parameter.Name, parameterTypeReference);
         operation.AddParameter(operationParameter);
     }
 }
Exemple #2
0
        private static EdmOperationImport CreateActionImport(
            OperationConfiguration operationConfiguration,
            EdmEntityContainer container,
            IEdmTypeReference returnReference,
            IEdmExpression expression,
            IEdmPathExpression pathExpression)
        {
            EdmAction operation = new EdmAction(
                operationConfiguration.Namespace,
                operationConfiguration.Name,
                returnReference,
                operationConfiguration.IsBindable,
                pathExpression);

            return(new EdmActionImport(container, operationConfiguration.Name, operation, expression));
        }
 private static void AddOperationParameters(EdmOperation operation, OperationConfiguration operationConfiguration, Dictionary <Type, IEdmType> edmTypeMap)
 {
     foreach (ParameterConfiguration parameter in operationConfiguration.Parameters)
     {
         bool isParameterNullable = parameter.Nullable;
         IEdmTypeReference parameterTypeReference = GetEdmTypeReference(edmTypeMap, parameter.TypeConfiguration, nullable: isParameterNullable);
         if (parameter.IsOptional)
         {
             if (parameter.DefaultValue != null)
             {
                 operation.AddOptionalParameter(parameter.Name, parameterTypeReference, parameter.DefaultValue);
             }
             else
             {
                 operation.AddOptionalParameter(parameter.Name, parameterTypeReference);
             }
         }
         else
         {
             IEdmOperationParameter operationParameter = new EdmOperationParameter(operation, parameter.Name, parameterTypeReference);
             operation.AddParameter(operationParameter);
         }
     }
 }
Exemple #4
0
        private static IEdmExpression GetEdmEntitySetExpression(IDictionary <string, EdmNavigationSource> navigationSources, OperationConfiguration operationConfiguration)
        {
            if (operationConfiguration.NavigationSource != null)
            {
                EdmNavigationSource navigationSource;
                if (navigationSources.TryGetValue(operationConfiguration.NavigationSource.Name, out navigationSource))
                {
                    EdmEntitySet entitySet = navigationSource as EdmEntitySet;
                    if (entitySet != null)
                    {
                        return(new EdmPathExpression(entitySet.Name));
                    }
                }
                else
                {
                    throw Error.InvalidOperation(SRResources.EntitySetNotFoundForName, operationConfiguration.NavigationSource.Name);
                }
            }
            else if (operationConfiguration.EntitySetPath != null)
            {
                return(new EdmPathExpression(operationConfiguration.EntitySetPath));
            }

            return(null);
        }
Exemple #5
0
        private static void ValidateOperationEntitySetPath(IEdmModel model, IEdmOperationImport operationImport, OperationConfiguration operationConfiguration)
        {
            IEdmOperationParameter operationParameter;
            Dictionary <IEdmNavigationProperty, IEdmPathExpression> relativeNavigations;
            IEnumerable <EdmError> edmErrors;

            if (operationConfiguration.EntitySetPath != null && !operationImport.TryGetRelativeEntitySetPath(model, out operationParameter, out relativeNavigations, out edmErrors))
            {
                throw Error.InvalidOperation(SRResources.OperationHasInvalidEntitySetPath, String.Join("/", operationConfiguration.EntitySetPath), operationConfiguration.FullyQualifiedName);
            }
        }
Exemple #6
0
        private static void AddOperationLinkBuilder(IEdmModel model, IEdmOperation operation, OperationConfiguration operationConfiguration)
        {
            ActionConfiguration   actionConfiguration = operationConfiguration as ActionConfiguration;
            IEdmAction            action = operation as IEdmAction;
            FunctionConfiguration functionConfiguration = operationConfiguration as FunctionConfiguration;
            IEdmFunction          function = operation as IEdmFunction;

            if (operationConfiguration.BindingParameter.TypeConfiguration.Kind == EdmTypeKind.Entity)
            {
                if (actionConfiguration != null && actionConfiguration.GetActionLink() != null && action != null)
                {
                    model.SetOperationLinkBuilder(
                        action,
                        new OperationLinkBuilder(actionConfiguration.GetActionLink(), actionConfiguration.FollowsConventions));
                }
                else if (functionConfiguration != null && functionConfiguration.GetFunctionLink() != null && function != null)
                {
                    model.SetOperationLinkBuilder(
                        function,
                        new OperationLinkBuilder(functionConfiguration.GetFunctionLink(), functionConfiguration.FollowsConventions));
                }
            }
            else if (operationConfiguration.BindingParameter.TypeConfiguration.Kind == EdmTypeKind.Collection)
            {
                CollectionTypeConfiguration collectionTypeConfiguration =
                    (CollectionTypeConfiguration)operationConfiguration.BindingParameter.TypeConfiguration;

                if (collectionTypeConfiguration.ElementType.Kind == EdmTypeKind.Entity)
                {
                    if (actionConfiguration != null && actionConfiguration.GetFeedActionLink() != null && action != null)
                    {
                        model.SetOperationLinkBuilder(
                            action,
                            new OperationLinkBuilder(actionConfiguration.GetFeedActionLink(), actionConfiguration.FollowsConventions));
                    }
                    else if (functionConfiguration != null && functionConfiguration.GetFeedFunctionLink() != null && function != null)
                    {
                        model.SetOperationLinkBuilder(
                            function,
                            new OperationLinkBuilder(functionConfiguration.GetFeedFunctionLink(), functionConfiguration.FollowsConventions));
                    }
                }
            }
        }
Exemple #7
0
 /// <summary>
 /// Adds a operation to the model.
 /// </summary>
 public virtual void AddOperation(OperationConfiguration operation)
 {
     _operations.Add(operation);
 }