當前位置: 首頁>>代碼示例>>C#>>正文


C# XmlSerializerNamespaces.Add方法代碼示例

本文整理匯總了C#中System.Xml.Serialization.XmlSerializerNamespaces.Add方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlSerializerNamespaces.Add方法的具體用法?C# XmlSerializerNamespaces.Add怎麽用?C# XmlSerializerNamespaces.Add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Xml.Serialization.XmlSerializerNamespaces的用法示例。


在下文中一共展示了XmlSerializerNamespaces.Add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: getRequestContent

        public byte[] getRequestContent( string doctype, string root, Type type, object obj)
        {
            XmlSerializer serializer = null;
            if (root == null)
            {
                //... root element will be the object type name
                serializer = new XmlSerializer(type);
            }
            else
            {
                //... root element set explicitely
                var xattribs = new XmlAttributes();
                var xroot = new XmlRootAttribute(root);
                xattribs.XmlRoot = xroot;
                var xoverrides = new XmlAttributeOverrides();
                xoverrides.Add(type, xattribs);
                serializer = new XmlSerializer(type, xoverrides);
            }
            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Indent = false;
            settings.OmitXmlDeclaration = false;
            settings.Encoding = new UTF8Encoding(false/*no BOM*/, true/*throw if input illegal*/);

            XmlSerializerNamespaces xmlNameSpace = new XmlSerializerNamespaces();
            xmlNameSpace.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance");
            xmlNameSpace.Add("noNamespaceSchemaLocation", m_schemadir + "/" + doctype + "." + m_schemaext);

            StringWriter sw = new StringWriter();
            XmlWriter xw = XmlWriter.Create( sw, settings);
            xw.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");

            serializer.Serialize(xw, obj, xmlNameSpace);

            return settings.Encoding.GetBytes( sw.ToString());
        }
開發者ID:ProjectTegano,項目名稱:Tegano,代碼行數:35,代碼來源:Serializer.cs

示例2: Cancelar

        public string Cancelar()
        {
            try
            {
                XmlSerializerNamespaces nameSpaces = new XmlSerializerNamespaces();
                nameSpaces.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance");
                nameSpaces.Add("tipos", "http://localhost:8080/WsNFe2/tp");
                nameSpaces.Add("ns1", "http://localhost:8080/WsNFe2/lote");

                string sPath = Pastas.PROTOCOLOS + "\\REQ_CANC_LOTE_" + objCancelamento.lote.Id.Replace("Lote:", "") + ".xml";
                if (File.Exists(sPath))
                {
                    File.Delete(sPath);
                }

                string sXmlSerializer = null;
                XmlSerializer xs = new XmlSerializer(typeof(ReqCancelamentoNFSe));
                MemoryStream memory = new MemoryStream();
                XmlTextWriter xmltext = new XmlTextWriter(memory, Encoding.UTF8);
                xs.Serialize(xmltext, objCancelamento, nameSpaces);
                UTF8Encoding encoding = new UTF8Encoding();
                sXmlSerializer = encoding.GetString(memory.ToArray());
                sXmlSerializer = sXmlSerializer.Substring(1);

                belAssinaXml Assinatura = new belAssinaXml();
                sXmlSerializer = Assinatura.ConfigurarArquivo(sXmlSerializer, "Lote", Acesso.cert_NFs);


                //SerializeClassToXml.SerializeClasse<ReqCancelamentoNFSe>(objCancelamento, sPath, nameSpaces);

                XmlDocument xmlConsulta = new XmlDocument();
                xmlConsulta.LoadXml(sXmlSerializer);
                xmlConsulta.Save(sPath);
                belValidaXml.ValidarXml("http://localhost:8080/WsNFe2/lote", Pastas.SCHEMA_NFSE_DSF + "\\ReqCancelamentoNFSe.xsd", sPath);

                string sPathRetConsultaCanc = Pastas.PROTOCOLOS + "\\Ret_CANC_LOTE_" + objCancelamento.lote.Id.Replace("Lote:", "") + ".xml";



                HLP.GeraXml.WebService.NFSE_Campinas.LoteRpsService lt = new WebService.NFSE_Campinas.LoteRpsService();
                string sRetornoLote = lt.cancelar(xmlConsulta.InnerXml);

                xmlConsulta = new XmlDocument();
                xmlConsulta.LoadXml(sRetornoLote);
                xmlConsulta.Save(sPathRetConsultaCanc);


                //   sPathRetConsultaCanc = @"D:\Ret_CANC_LOTE_2805131157.xml";

                RetornoCancelamentoNFSe objretorno = SerializeClassToXml.DeserializeClasse<RetornoCancelamentoNFSe>(sPathRetConsultaCanc);

                string sMessageRetorno = TrataRetornoCancelamento(objretorno);
                return sMessageRetorno;

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
開發者ID:dramosti,項目名稱:GeraXml_3.0,代碼行數:60,代碼來源:belCancelamentoDSF.cs

示例3: Parse

        /// <summary>
        /// Parses the export file at the specified disk path.
        /// </summary>
        /// <param name="diskPathToExportFile">The disk path to the export file.</param>
        public Feed Parse(string diskPathToExportFile)
        {
            diskPathToExportFile.CheckNullOrEmpty("diskPathToExportFile");

            Log.InfoFormat("blogger2jekyll.Blogger.ExportXmlParses conversion started at {0}.", DateTime.Now);
            Log.InfoFormat("Using Blogger import file at {0}", diskPathToExportFile);

            XmlDocument sourceDocument = new XmlDocument();
            sourceDocument.Load(diskPathToExportFile);

            XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
            ns.Add(string.Empty, string.Empty);
            ns.Add("app", "http://purl.org/atom/app#");

            XmlSerializer serializer = new XmlSerializer(typeof(Feed));
            Feed feed = (Feed)serializer.Deserialize(new StringReader(sourceDocument.OuterXml));

            ProcessComments(feed);
            ProcessPages(feed);
            ProcessSettings(feed);

            Log.InfoFormat("blogger2jekyll.Blogger.ExportXmlParses conversion completed at {0}.", DateTime.Now);
            Log.InfoFormat("The blog {0} was converted.", feed.Title);
            Log.InfoFormat("{0} posts were found in the export file.", feed.Posts.Count);

            return feed;
        }
開發者ID:kcargile,項目名稱:blogger2jekyll,代碼行數:31,代碼來源:ExportXmlParser.cs

示例4: ToXML

        public XmlDocument ToXML()
        {
            using (MemoryStream stream = new MemoryStream())
            {
                // xmlns:georss="http://www.georss.org/georss"
                // xmlns:gml="http://www.opengis.net/gml"
                //xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
                //xmlns:kml="http://www.opengis.net/kml/2.2"
                //xmlns:dc="http://purl.org/dc/elements/1.1/"
                var ns = new XmlSerializerNamespaces();
                ns.Add("georss", "http://www.georss.org/georss");
                ns.Add("gml", "http://www.opengis.net/gml");
                ns.Add("geo", "http://www.w3.org/2003/01/geo/wgs84_pos#");
                ns.Add("kml", "http://www.opengis.net/kml/2.2");
                ns.Add("dc", "http://purl.org/dc/elements/1.1/");

                XmlSerializer s = new XmlSerializer(this.GetType());
                Console.WriteLine("Testing for type: {0}", this.GetType());
                s.Serialize(XmlWriter.Create(stream), this, ns);
                stream.Flush();
                stream.Seek(0, SeekOrigin.Begin);
                //object o = s.Deserialize(XmlReader.Create(stream));
                //Console.WriteLine("  Deserialized type: {0}", o.GetType());
                XmlDocument xml = new XmlDocument();
                xml.Load(stream);
                Console.Write(xml.InnerXml);
                return xml;
            }

            //var serializer = new XmlSerializer(this.GetType());
            //serializer.Serialize(new StreamWriter("test.xml"), this);
        }
開發者ID:halljames,項目名稱:GeoRSS,代碼行數:32,代碼來源:GeoRSS.cs

示例5: WriteObject

		public bool WriteObject(XPathResult result, XPathNavigator node, object value)
		{
			var rootOverride = new XmlRootAttribute(node.LocalName)
			{
				Namespace = node.NamespaceURI
			};

			var xml = new StringBuilder();
			var settings = new XmlWriterSettings
			{
				OmitXmlDeclaration = true,
				Indent = false
			};
			var namespaces = new XmlSerializerNamespaces();
			namespaces.Add(string.Empty, string.Empty);
			if (string.IsNullOrEmpty(node.NamespaceURI) == false)
			{
				var prefix = result.Context.AddNamespace(node.NamespaceURI);
				namespaces.Add(prefix, node.NamespaceURI);
			}

			var serializer = new XmlSerializer(result.Type, rootOverride);

			using (var writer = XmlWriter.Create(xml, settings))
			{
				serializer.Serialize(writer, value, namespaces);
				writer.Flush();
			}

			node.ReplaceSelf(xml.ToString());

			return true;
		}
開發者ID:ThatExtraBit,項目名稱:Castle.Core,代碼行數:33,代碼來源:DefaultXmlSerializer.cs

示例6: Write

        public void Write(Stream outputStream, object artifact)
        {
            using (var stream = new MemoryStream())
            {
                var serializer = new XmlSerializer(artifact.GetType(), "http://schemas.microsoft.com/winfx/2006/xaml/presentation");
                var ns = new XmlSerializerNamespaces();
                ns.Add("", "http://schemas.microsoft.com/winfx/2006/xaml/presentation");
                ns.Add("ds", "http://schemas.allscripts.com/cds/evaluation");
                ns.Add("am", "http://schemas.allscripts.com/mom");
                serializer.Serialize(stream, artifact, ns);

                // This seems like a bug with the serializer to me, but the outer-most instance of
                // Composite expression within the artifact is serialized with the prefix ds, instead
                // of am, even though the CompositeAssertion class has the XmlNamespaceAttribute with
                // allscripts.com/mom as given above. So we serialize the output to a temporary stream,
                // read it into a string, replace the offending instance with the correct value, and
                // then write the output stream with that string.
                stream.Position = 0;
                using (var sr = new StreamReader(stream))
                {
                    var result = sr.ReadToEnd();

                    using (var sw = new StreamWriter(outputStream))
                    {
                        sw.Write(result.Replace("ds:CompositeAssertion", "am:CompositeAssertion"));
                    }
                }
            }
        }
開發者ID:suesse,項目名稱:healthedecisions,代碼行數:29,代碼來源:CREFWriter.cs

示例7: SaveDelta

        public static void SaveDelta(Delta delta, string file)
        {
            var ns = new XmlSerializerNamespaces();
            ns.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance");
            ns.Add("xsd", "http://www.w3.org/2001/XMLSchema");

            var serializer = new XmlSerializer(typeof(Delta));
            
            var list = new List<ImportObject>();
            foreach (var obj in delta.Objects.Where(x => x.NeedsInclude()))
            {
                var newObj = new ImportObject();
                newObj.SourceObjectIdentifier = obj.SourceObjectIdentifier;
                newObj.TargetObjectIdentifier = obj.TargetObjectIdentifier;
                newObj.ObjectType = obj.ObjectType;
                newObj.State = obj.State;
                newObj.Changes = obj.Changes != null ? obj.Changes.Where(x => x.IsIncluded).ToArray() : null;
                newObj.AnchorPairs = obj.AnchorPairs;
                list.Add(newObj);
            }

            var newDelta = new Delta();
            newDelta.Objects = list.ToArray();

			var settings = new XmlWriterSettings();
			settings.OmitXmlDeclaration = false;
			settings.Indent = true;
            using (var w = XmlWriter.Create(file, settings))
                serializer.Serialize(w, newDelta, ns);
        }
開發者ID:bdesmond,項目名稱:FIMDelta,代碼行數:30,代碼來源:DeltaParser.cs

示例8: UseCase

        public UseCase()
        {
            Xmlns = new XmlSerializerNamespaces();
            Xmlns.Add("ns3", ScenarioDocuXMLFileUtil.ScenarioNameSpace);
            Xmlns.Add("xs", ScenarioDocuXMLFileUtil.XmlSchema);

            Details = new Details();
        }
開發者ID:scenarioo,項目名稱:scenarioo-cs,代碼行數:8,代碼來源:UseCase.cs

示例9: Step

        public Step()
        {
            ScreenAnnotations = new List<ScreenAnnotation>();

            Xmlns = new XmlSerializerNamespaces();
            Xmlns.Add("ns3", ScenarioDocuXMLFileUtil.ScenarioNameSpace);
            Xmlns.Add("xs", ScenarioDocuXMLFileUtil.XmlSchema);
        }
開發者ID:scenarioo,項目名稱:scenarioo-cs,代碼行數:8,代碼來源:Step.cs

示例10: ReadRSS

        public static Rss ReadRSS(Stream source)
        {
            XmlSerializerNamespaces xsn = new XmlSerializerNamespaces();
            xsn.Add("atom", "http://www.w3.org/2005/Atom");
            xsn.Add("dc", "http://purl.org/dc/elements/1.1/");
            xsn.Add("content", "http://purl.org/rss/1.0/modules/content/");

            XmlSerializer ser = new XmlSerializer(typeof(Rss));
            return (Rss)ser.Deserialize(source);
        }
開發者ID:ApmeM,項目名稱:Simple-RSS,代碼行數:10,代碼來源:RSSHelper.cs

示例11: SpreadsheetXmlSerializer

 public SpreadsheetXmlSerializer()
 {
     _xmlSerializer = new XmlSerializer(typeof (Workbook), "urn:schemas-microsoft-com:office:spreadsheet");
     _xmlNamespaces = new XmlSerializerNamespaces();
     _xmlNamespaces.Add("ss", "urn:schemas-microsoft-com:office:spreadsheet");
     _xmlNamespaces.Add("x", "urn:schemas-microsoft-com:office:excel");
     _xmlNamespaces.Add("o", "urn:schemas-microsoft-com:office:office");
     _xmlNamespaces.Add("c", "urn:schemas-microsoft-com:office:component:spreadsheet");
     _xmlNamespaces.Add("html", "http://www.w3.org/TR/REC-html40");
 }
開發者ID:junshao,項目名稱:Medidata.MsExcel2003.Xml,代碼行數:10,代碼來源:SpreadsheetXmlSerializer.cs

示例12: ReadRss

        public static Structure.RssFeed ReadRss(Stream source)
        {
            var xsn = new XmlSerializerNamespaces();
            xsn.Add("atom", "http://www.w3.org/2005/Atom");
            xsn.Add("dc", "http://purl.org/dc/elements/1.1/");
            xsn.Add("content", "http://purl.org/rss/1.0/modules/content/");

            var ser = new XmlSerializer(typeof(Structure.RssFeed));
            return (Structure.RssFeed)ser.Deserialize(source);
        }
開發者ID:KnownSubset,項目名稱:CustomizableRss,代碼行數:10,代碼來源:RSSHelper.cs

示例13: WriteRss

        public static void WriteRss(Structure.RssFeed value, Stream destination)
        {
            var xsn = new XmlSerializerNamespaces();
            xsn.Add("atom", "http://www.w3.org/2005/Atom");
            xsn.Add("dc", "http://purl.org/dc/elements/1.1/");
            xsn.Add("content", "http://purl.org/rss/1.0/modules/content/");

            var ser = new XmlSerializer(value.GetType());
            ser.Serialize(destination, value, xsn);
        }
開發者ID:KnownSubset,項目名稱:CustomizableRss,代碼行數:10,代碼來源:RSSHelper.cs

示例14: Scenario

        public Scenario()
        {
            Xmlns = new XmlSerializerNamespaces();
            Xmlns.Add("ns3", ScenarioDocuXMLFileUtil.ScenarioNameSpace);
            Xmlns.Add("xs", ScenarioDocuXMLFileUtil.XmlSchema);

            Name = string.Empty;
            Description = string.Empty;
            Status = string.Empty;
            Details = new Details();
        }
開發者ID:scenarioo,項目名稱:scenarioo-cs,代碼行數:11,代碼來源:Scenario.cs

示例15: Serialize

        public static void Serialize(Manifest manifest, StreamWriter writer)
        {
            var xs = new XmlSerializer(typeof(Manifest));

            var xsn = new XmlSerializerNamespaces();
            xsn.Add(SCORM.Adlcp, SCORM.AdlcpNamespaceV1P3);
            xsn.Add(SCORM.Imsss, SCORM.ImsssNamespace);
            xsn.Add(SCORM.Adlseq, SCORM.AdlseqNamespace);
            xsn.Add(SCORM.Adlnav, SCORM.AdlnavNamespace);
            xsn.Add(SCORM.Imsss, SCORM.ImsssNamespace);

            xs.Serialize(writer, manifest, xsn);
        }
開發者ID:supermuk,項目名稱:iudico,代碼行數:13,代碼來源:ManifestManager.cs


注:本文中的System.Xml.Serialization.XmlSerializerNamespaces.Add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。