Пример #1
0
 public void Process()
 {
     foreach (string str in this.templateFileList)
     {
         string content = string.Empty;
         string path    = HttpContext.Current.Server.MapPath(this.templateFodler + str);
         if (File.Exists(path))
         {
             using (StreamReader reader = new StreamReader(path, Encoding.UTF8))
             {
                 content = reader.ReadToEnd();
                 reader.Close();
             }
             this.IncludeHandler(ref content);
             this.TagHandler(ref content);
             string str4 = string.Empty;
             foreach (Match match in this.namespaceRg.Matches(content))
             {
                 str4    = str4 + "\r\nusing " + match.Groups[1].ToString() + " ;";
                 content = content.Replace(match.Groups[0].ToString(), string.Empty);
             }
             string folderName = FileHelper.GetFolderName(str);
             string fileName   = FileHelper.GetFileName(str);
             string str10      = ((("<%@ WebHandler Language=\"C#\" Class=\"" + this.nameSpace + "." + fileName + "\" %>") + "\r\nusing System;\r\nusing System.Text;\r\nusing System.Web;\r\nusing System.Collections;\r\nusing System.Collections.Generic;" + str4) + "\r\nnamespace " + this.nameSpace) + "\r\n{";
             string s          = ((((((str10 + "\r\npublic class " + fileName + " : " + this.inheritsNameSpace + "." + fileName) + "\r\n{" + "\r\nprotected override void ShowPage()") + "\r\n{" + "\r\n\t/* ") + "\r\n\t\t本页面代码由天易模板生成于 " + DateTime.Now.ToString() + ".") + "\r\n\t*/") + this.PrepareOut(this.LineHandler(content)) + "\r\n}") + "\r\n}" + "\r\n}";
             string str8       = HttpContext.Current.Server.MapPath(this.ashxFolder + folderName);
             if (!Directory.Exists(str8))
             {
                 Directory.CreateDirectory(str8);
             }
             using (FileStream stream = new FileStream(str8 + fileName + ".ashx", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite))
             {
                 byte[] bytes = Encoding.UTF8.GetBytes(s);
                 stream.Write(bytes, 0, bytes.Length);
                 stream.Close();
             }
         }
         if (this.OnProcessing != null)
         {
             int currentPage = this.templateFileList.IndexOf(str) + 1;
             int count       = this.templateFileList.Count;
             this.OnProcessing(this, new ProcessingEventArgs(count, currentPage));
         }
     }
     if (this.OnProcessFinished != null)
     {
         this.OnProcessFinished(this, new EventArgs());
     }
 }