bool TryProcessXapRequest(HttpSocket s, string path) { // must end with XAP if (string.Compare(Path.GetExtension(path), ".xap", StringComparison.OrdinalIgnoreCase) != 0) { return(false); } // XAP already there? if (File.Exists(path)) { return(false); } // Directory must be present string dir = Path.GetDirectoryName(path) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(path); if (!Directory.Exists(dir)) { return(false); } byte[] xapBytes = null; try { xapBytes = XapBuilder.XapToMemory(dir); } catch (Exception e) { s.WriteErrorResponse(500, "error generating XAP: " + e.Message); return(true); } s.WriteBinaryResponse(200, "application/x-zip-compressed", xapBytes, false); return(true); }
public override void ProcessRequest(HttpContext context) { InternalProcessRequest(context, delegate(string pdirpath, string path) { // create in memory XAP archive if (Directory.Exists(pdirpath)) { var xapBuffer = XapBuilder.XapToMemory(pdirpath); context.Response.OutputStream.Write(xapBuffer, 0, xapBuffer.Length); } else { throw new HttpException(404, "Missing " + path); } }); }