public FileResult Decompressor(DecompressorModel model) { const int BUFFER_SIZE = 4096; if (ModelState.IsValid) { if (model.File != null) { switch (model.Action) { case CompressorActions.Compress: break; case CompressorActions.Decompress: string fileName = Path.GetFileNameWithoutExtension(model.File.FileName); /* * using (MemoryStream ms = new MemoryStream()) * { * using (GZipStream input = new GZipStream(model.File.InputStream, CompressionMode.Decompress, false)) * { * byte[] buffer = new byte[BUFFER_SIZE]; * int n; * while ((n = input.Read(buffer, 0, buffer.Length)) > 0) * ms.Write(buffer, 0, n); * * input.Close(); * } * ms.Close(); * * return File(ms, "application/octet-stream", fileName); * }*/ break; default: throw new NotImplementedException(string.Format(Resources.Controllers.Apps.Decompressor.NotImplementedAction.ToString(), model.Action.ToString())); } return(File("", "application/octet-stream", "Output.xml")); } else { string message = Resources.Controllers.Apps.Decompressor.FileUploadedIsInvalid.ToString(); throw new Exception(message); } } else { MvcUtility.ProcessInvalidModelState(ModelState); return(null); } }
protected override void RenderContents(IHtmlWriter writer, IDotvvmRequestContext context) { var parameters = new RouteValueDictionary(); foreach (var param in Params.RawValues) { var value = param.Value is IValueBinding ? ((IValueBinding)param.Value).Evaluate(this) : param.Value; parameters.Add(param.Key, value); } var w = new StringWriter(); MvcUtility.RenderView(ControllerName, ViewName, parameters, Model, w); writer.WriteUnencodedText(w.ToString()); }
public RenderMvcView(MvcUtility mvcUtility) { this.mvcUtility = mvcUtility; }