コード例 #1
0
 public virtual string Run(FileInfo path, out NSJSException exception)
 {
     if (path == null)
     {
         throw new ArgumentNullException("path");
     }
     if (!path.Exists)
     {
         throw new FileNotFoundException("path");
     }
     byte[] source = File.ReadAllBytes(path.FullName);
     return(Run(FileAuxiliary.GetEncoding(source).GetString(source), path.FullName, out exception));
 }
コード例 #2
0
        public bool Handle()
        {
            int methodid = this.GetMethodId();

            if (methodid != 1 && methodid != 3)
            {
                return(false);
            }
            string path = (application.Root + request.Url.LocalPath);

            if (string.IsNullOrEmpty(path))
            {
                return(false);
            }
            path = Path.GetFullPath(path);
            if (!File.Exists(path))
            {
                return(false);
            }
            string ext = Path.GetExtension(path);

            if (string.IsNullOrEmpty(ext))
            {
                return(false);
            }
            try
            {
                response.ContentType = HttpContentTypeTable.Get(ext = ext.ToLower());
                if (string.IsNullOrEmpty(response.ContentType))
                {
                    response.ContentType = "application/octet-stream";
                }
                response.ContentEncoding = FileAuxiliary.GetEncoding(path);
                this.ProcessRequest(methodid, path);
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }