代码高亮插件(直接复制支持中文)

          最近整理了一个工作流引擎,准备点文章以资纪念。但是找的几个代码高亮的工具都不好用。要么是编辑的时候看不到效果,要不就是不支持中文,再来就是自定义的类没有高亮显示,反正就是不爽。所以花费了2天时间写了一个Windows Live Writer的代码插件(下载地址)。

          使用说明:从Visual Studio中复制代码,在Windows Live Writer中点击 image ,代码就到页面了。Visual Studio中什么样子复制过来就是什么样子。字体会变成Consolas。Firefox,Chrome中占用高度为300px,IE中无效。

          多的没什么了,效果如下:

 

Code
  1.         /// <summary>
  2.         /// 保存数据
  3.         /// </summary>
  4.         /// <param name="SaveList">要保持的列表</param>
  5.         /// <param name="msg">错误信息</param>
  6.         /// <returns>是否成功</returns>
  7.         public bool Save(List<T_AppraiseTeachers> SaveList, ref string msg)
  8.         {
  9.             bool Result = false;
  10.             if (SaveList.Count(a => a.ID == 0) > 0)
  11.             {
  12.                 //新增
  13.                 using (DBEntities db = new DBEntities())
  14.                 {
  15.                     foreach (var a in SaveList)
  16.                     {
  17.                         db.AddToT_AppraiseTeachers(a);
  18.                     }
  19.                     try
  20.                     {
  21.                         db.SaveChanges();
  22.                         Result = true;
  23.                     }
  24.                     catch (Exception ex)
  25.                     {
  26.                         msg = ex.Message;
  27.                     }
  28.                 }
  29.             }
  30.             else
  31.             {
  32.                 //保存
  33.                 var IDs = (from a in SaveList.AsParallel()
  34.                            select a.ID).ToList();
  35.                 using (DBEntities db = new DBEntities())
  36.                 {
  37.                     var query = (from a in db.T_AppraiseTeachers
  38.                                  where IDs.Contains(a.ID)
  39.                                  select a).ToList();
  40.                     foreach (var a in SaveList)
  41.                     {
  42.                         db.ApplyCurrentValues("T_AppraiseTeachers", a);
  43.                     }
  44.                     try
  45.                     {
  46.                         db.SaveChanges();
  47.                         Result = true;
  48.                     }
  49.                     catch (Exception ex)
  50.                     {
  51.                         msg = ex.Message;
  52.                     }
  53.                 }
  54.             }
  55.             return Result;
  56.         }
posted @ 2010-09-16 08:46  ☆磊☆  阅读(1068)  评论(0编辑  收藏  举报