Load() public method

public Load ( ) : void
return void
コード例 #1
0
ファイル: BlogController.cs プロジェクト: eshengsky/iBlog
 public async Task<ViewResult> Item(string id)
 {
     if (id.Equals("about", StringComparison.CurrentCultureIgnoreCase))
     {
         var configSettings = new ConfigSettings();
         var config = new AboutConfig(configSettings, "About", Server.MapPath("~/Settings"));
         config.Load();
         return View("About", config);
     }
     if (id.Equals("guestbook", StringComparison.CurrentCultureIgnoreCase))
     {
         return View("Guestbook");
     }
     var cacheKey = "post_" + id;
     var post = RedisManager.GetItem<Post>(cacheKey);
     if (post == null)
     {
         post = await _postRepository.GetPostByAlias(id);
         if (post != null)
         {
             RedisManager.SetItem(cacheKey, post, new TimeSpan(0, Settings.Config.CacheExpired, 0));
         }
     }
     if (post != null)
     {
         var item = new PostItem
         {
             UniqueId = post.UniqueId,
             Title = post.Title,
             CategoryAlias = post.CategoryAlias,
             CateName = await _categoryRepository.GetNameByAlias(post.CategoryAlias),
             CreateTimeStr = post.CreateTime.ToString("yy-MM-dd HH:mm"),
             ViewCount = post.ViewCount,
             LabelList = JsonConvert.DeserializeObject<List<LabelShow>>(post.Labels).Select(t => t.Text).ToList(),
             Summary = post.Summary,
             Content = post.Content
         };
         return View(item);
     }
     else
     {
         var error = new Elmah.Error(new Exception("文章id:" + id + " 不存在!"), System.Web.HttpContext.Current) { StatusCode = 404 };
         Elmah.ErrorLog.GetDefault(System.Web.HttpContext.Current).Log(error);
         return View("Error404");
     }
 }
コード例 #2
0
ファイル: AdminController.cs プロジェクト: eshengsky/iBlog
 /// <summary>
 /// 关于管理
 /// </summary>
 /// <returns></returns>
 public ActionResult AboutManage()
 {
     var configSettings = new ConfigSettings();
     var config = new AboutConfig(configSettings, "About", Server.MapPath("~/Settings"));
     config.Load();
     return View(config);
 }