Пример #1
0
        /// <summary>
        /// Gets the XML request.
        /// </summary>
        /// <returns>XML.</returns>
        public string GetRequest()
        {
            var qbXml = new QBXML
            {
                Items            = qbxmlMsgsRqList.ToArray(),
                ItemsElementName = Enumerable.Repeat(ItemsChoiceType99.QBXMLMsgsRq, qbxmlMsgsRqList.Count()).ToArray()
            };

            using var writer          = new StringWriter();
            using XmlWriter xmlWriter = new QbXmlTextWriter(writer);
            xmlWriter.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"utf-8\"");
            xmlWriter.WriteProcessingInstruction("qbxml", string.Format("version=\"{0}.{1}\"", VERSION.Major, VERSION.Minor));
            var ns = new XmlSerializerNamespaces();

            ns.Add("", "");
            QbXmlSerializer.Instance.XmlSerializer.Serialize(xmlWriter, qbXml, ns);

            xmlWriter.Flush();
            return(writer.ToString());
        }
Пример #2
0
        public string GetRequest()
        {
            var qbXml = new QBXML
            {
                Items = qbxmlMsgsRqList.ToArray(),
                ItemsElementName = Enumerable.Repeat<ItemsChoiceType99>(ItemsChoiceType99.QBXMLMsgsRq, qbxmlMsgsRqList.Count()).ToArray()
            };

            using (MemoryStream memoryStream = new MemoryStream())
            using (XmlWriter xmlWriter = new QbXmlTextWriter(memoryStream, Encoding.UTF8))
            {
                xmlWriter.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"utf-8\"");
                xmlWriter.WriteProcessingInstruction("qbxml", string.Format("version=\"{0}.{1}\"", VERSION.Major, VERSION.Minor));
                var ns = new XmlSerializerNamespaces();
                ns.Add("", "");
                QbXmlSerializer.Instance.XmlSerializer.Serialize(xmlWriter, qbXml, ns);

                xmlWriter.Flush();
                memoryStream.Position = 0;
                var streamReader = new StreamReader(memoryStream);
                return streamReader.ReadToEnd();
            }
        }
Пример #3
0
        public string GetRequest()
        {
            var qbXml = new QBXML
            {
                Items            = qbxmlMsgsRqList.ToArray(),
                ItemsElementName = Enumerable.Repeat <ItemsChoiceType99>(ItemsChoiceType99.QBXMLMsgsRq, qbxmlMsgsRqList.Count()).ToArray()
            };

            using (MemoryStream memoryStream = new MemoryStream())
                using (XmlWriter xmlWriter = new QbXmlTextWriter(memoryStream, Encoding.UTF8))
                {
                    xmlWriter.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"utf-8\"");
                    xmlWriter.WriteProcessingInstruction("qbxml", string.Format("version=\"{0}.{1}\"", VERSION.Major, VERSION.Minor));
                    var ns = new XmlSerializerNamespaces();
                    ns.Add("", "");
                    QbXmlSerializer.Instance.XmlSerializer.Serialize(xmlWriter, qbXml, ns);

                    xmlWriter.Flush();
                    memoryStream.Position = 0;
                    var streamReader = new StreamReader(memoryStream);
                    return(streamReader.ReadToEnd());
                }
        }