public static System.Text.StringBuilder Write(
            System.Xml.XmlDocument document)
        {
            var settings = new System.Xml.XmlWriterSettings();
            settings.CheckCharacters = true;
            settings.CloseOutput = true;
            settings.ConformanceLevel = System.Xml.ConformanceLevel.Auto;
            settings.Indent = true;
            settings.IndentChars = new string(' ', 4);
            settings.NewLineChars = "\n";
            settings.NewLineHandling = System.Xml.NewLineHandling.None;
            settings.NewLineOnAttributes = false;
            settings.OmitXmlDeclaration = false;
            settings.Encoding = new System.Text.UTF8Encoding(false); // do not write BOM

            var xmlString = new System.Text.StringBuilder();
            using (var xmlWriter = System.Xml.XmlWriter.Create(xmlString, settings))
            {
                document.WriteTo(xmlWriter);
                xmlWriter.WriteWhitespace(settings.NewLineChars);
            }

            return xmlString;
        }
예제 #2
0
파일: Http.cs 프로젝트: smithydll/boxsocial
 public void WriteStream(System.IO.MemoryStream stream)
 {
     stream.WriteTo(HttpContext.Current.Response.OutputStream);
 }
예제 #3
0
        //public static double GetAttribute(this XmlNode suiteResult, string name, double defaultValue)
        //{
        //    XmlAttribute attr = suiteResult.Attributes[name];

        //    return attr == null
        //        ? defaultValue
        //        : double.Parse(attr.Value, System.Globalization.CultureInfo.InvariantCulture);
        //}

        #endregion

        public static string ToFormattedString(System.Xml.XmlNode node, int indentation)
        {
            using (var sw = new System.IO.StringWriter())
            {
                using (var xw = new System.Xml.XmlTextWriter(sw))
                {
                    xw.Formatting = System.Xml.Formatting.Indented;
                    xw.Indentation = indentation;
                    node.WriteTo(xw);
                }
                return sw.ToString();
            }
        }
예제 #4
0
파일: Lote.aspx.cs 프로젝트: pjeconde/eFact
		private void RegistrarActividad(FeaEntidades.InterFacturas.lote_comprobantes lote, System.Text.StringBuilder sb, System.Net.Mail.SmtpClient smtpClient, string smtpXAmb, System.IO.MemoryStream m)
		{
			//Registro cantidad de comprobantes
			if (((CedWebEntidades.Sesion)Session["Sesion"]).Cuenta.Id != null)
			{
				CedWebRN.Cuenta.RegistrarComprobante(((CedWebEntidades.Sesion)Session["Sesion"]).Cuenta, (CedEntidades.Sesion)Session["Sesion"]);
			}

			if (((CedWebEntidades.Sesion)Session["Sesion"]).Flag.ModoDepuracion)
			{
				//ModoDepuracion encendido
				System.IO.FileStream fs = new System.IO.FileStream(Server.MapPath(@"~/Temp/" + sb.ToString()), System.IO.FileMode.Create);
				m.WriteTo(fs);
				fs.Close();
			}
		}
예제 #5
0
 protected ResponseAction OK(System.Collections.ICollection models, JsonWriterOptions options)
 {
     return r =>
     {
         r.StatusCode = (int)HttpStatusCode.OK;
         models.WriteTo(r.Output, false, options);
     };
 }
예제 #6
0
        private void Write(
            System.Xml.XmlDocument document,
            string path)
        {
            // do not write a Byte-Ordering-Mark (BOM)
            var encoding = new System.Text.UTF8Encoding(false);

            System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(path));
            using (var writer = new System.IO.StreamWriter(path, false, encoding))
            {
                var settings = new System.Xml.XmlWriterSettings();
                settings.OmitXmlDeclaration = false;
                settings.NewLineChars = "\n";
                settings.Indent = true;
                settings.IndentChars = "   ";
                settings.NewLineOnAttributes = true;
                using (var xmlWriter = System.Xml.XmlWriter.Create(writer, settings))
                {
                    document.WriteTo(xmlWriter);
                    xmlWriter.WriteWhitespace(settings.NewLineChars);
                }
            }
        }