/// <summary>
        /// Initializes a new instance of the <see cref="IoBase"/> class.
        /// </summary>
        /// <param name="namespaces">
        /// The namespaces.
        /// </param>
        /// <param name="schema">
        /// The SDMX schema version.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="schema"/> is null
        /// </exception>
        protected IoBase(SdmxNamespaces namespaces, SdmxSchema schema)
        {
            if (schema == null)
            {
                throw new ArgumentNullException("schema");
            }

            this._targetSchema = schema;
            this._namespaces = namespaces ?? CreateNamespaces(schema.EnumType);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CodeListReaderV2"/> class.
 /// </summary>
 /// <param name="namespaces">
 /// The namespaces.
 /// </param>
 public CodeListReaderV2(SdmxNamespaces namespaces)
     : base(namespaces)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ConceptSchemeWriterV2"/> class.
 /// </summary>
 /// <param name="writer">
 /// The writer.
 /// </param>
 /// <param name="namespaces">
 /// The namespaces.
 /// </param>
 public ConceptSchemeWriterV2(XmlWriter writer, SdmxNamespaces namespaces)
     : base(writer, namespaces)
 {
 }
        /// <summary>
        /// The validate.
        /// </summary>
        /// <param name="namespaces">
        /// The namespaces.
        /// </param>
        /// <exception cref="ArgumentException">
        /// <paramref name="namespaces"/> is not configured correctly
        /// </exception>
        private static void Validate(SdmxNamespaces namespaces)
        {
            if (namespaces == null)
            {
                throw new ArgumentNullException("namespaces");
            }

            if (namespaces.Message == null || namespaces.Common == null || namespaces.Xsi == null
                || (namespaces.DataSetStructureSpecific == null && namespaces.Generic == null))
            {
                throw new ArgumentException(
                    "One or more of the required namespaces are not set. Please set Message, Common, Xsi and either DataSetStructureSpecific or Generic namespaces. Else use another ctor to use the defaults.");
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="QueryStructureResponseWriterV2"/> class.
 /// </summary>
 /// <param name="writer">
 /// The writer.
 /// </param>
 /// <param name="namespaces">
 /// The namespaces.
 /// </param>
 public QueryStructureResponseWriterV2(XmlWriter writer, SdmxNamespaces namespaces)
     : base(writer, namespaces)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CrossSectionalWriterEngine"/> class.
 /// </summary>
 /// <param name="writer">
 /// The output <see cref="XmlWriter"/>
 /// </param>
 /// <param name="namespaces">
 /// The output XML message namespaces.
 /// </param>
 /// <param name="sdmxSchema">
 /// The SDMX version.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="namespaces"/> is null
 /// </exception>
 public CrossSectionalWriterEngine(XmlWriter writer, SdmxNamespaces namespaces, SdmxSchema sdmxSchema)
     : base(writer, namespaces, sdmxSchema)
 {
     if (sdmxSchema.EnumType == SdmxSchemaEnumType.VersionTwoPointOne)
     {
         throw new ArgumentException(Resources.ErrorCrossWith21, "sdmxSchema");
     }
 }
        /// <summary>
        /// This method is used to write the root xml tag and *Data tag
        ///     with their corresponding attributes
        /// </summary>
        /// <param name="element">
        /// The first element tag name
        /// </param>
        /// <param name="namespaces">
        /// The namespaces used by sdmx that are
        ///     appended by this method as attributes of the *Data tag
        /// </param>
        protected void WriteMessageTag(string element, SdmxNamespaces namespaces)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            // <?xml version="1.0" encoding="UTF-8"?>
            if (!this.Wrapped)
            {
                this.SdmxMLWriter.WriteStartDocument();
            }

            // Generated File comment
            if (!string.IsNullOrEmpty(this._generatedFileComment))
            {
                this.SdmxMLWriter.WriteComment(this._generatedFileComment);
            }

            // <CompactData
            this.WriteStartElement(this.Namespaces.Message, element);

            // xmlns="http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message"
            this.WriteNamespaceDecl(this.Namespaces.Message);
            if (string.IsNullOrEmpty(this._namespacePrefix))
            {
                this._namespacePrefix = string.Format(
                    CultureInfo.InvariantCulture, "{0}{1}", PrefixConstants.DataSetStructureSpecific, this._prefixCount);
                this._prefixCount++;
            }

            switch (this.DataFormatType)
            {
                case BaseDataFormatEnumType.Generic:
                    this._dataSetNS = this.Namespaces.Generic;
                    break;
                case BaseDataFormatEnumType.Compact:
                case BaseDataFormatEnumType.CrossSectional:
                    this._dataSetNS = this._namespace == null
                                          ? this.BuildDSDSpecificUrn(this._namespacePrefix)
                                          : new NamespacePrefixPair(this._namespace, this._namespacePrefix);
                    this.Namespaces.DataSetStructureSpecific = this._dataSetNS;
                    break;
            }

            this.WriteNamespaceDecl(this._dataSetNS);

            // xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            this.WriteNamespaceDecl(this.Namespaces.Xsi);

            // xsi:schemaLocation="http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message SDMXMessage.xsd">
            string schemaLocation = this.Namespaces.SchemaLocation ?? string.Empty;
            string structureSpecific = this.GetSchemaLocation(this.TargetSchema.EnumType);
            if (!string.IsNullOrWhiteSpace(structureSpecific))
            {
                schemaLocation = string.Format(
                    CultureInfo.InvariantCulture, "{0} {1}", schemaLocation, structureSpecific);
            }

            if (!string.IsNullOrWhiteSpace(schemaLocation))
            {
                this.WriteAttributeString(this.Namespaces.Xsi, XmlConstants.SchemaLocation, schemaLocation);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="RegistryInterfaceReaderBaseV2"/> class.
 /// </summary>
 /// <param name="namespaces">
 /// The namespaces.
 /// </param>
 protected RegistryInterfaceReaderBaseV2(SdmxNamespaces namespaces)
     : base(namespaces)
 {
 }
Esempio n. 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HeaderReader"/> class.
 /// </summary>
 /// <param name="namespaces">
 /// The namespaces.
 /// </param>
 /// <param name="schema">
 /// The schema.
 /// </param>
 public HeaderReader(SdmxNamespaces namespaces, SdmxSchema schema)
     : base(namespaces, schema)
 {
 }
Esempio n. 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HeaderWriter"/> class.
 /// </summary>
 /// <param name="writer">
 /// The writer.
 /// </param>
 /// <param name="namespaces">
 /// The namespaces.
 /// </param>
 /// <param name="schema">
 /// The schema.
 /// </param>
 public HeaderWriter(XmlWriter writer, SdmxNamespaces namespaces, SdmxSchema schema)
     : base(writer, namespaces, schema)
 {
 }
Esempio n. 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HeaderWriter" /> class.
 /// </summary>
 /// <param name="writer">The writer.</param>
 /// <param name="namespaces">The namespaces.</param>
 /// <param name="schema">The schema.</param>
 /// <param name="retrievalManager">The header retrieval manager.</param>
 public HeaderWriter(XmlWriter writer, SdmxNamespaces namespaces, SdmxSchema schema, IHeaderRetrievalManager retrievalManager)
     : base(writer, namespaces, schema)
 {
     this._retrievalManager = retrievalManager;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="GenericDataWriterEngine"/> class.
 /// </summary>
 /// <param name="writer">
 /// The writer.
 /// </param>
 /// <param name="namespaces">
 /// The namespaces.
 /// </param>
 /// <param name="schema">
 /// The schema.
 /// </param>
 public GenericDataWriterEngine(XmlWriter writer, SdmxNamespaces namespaces, SdmxSchema schema)
     : base(writer, namespaces, schema)
 {
     if (this.IsTwoPointOne)
     {
         this._conceptAttribute = AttributeNameTable.id;
         this._writeObservationMethod = this.WriteObservation21;
     }
     else
     {
         this._conceptAttribute = AttributeNameTable.concept;
         this._writeObservationMethod = this.WriteObservation20;
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DataflowReaderV2"/> class.
 /// </summary>
 /// <param name="namespaces">
 /// The namespaces.
 /// </param>
 public DataflowReaderV2(SdmxNamespaces namespaces)
     : base(namespaces)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CategorySchemeWriterV2"/> class.
 /// </summary>
 /// <param name="writer">
 /// The writer.
 /// </param>
 /// <param name="namespaces">
 /// The namespaces.
 /// </param>
 public CategorySchemeWriterV2(XmlWriter writer, SdmxNamespaces namespaces)
     : base(writer, namespaces)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="QueryStructureRequestReaderV2"/> class.
 /// </summary>
 /// <param name="namespaces">
 /// The namespaces.
 /// </param>
 public QueryStructureRequestReaderV2(SdmxNamespaces namespaces)
     : base(namespaces)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Writer"/> class.
 /// </summary>
 /// <param name="writer">
 /// The output <see cref="XmlWriter"/>
 /// </param>
 /// <param name="targetSchema">
 /// The target SDMX Schema version
 /// </param>
 /// <param name="namespaces">
 /// The list of namespaces used by the message
 /// </param>
 protected Writer(
     XmlWriter writer, SdmxSchema targetSchema, SdmxNamespaces namespaces)
     : this(writer, namespaces, targetSchema)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DataStructureWriterV2"/> class.
 /// </summary>
 /// <param name="writer">
 /// The writer.
 /// </param>
 /// <param name="namespaces">
 /// The namespaces.
 /// </param>
 public DataStructureWriterV2(XmlWriter writer, SdmxNamespaces namespaces)
     : base(writer, namespaces)
 {
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="Writer"/> class.
        /// </summary>
        /// <param name="writer">
        /// The writer.
        /// </param>
        /// <param name="namespaces">
        /// The namespaces. If set the null then the default parameters
        /// </param>
        /// <param name="schema">
        /// The SDMX version schema.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="writer"/> is null
        ///     -or-
        ///     <paramref name="schema"/> is null
        /// </exception>
        protected Writer(XmlWriter writer, SdmxNamespaces namespaces, SdmxSchema schema)
            : base(namespaces, schema)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            if (schema == null)
            {
                throw new ArgumentNullException("schema");
            }

            this._writer = writer;
            this._wrapped = writer.WriteState != WriteState.Start;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DataStreamWriterBase"/> class.
 /// </summary>
 /// <param name="writer">
 /// The writer.
 /// </param>
 /// <param name="namespaces">
 /// The namespaces.
 /// </param>
 /// <param name="schema">
 /// The schema.
 /// </param>
 protected DataStreamWriterBase(XmlWriter writer, SdmxNamespaces namespaces, SdmxSchema schema)
     : base(writer, namespaces, schema)
 {
     Validate(namespaces);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="HierarchicalCodeListReaderV2"/> class.
 /// </summary>
 /// <param name="namespaces">
 /// The namespaces.
 /// </param>
 public HierarchicalCodeListReaderV2(SdmxNamespaces namespaces)
     : base(namespaces)
 {
 }
        /// <summary>
        /// The create namespaces.
        /// </summary>
        /// <param name="sdmxSchema">
        /// The SDMX version
        /// </param>
        /// <returns>
        /// The <see cref="SdmxNamespaces"/>.
        /// </returns>
        private static SdmxNamespaces CreateDataNamespaces(SdmxSchemaEnumType sdmxSchema)
        {
            var namespaces = new SdmxNamespaces
                                 {
                                     Xsi =
                                         new NamespacePrefixPair(
                                         XmlConstants.XmlSchemaNS, XmlConstants.XmlSchemaPrefix)
                                 };
            switch (sdmxSchema)
            {
                case SdmxSchemaEnumType.VersionOne:
                    namespaces.Common = new NamespacePrefixPair(SdmxConstants.CommonNs10, PrefixConstants.Common);
                    namespaces.Message = new NamespacePrefixPair(SdmxConstants.MessageNs10, string.Empty);
                    namespaces.Generic = new NamespacePrefixPair(SdmxConstants.GenericNs10, PrefixConstants.Generic);
                    namespaces.SchemaLocation = string.Format(
                        CultureInfo.InvariantCulture, "{0} SDMXMessage.xsd", SdmxConstants.MessageNs10);
                    break;
                case SdmxSchemaEnumType.VersionTwo:
                    namespaces.Common = new NamespacePrefixPair(SdmxConstants.CommonNs20, PrefixConstants.Common);
                    namespaces.Message = new NamespacePrefixPair(SdmxConstants.MessageNs20, string.Empty);
                    namespaces.Generic = new NamespacePrefixPair(SdmxConstants.GenericNs20, PrefixConstants.Generic);
                    namespaces.SchemaLocation = string.Format(
                        CultureInfo.InvariantCulture, "{0} SDMXMessage.xsd", SdmxConstants.MessageNs20);
                    break;
                case SdmxSchemaEnumType.VersionTwoPointOne:
                    namespaces.Common = new NamespacePrefixPair(SdmxConstants.CommonNs21, PrefixConstants.Common);
                    namespaces.Message = new NamespacePrefixPair(SdmxConstants.MessageNs21, PrefixConstants.Message);
                    namespaces.Generic = new NamespacePrefixPair(SdmxConstants.GenericNs21, PrefixConstants.Generic);
                    namespaces.StructureSpecific21 = new NamespacePrefixPair(
                        SdmxConstants.StructureSpecificNs21, PrefixConstants.StructureSpecific21);
                    namespaces.SchemaLocation = string.Format(
                        CultureInfo.InvariantCulture, "{0} SDMXMessage.xsd", SdmxConstants.MessageNs21);
                    break;
            }

            return namespaces;
        }
Esempio n. 22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CodeListWriterV2"/> class.
 /// </summary>
 /// <param name="writer">
 /// The writer.
 /// </param>
 /// <param name="namespaces">
 /// The namespaces.
 /// </param>
 public CodeListWriterV2(XmlWriter writer, SdmxNamespaces namespaces)
     : base(writer, namespaces)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CategorySchemeReaderV2"/> class.
 /// </summary>
 /// <param name="namespaces">
 /// The namespaces.
 /// </param>
 public CategorySchemeReaderV2(SdmxNamespaces namespaces)
     : base(namespaces)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MetadataStructureReaderV2"/> class. 
 /// </summary>
 /// <param name="namespaces">
 /// The namespaces.
 /// </param>
 public MetadataStructureReaderV2(SdmxNamespaces namespaces)
     : base(namespaces)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RegistryInterfaceWriterBaseV2"/> class.
 /// </summary>
 /// <exception cref="System.ArgumentNullException">
 /// writer is null
 /// </exception>
 /// <param name="writer">
 /// The XmlTextWriter object use to actually perform the writing
 /// </param>
 /// <param name="namespaces">
 /// The namespaces.
 /// </param>
 protected RegistryInterfaceWriterBaseV2(XmlWriter writer, SdmxNamespaces namespaces)
     : base(writer, namespaces)
 {
     this._commonPrefix = this.Namespaces.Common.Prefix;
     this._defaultNs = this.Namespaces.Registry;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RegistryInterfaceWriterV2"/> class.
 /// </summary>
 /// <param name="writer">
 /// The writer.
 /// </param>
 /// <param name="namespaces">
 /// The namespaces.
 /// </param>
 public RegistryInterfaceWriterV2(XmlWriter writer, SdmxNamespaces namespaces)
     : base(writer, namespaces)
 {
     this.HeaderRetrievalManager = new HeaderRetrievalManager();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CompactDataWriterEngine"/> class.
 /// </summary>
 /// <param name="writer">
 /// The writer.
 /// </param>
 /// <param name="namespaces">
 /// The namespaces.
 /// </param>
 /// <param name="schema">
 /// The schema.
 /// </param>
 public CompactDataWriterEngine(XmlWriter writer, SdmxNamespaces namespaces, SdmxSchema schema)
     : base(writer, namespaces, schema)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="StructureWriterBaseV2"/> class.
 ///     Initializes a new instance of the <see cref="StructureWriterV2"/> class.
 ///     Constructor that initialize the internal fields
 /// </summary>
 /// <exception cref="System.ArgumentNullException">
 /// writer is null
 /// </exception>
 /// <param name="writer">
 /// The XmlWriter object use to actually perform the writing
 /// </param>
 /// <param name="namespaces">
 /// The namespaces
 /// </param>
 protected StructureWriterBaseV2(XmlWriter writer, SdmxNamespaces namespaces)
     : base(writer, _versionTwo, namespaces)
 {
     this._defaultNs = this.Namespaces.Structure;
     this._rootNamespace = this.Namespaces.Message;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="HierarchicalCodeListWriterV2"/> class.
 /// </summary>
 /// <param name="writer">
 /// The writer.
 /// </param>
 /// <param name="namespaces">
 /// The namespaces.
 /// </param>
 public HierarchicalCodeListWriterV2(XmlWriter writer, SdmxNamespaces namespaces)
     : base(writer, namespaces)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ConceptSchemeReaderV2"/> class.
 /// </summary>
 /// <param name="namespaces">
 /// The namespaces.
 /// </param>
 public ConceptSchemeReaderV2(SdmxNamespaces namespaces)
     : base(namespaces)
 {
 }