/// <summary> /// Writes the application trust to a new template ClickOnce application manifest. /// </summary> /// <param name="output">Specifies an output stream.</param> public void WriteManifest(Stream output) { string r = "manifest.xml"; Stream input = Util.GetEmbeddedResourceStream(r); WriteManifest(input, output); }
public void WriteManifest(Stream output) { string name = "manifest.xml"; Stream embeddedResourceStream = Util.GetEmbeddedResourceStream(name); this.WriteManifest(embeddedResourceStream, output); }
public static Stream XslTransform(string resource, Stream input, params DictionaryEntry[] entries) { int tickCount = Environment.TickCount; Stream embeddedResourceStream = Util.GetEmbeddedResourceStream(resource); int num2 = Environment.TickCount; XPathDocument stylesheet = new XPathDocument(embeddedResourceStream); Util.WriteLog(string.Format(CultureInfo.CurrentCulture, "new XPathDocument(1) t={1}", new object[] { resource, Environment.TickCount - num2 })); int num3 = Environment.TickCount; System.Xml.Xsl.XslTransform transform = new System.Xml.Xsl.XslTransform(); transform.Load(stylesheet, resolver, evidence); Util.WriteLog(string.Format(CultureInfo.CurrentCulture, "XslTransform.Load t={1}", new object[] { resource, Environment.TickCount - num3 })); MemoryStream output = new MemoryStream(); Util.CopyStream(input, output); int num4 = Environment.TickCount; XPathDocument document2 = new XPathDocument(output); Util.WriteLog(string.Format(CultureInfo.CurrentCulture, "new XPathDocument(2) t={1}", new object[] { resource, Environment.TickCount - num4 })); XsltArgumentList args = null; if (entries.Length > 0) { args = new XsltArgumentList(); foreach (DictionaryEntry entry in entries) { string name = entry.Key.ToString(); object parameter = entry.Value.ToString(); args.AddParam(name, "", parameter); Util.WriteLog(string.Format(CultureInfo.CurrentCulture, "arg: key='{0}' value='{1}'", new object[] { name, parameter.ToString() })); } } MemoryStream w = new MemoryStream(); XmlTextWriter writer = new XmlTextWriter(w, Encoding.UTF8); writer.WriteStartDocument(); int num1 = Environment.TickCount; transform.Transform((IXPathNavigable)document2, args, (XmlWriter)writer, resolver); Util.WriteLog(string.Format(CultureInfo.CurrentCulture, "XslTransform.Transform t={1}", new object[] { resource, Environment.TickCount - num4 })); writer.WriteEndDocument(); writer.Flush(); w.Position = 0L; Util.WriteLog(string.Format(CultureInfo.CurrentCulture, "XslTransform(\"{0}\") t={1}", new object[] { resource, Environment.TickCount - tickCount })); return(w); }
public static Stream XslTransform(string resource, Stream input, params DictionaryEntry[] entries) { int t1 = Environment.TickCount; Stream s = Util.GetEmbeddedResourceStream(resource); int t2 = Environment.TickCount; XPathDocument d = new XPathDocument(s); Util.WriteLog(String.Format(CultureInfo.CurrentCulture, "new XPathDocument(1) t={0}", Environment.TickCount - t2)); int t3 = Environment.TickCount; XslCompiledTransform xslc = new XslCompiledTransform(); // Using the Trusted Xslt is fine as the style sheet comes from our own assemblies. // This is similar to the prior this.GetType().Assembly/Evidence method that was used in the now depricated XslTransform. xslc.Load(d, XsltSettings.TrustedXslt, s_resolver); Util.WriteLog(String.Format(CultureInfo.CurrentCulture, "XslCompiledTransform.Load t={0}", Environment.TickCount - t3)); // Need to copy input stream because XmlReader will close it, // causing errors for later callers that access the same stream MemoryStream clonedInput = new MemoryStream(); Util.CopyStream(input, clonedInput); int t4 = Environment.TickCount; XmlReader xml = XmlReader.Create(clonedInput); Util.WriteLog(String.Format(CultureInfo.CurrentCulture, "new XmlReader(2) t={0}", Environment.TickCount - t4)); XsltArgumentList args = null; if (entries.Length > 0) { args = new XsltArgumentList(); foreach (DictionaryEntry entry in entries) { string key = entry.Key.ToString(); object val = entry.Value.ToString(); args.AddParam(key, "", val); Util.WriteLog(String.Format(CultureInfo.CurrentCulture, "arg: key='{0}' value='{1}'", key, val.ToString())); } } MemoryStream m = new MemoryStream(); XmlTextWriter w = new XmlTextWriter(m, Encoding.UTF8); w.WriteStartDocument(); int t5 = Environment.TickCount; xslc.Transform(xml, args, w, s_resolver); Util.WriteLog(String.Format(CultureInfo.CurrentCulture, "XslCompiledTransform.Transform t={0}", Environment.TickCount - t4)); w.WriteEndDocument(); w.Flush(); m.Position = 0; Util.WriteLog(String.Format(CultureInfo.CurrentCulture, "XslCompiledTransform(\"{0}\") t={1}", resource, Environment.TickCount - t1)); return(m); }