当前位置: 首页>>代码示例>>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;未经允许,请勿转载。