Beispiel #1
0
        private void WriteOutRawXml(IMvcContext context, GraphOptions options)
        {
            var val = context.ActionResult;

            context.ContentType = MimeHelper.GetMimeByExtension("xml");
            if (val is IGraphSource)
            {
                val = ((IGraphSource)val).BuildGraph(options);
            }
            var xmls = Application.Container.Get <ISerializer>("xml.serializer");

            xmls.Serialize("dot.xml", val, context.Output);
        }
        /// <summary>
        /// Сохраняет файл в Wiki
        /// </summary>
        /// <returns></returns>
        protected override object MainProcess()
        {
            var srcname = _file.FileName;
            var ext     = Path.GetExtension(srcname);
            var mime    = MimeHelper.GetMimeByExtension(ext);
            var binobj  = new WikiBinary();

            binobj.Code     = Code;
            binobj.Title    = string.IsNullOrWhiteSpace(Title) ? Code : Title;
            binobj.MimeType = mime;
            var data = new byte[_file.ContentLength];

            using (var s = _file.InputStream) {
                s.Read(data, 0, (int)s.Length);
            }
            binobj.Data = data;
            WikiSource.SaveBinary(binobj);
            return(true);
        }
Beispiel #3
0
        /// <summary>
        ///     Renders given context
        /// </summary>
        /// <param name="context"> </param>
        public override void Render(IMvcContext context)
        {
            GraphOptions options   = ExtractOptions(context);
            string       dotscript = DotSerializer.Serialize(options.Context.ActionResult, options: options);

            context.ContentType = MimeHelper.GetMimeByExtension(options.Format);
            string script = dotscript.GetUnicodeSafeXmlString();

            if (options.Format == "dot")
            {
                context.ContentType = "text/plain";
                context.Output.Write(script);
            }
            else if (options.Format == "rawxml")
            {
                WriteOutRawXml(context, options);
            }
            else
            {
                GenerateGraph(context, dotscript, options);
            }
        }