Esempio n. 1
0
        /// <summary>
        /// Initializes new response definition using default values extracted from
        /// operation definition entity.
        /// </summary>
        public ResponseDefinition(OperationDefinition declaringOperationDefinition, Func <string, bool> isQualifiedElementDefault)
        {
            var parameterInfo = declaringOperationDefinition.MethodInfo.ReturnParameter;

            DeclaringOperationDefinition = declaringOperationDefinition;
            ParameterInfo      = parameterInfo;
            WrapperElementName = XName.Get($"{declaringOperationDefinition.Name.LocalName}Response", declaringOperationDefinition.Name.NamespaceName);

            var targetNamespace         = declaringOperationDefinition.Name.NamespaceName;
            var defaultQualifiedElement = isQualifiedElementDefault(targetNamespace);

            Content = ContentDefinition.FromType(
                this,
                parameterInfo,
                parameterInfo?.ParameterType,
                "response",
                targetNamespace,
                defaultQualifiedElement
                );

            var qualifiedNamespace = ContentDefinition.GetQualifiedNamespace("", null, targetNamespace, defaultQualifiedElement);

            FaultName          = XName.Get("fault", qualifiedNamespace);
            RequestContentName = XName.Get("request", qualifiedNamespace);
            ResultElementName  = XName.Get("result", qualifiedNamespace);
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes new request definition object.
        /// </summary>
        public RequestDefinition(OperationDefinition declaringOperationDefinition, Func <string, bool> isQualifiedElementDefault)
        {
            var methodParameters = declaringOperationDefinition.MethodInfo.GetParameters();

            if (methodParameters.Length > 1)
            {
                throw new SchemaDefinitionException($"Invalid X-Road operation contract `{declaringOperationDefinition.Name.LocalName}`: expected 0-1 input parameters, but {methodParameters.Length} was given.");
            }

            DeclaringOperationDefinition = declaringOperationDefinition;
            ParameterInfo      = methodParameters.SingleOrDefault();
            WrapperElementName = declaringOperationDefinition.Name;

            var targetNamespace         = declaringOperationDefinition.Name.NamespaceName;
            var defaultQualifiedElement = isQualifiedElementDefault(targetNamespace);

            Content = ContentDefinition.FromType(
                this,
                ParameterInfo,
                ParameterInfo?.ParameterType,
                "request",
                targetNamespace,
                defaultQualifiedElement
                );
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes default opeartion definition and applies customizations (if any).
        /// </summary>
        public OperationDefinition GetOperationDefinition(MethodInfo methodInfo, XName qualifiedName, uint?version)
        {
            var operationDefinition = new OperationDefinition(qualifiedName, version, methodInfo);

            operationDefinition.ExtensionSchemaExporter?.ExportOperationDefinition(operationDefinition);
            schemaExporter.ExportOperationDefinition(operationDefinition);

            return(operationDefinition);
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes default request element definition and applies customizations (if any).
        /// </summary>
        public RequestDefinition GetRequestDefinition(OperationDefinition operationDefinition)
        {
            var requestDefinition = new RequestDefinition(operationDefinition);

            operationDefinition.ExtensionSchemaExporter?.ExportRequestDefinition(requestDefinition);
            schemaExporter.ExportRequestDefinition(requestDefinition);

            return(requestDefinition);
        }
        /// <summary>
        /// Initializes default request element definition and applies customizations (if any).
        /// </summary>
        public RequestDefinition GetRequestDefinition(OperationDefinition operationDefinition)
        {
            var requestDefinition = new RequestDefinition(operationDefinition, schemaExporter.IsQualifiedElementDefault);

            operationDefinition.ExtensionSchemaExporter?.ExportRequestDefinition(requestDefinition);
            schemaExporter.ExportRequestDefinition(requestDefinition);

            return(requestDefinition);
        }
Esempio n. 6
0
        /// <summary>
        /// Initializes new response definition using default values extracted from
        /// operation definition entity.
        /// </summary>
        public ResponseDefinition(OperationDefinition declaringOperationDefinition)
        {
            var parameterInfo = declaringOperationDefinition.MethodInfo.ReturnParameter;

            DeclaringOperationDefinition = declaringOperationDefinition;
            ParameterInfo = parameterInfo;

            Content = ContentDefinition.FromType(this, parameterInfo, parameterInfo?.ParameterType, "result");
        }
Esempio n. 7
0
        /// <summary>
        /// Initializes new response definition using default values extracted from
        /// operation definition entity.
        /// </summary>
        public ResponseValueDefinition(OperationDefinition declaringOperationDefinition)
        {
            var parameterInfo = declaringOperationDefinition.MethodInfo.ReturnParameter;

            DeclaringOperationDefinition = declaringOperationDefinition;
            ParameterInfo = parameterInfo;
            RuntimeType   = NormalizeType(parameterInfo?.ParameterType);

            InitializeContentDefinition(parameterInfo);
        }
Esempio n. 8
0
        /// <summary>
        /// Initializes default response element definition and applies customizations (if any).
        /// </summary>
        public ResponseDefinition GetResponseDefinition(OperationDefinition operationDefinition, XRoadFaultPresentation?xRoadFaultPresentation = null)
        {
            var responseDefinition = new ResponseDefinition(operationDefinition)
            {
                XRoadFaultPresentation = xRoadFaultPresentation ?? XRoadFaultPresentation.Choice
            };

            operationDefinition.ExtensionSchemaExporter?.ExportResponseDefinition(responseDefinition);
            schemaExporter.ExportResponseDefinition(responseDefinition);

            return(responseDefinition);
        }
Esempio n. 9
0
        /// <summary>
        /// Initializes new request definition object.
        /// </summary>
        public RequestDefinition(OperationDefinition declaringOperationDefinition)
        {
            var methodParameters = declaringOperationDefinition.MethodInfo.GetParameters();

            if (methodParameters.Length > 1)
            {
                throw new Exception($"Invalid X-Road operation contract `{declaringOperationDefinition.Name.LocalName}`: expected 0-1 input parameters, but {methodParameters.Length} was given.");
            }

            DeclaringOperationDefinition = declaringOperationDefinition;
            ParameterInfo = methodParameters.SingleOrDefault();

            Content = ContentDefinition.FromType(this, ParameterInfo, ParameterInfo?.ParameterType, "request");
        }
Esempio n. 10
0
        /// <summary>
        /// Initializes new request definition object.
        /// </summary>
        public RequestValueDefinition(OperationDefinition declaringOperationDefinition)
        {
            var methodParameters = declaringOperationDefinition.MethodInfo.GetParameters();

            if (methodParameters.Length > 1)
            {
                throw new Exception($"Invalid X-Road operation contract `{declaringOperationDefinition.Name.LocalName}`: expected 0-1 input parameters, but {methodParameters.Length} was given.");
            }

            DeclaringOperationDefinition = declaringOperationDefinition;
            ParameterInfo = methodParameters.SingleOrDefault();

            if (ParameterInfo == null)
            {
                return;
            }

            RuntimeType = NormalizeType(ParameterInfo.ParameterType);

            InitializeContentDefinition(ParameterInfo);
        }
 /// <inheritdoc />
 public virtual void ExportOperationDefinition(OperationDefinition operationDefinition)
 {
 }