Esempio n. 1
0
        /// <summary>
        /// Initializes definition builder.
        /// </summary>
        public SchemaDefinitionProvider(ISchemaExporter schemaExporter)
        {
            if (schemaExporter == null)
            {
                throw new ArgumentNullException(nameof(schemaExporter));
            }
            this.schemaExporter = schemaExporter;

            ProtocolDefinition = GetProtocolDefinition();
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes new definition object using default settings.
        /// </summary>
        public OperationDefinition(XName qualifiedName, uint?version, MethodInfo methodInfo)
        {
            MethodInfo = methodInfo;

            var attribute = methodInfo.GetServices().SingleOrDefault(x => x.Name == qualifiedName.LocalName);

            Name                      = qualifiedName;
            IsAbstract                = (attribute?.IsAbstract).GetValueOrDefault();
            InputBinaryMode           = BinaryMode.Xml;
            OutputBinaryMode          = BinaryMode.Xml;
            State                     = (attribute?.IsHidden).GetValueOrDefault() ? DefinitionState.Hidden : DefinitionState.Default;
            Version                   = version.GetValueOrDefault(attribute?.AddedInVersion ?? 0u);
            CopyRequestPartToResponse = true;
            InputMessageName          = qualifiedName.LocalName;
            OutputMessageName         = $"{qualifiedName.LocalName}Response";
            Documentation             = new DocumentationDefinition(methodInfo);
            ServiceMapType            = attribute?.ServiceMapType ?? typeof(ServiceMap);
            ExtensionSchemaExporter   = attribute?.SchemaExporter;
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes new X-Road message protocol instance.
        /// <param name="name">Identifies protocol instance.</param>
        /// <param name="schemaExporter">Schema customization provider.</param>
        /// </summary>
        public XRoadProtocol(string name, ISchemaExporter schemaExporter)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (schemaExporter == null)
            {
                throw new ArgumentNullException(nameof(schemaExporter));
            }

            Name = name;

            schemaDefinitionProvider = new SchemaDefinitionProvider(schemaExporter);

            HeaderDefinition   = schemaDefinitionProvider.GetXRoadHeaderDefinition();
            ProtocolDefinition = schemaDefinitionProvider.ProtocolDefinition;

            SetContractAssembly();
        }
Esempio n. 4
0
 /// <summary>
 /// Get schema location of specified schema namespace.
 /// </summary>
 public string GetSchemaLocation(string namespaceName, ISchemaExporter extension = null)
 {
     return(schemaExporter.ExportSchemaLocation(namespaceName)
            ?? extension?.ExportSchemaLocation(namespaceName)
            ?? NamespaceConstants.GetSchemaLocation(namespaceName));
 }