Пример #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);
        }
Пример #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
                );
        }
Пример #3
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");
        }
Пример #4
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");
        }
Пример #5
0
        public PropertyDefinition(PropertyInfo propertyInfo, TypeDefinition declaringTypeDefinition)
        {
            DeclaringTypeDefinition = declaringTypeDefinition;
            PropertyInfo            = propertyInfo;
            RuntimeName             = propertyInfo.GetRuntimeName();

            Content = ContentDefinition.FromType(
                this,
                propertyInfo,
                propertyInfo.PropertyType.NormalizeType(),
                RuntimeName
                );

            TemplateName = Content.Name?.LocalName;
        }
Пример #6
0
        public PropertyDefinition(PropertyInfo propertyInfo, TypeDefinition declaringTypeDefinition, Func <string, bool> isQualifiedElementDefault)
        {
            DeclaringTypeDefinition = declaringTypeDefinition;
            PropertyInfo            = propertyInfo;
            RuntimeName             = propertyInfo.GetRuntimeName();

            Content = ContentDefinition.FromType(
                this,
                propertyInfo,
                propertyInfo.PropertyType.NormalizeType(),
                RuntimeName,
                declaringTypeDefinition.TargetNamespace,
                isQualifiedElementDefault(declaringTypeDefinition.TargetNamespace)
                );

            TemplateName = Content.Name?.LocalName;
        }