Beispiel #1
0
        public override void WriteToStream(Type type, object value, System.IO.Stream writeStream, System.Net.Http.HttpContent content)
        {
            ICanvasScript script = (ICanvasScript)value;
            var           html   = Westwind.Web.Mvc.ViewRenderer.RenderView("~/Views/CanvasScripts/View.cshtml", script);

            var writer = new System.IO.StreamWriter(writeStream);

            writer.Write(html);
            writer.Flush();
        }
Beispiel #2
0
        public override System.Threading.Tasks.Task WriteToStreamAsync(Type type, object value, System.IO.Stream writeStream, System.Net.Http.HttpContent content, System.Net.TransportContext transportContext)
        {
            ICanvasScript script = (ICanvasScript)value;


            var xScript = new XElement(XName.Get("CanvasScript"),
                                       new XElement(XName.Get("Author"), script.AuthorName),
                                       new XElement(XName.Get("Name"), script.Name),
                                       new XElement(XName.Get("Created"), script.Created.ToString("s")),
                                       new XElement(XName.Get("Mikdified"), script.Modified.ToString("s")),
                                       new XElement(XName.Get("ScriptAsJson"), script.ScriptAsJson)
                                       );

            var xWriter         = System.Xml.XmlWriter.Create(writeStream);
            var xScriptAsString = xScript.ToString();

            return(System.Threading.Tasks.Task.Run(() => xScript.WriteTo(xWriter)));
        }
Beispiel #3
0
        public override void WriteToStream(Type type, object value, System.IO.Stream writeStream, System.Net.Http.HttpContent content)
        {
            ICanvasScript script = (ICanvasScript)value;


            var xScript = new XElement(XName.Get("CanvasScript"),
                                       new XElement(XName.Get("Author"), script.AuthorName),
                                       new XElement(XName.Get("Name"), script.Name),
                                       new XElement(XName.Get("Created"), script.Created.ToString("s")),
                                       new XElement(XName.Get("Modified"), script.Modified.ToString("s")),
                                       new XElement(XName.Get("ScriptAsJson"), script.ScriptAsJson)
                                       );

            var xWriter         = System.Xml.XmlWriter.Create(writeStream);
            var xScriptAsString = xScript.ToString();

            xScript.WriteTo(xWriter);
            xWriter.Flush();
        }