/// <summary>
        /// Write the specified <paramref name="registry"/>
        /// </summary>
        /// <param name="registry">
        /// The <see cref="IRegistryInfo"/> object
        /// </param>
        public void Write(IRegistryInfo registry)
        {
            if (registry == null)
            {
                throw new ArgumentNullException("registry");
            }

            if (registry.QueryStructureResponse != null)
            {
                this.WriteQueryStructureResponse(registry.QueryStructureResponse);
            }
        }
コード例 #2
0
        /// <summary>
        /// This is the main method of the class and is used to write the <see cref="IRegistryInfo"/>
        ///     to the <see cref="System.Xml.XmlTextWriter"/> given in the constructor
        /// </summary>
        /// <param name="registryInterface">
        /// The <see cref="IRegistryInfo"/> object we want to write
        /// </param>
        public void WriteRegistryInterface(IRegistryInfo registryInterface)
        {
            if (registryInterface == null)
            {
                throw new ArgumentNullException("registryInterface");
            }

            this._registryInterface = registryInterface;
            this.WriteMessageTag(ElementNameTable.RegistryInterface);

            // print message header
            this.WriteMessageHeader(this._registryInterface.Header);

            // write QueryStructureRequest
            if (this._registryInterface.QueryStructureRequest != null)
            {
                var writer = new QueryStructureRequestWriterV2(this.SdmxMLWriter, this.Namespaces);
                writer.Write(registryInterface);
            }

            // write QueryStructureResponse
            if (this._registryInterface.QueryStructureResponse != null)
            {
                var writer = new QueryStructureResponseWriterV2(this.SdmxMLWriter, this.Namespaces);
                writer.Write(registryInterface);
            }

            // close document
            this.WriteEndElement();
            this.WriteEndDocument();
            if (this._closeXmlWriter)
            {
                this.SdmxMLWriter.Close();
            }
        }
 /// <summary>
 /// Read contents from <paramref name="reader"/> to <paramref name="registry"/>.
 /// </summary>
 /// <param name="reader">
 /// The reader.
 /// </param>
 /// <param name="registry">
 /// The registry.
 /// </param>
 protected override void ReadContents(XmlReader reader, IRegistryInfo registry)
 {
     base.ReadContents(reader, localName => HandleChildElements(registry.QueryStructureRequest, localName));
 }
コード例 #4
0
        /// <summary>
        /// Parses the reader opened against the stream containing the contents of a SDMX-ML Registry message or
        ///     RegistryInterface structure contents and populates the given <see cref="IRegistryInfo"/> object.
        /// </summary>
        /// <exception cref="System.ArgumentNullException">
        /// <paramref name="reader"/> is null
        /// </exception>
        /// <exception cref="ParseException">
        /// SDMX structure message parsing error
        /// </exception>
        /// <param name="registry">
        /// The <see cref="IRegistryInfo"/> object to populate
        /// </param>
        /// <param name="reader">
        /// The xml reader opened against the stream containing the structure contents
        /// </param>
        public void Read(IRegistryInfo registry, XmlReader reader)
        {
            if (registry == null)
            {
                throw new ArgumentNullException("registry");
            }

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

            this._registryInterface = registry;
            this.ReadContents(reader, registry);
        }
コード例 #5
0
 /// <summary>
 /// Read contents from <paramref name="reader"/> to <paramref name="registry"/>.
 /// </summary>
 /// <param name="reader">
 /// The reader.
 /// </param>
 /// <param name="registry">
 /// The registry.
 /// </param>
 protected abstract void ReadContents(XmlReader reader, IRegistryInfo registry);
        // ///<summary>Handle Structure Child elements</summary>
        // /// <param name="parent">The parent IMutableObjects object</param>
        // /// <param name="localName">The name of the current xml element</param>
        // /// <param name="reader">The xml reader to be passed to Structure Reader</param>
        // /// <returns>The created SDMX model entity object corresponding to the current xml element or null if there is none</returns>
        // private object HandleStructureChildElements(Model.Structure.IMutableObjects parent,object localName,Dictionary<string,string> attributes,XmlReader reader) {
        // object current = null;
        // ReadStructure(parent, reader);
        // return current;
        // }

        /// <summary>
        /// Handles the Registry Interface top level elements
        ///     This includes
        /// </summary>
        /// <param name="parent">
        /// The parent <see cref="IRegistryInfo"/>
        /// </param>
        /// <param name="localName">
        /// The name of the current xml element
        /// </param>
        /// <returns>
        /// Always null
        /// </returns>
        private ElementActions HandleTopLevel(IRegistryInfo parent, object localName)
        {
            if (NameTableCache.IsElement(localName, ElementNameTable.QueryStructureRequest))
            {
                parent.QueryStructureRequest = new QueryStructureRequestInfo();
                parent.QueryStructureRequest.ResolveReferences = Helper.TrySetFromAttribute(
                    this.Attributes, 
                    AttributeNameTable.resolveReferences, 
                    parent.QueryStructureRequest.ResolveReferences);
                parent.QueryStructureRequest.ReturnDetails = Helper.TrySetFromAttribute(
                    this.Attributes, AttributeNameTable.returnDetails, parent.QueryStructureRequest.ReturnDetails);
                var requestReaderV2 = new QueryStructureRequestReaderV2(this.Namespaces);
                requestReaderV2.Read(parent, this.Reader);
            }
            else if (NameTableCache.IsElement(localName, ElementNameTable.QueryStructureResponse))
            {
                parent.QueryStructureResponse = new QueryStructureResponseInfo();
                var responseReaderV2 = new QueryStructureResponseReaderV2(this.Namespaces);
                responseReaderV2.Read(parent, this.Reader);
            }

            return null;
        }
        /// <summary>
        /// Read contents from <paramref name="reader"/> to <paramref name="registry"/>.
        /// </summary>
        /// <param name="reader">
        /// The reader.
        /// </param>
        /// <param name="registry">
        /// The registry.
        /// </param>
        protected override void ReadContents(XmlReader reader, IRegistryInfo registry)
        {
            bool foundMessage = false;
            while (!foundMessage && reader.Read())
            {
                switch (reader.NodeType)
                {
                        // Start Element
                    case XmlNodeType.Element:
                        object localName = reader.LocalName;
                        if (NameTableCache.IsElement(localName, ElementNameTable.RegistryInterface)
                            && reader.NamespaceURI.Equals(this.Namespaces.Message.NS))
                        {
                            foundMessage = true;
                            this.RegistryInterface.Header = this.ReadHeader(reader);
                        }

                        break;
                }
            }

            if (!foundMessage)
            {
                return;
            }

            base.ReadContents(reader, o => this.HandleTopLevel(this.RegistryInterface, o));
        }
コード例 #8
0
 /// <summary>
 /// Read contents.
 /// </summary>
 /// <param name="reader">
 /// The reader.
 /// </param>
 /// <param name="rootObject">
 /// The root object.
 /// </param>
 protected override void ReadContents(XmlReader reader, IRegistryInfo rootObject)
 {
     base.ReadContents(reader, o => this.HandleChildElements(this.RegistryInterface.QueryStructureResponse, o));
 }