📄 weblogconfiguration.cs
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
// Copyright (c) Telligent Systems Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Web.Caching;
using System.Xml;
using CommunityServer.Components;
using CommunityServer.Configuration;
namespace CommunityServer.Blogs.Components
{
/// <summary>
/// Summary description for WeblogConfiguration.
/// </summary>
public class WeblogConfiguration
{
public static WeblogConfiguration Instance()
{
string cacheKey = "WeblogConfiguration";
WeblogConfiguration config = CSCache.Get(cacheKey) as WeblogConfiguration;
if(config == null)
{
XmlNode node = CSConfiguration.GetConfig().GetConfigSection("CommunityServer/Weblog");
config = new WeblogConfiguration();
if(node != null)
{
XmlAttributeCollection attcol = node.Attributes;
XmlAttribute skinCache = attcol["enableSkinCache"];
if(skinCache != null)
config._enableSkinCache = bool.Parse(skinCache.Value);
XmlAttribute defaultTemplate = attcol["defaultTheme"];
if(defaultTemplate != null)
config._defaultTemplate = defaultTemplate.Value;
XmlAttribute postSize = attcol["aggregatePostSize"];
if(postSize != null)
config._aggregatePostSize = Int32.Parse(postSize.Value);
XmlAttribute blogDirs = attcol["createDirectories"];
if(blogDirs != null)
config._createBlogDirectories = bool.Parse(blogDirs.Value);
XmlAttribute spc = attcol["servicePostCountLimit"];
if(spc != null)
config._servicePostCountLimit = Int32.Parse(spc.Value);
XmlAttribute apc = attcol["aggregatePostCount"];
if(apc != null)
config._aggregatePostCount = Int32.Parse(apc.Value);
XmlAttribute ipc = attcol["individualPostCount"];
if(ipc != null)
config._individualPostCount = Int32.Parse(ipc.Value);
XmlAttribute et = attcol["enableThemes"];
if(et != null)
config._enableThemes = bool.Parse(et.Value);
XmlAttribute pbDisplay = attcol["postedbyDisplay"];
if(pbDisplay != null)
{
try
{
config._postedbyDisplay = (BlogPostedByDisplayType)Enum.Parse(typeof(BlogPostedByDisplayType), attcol["postedbyDisplay"].Value);
}
catch
{
throw new CSException(CSExceptionType.SiteSettingsInvalidXML, "Weblogs postedbyDisplay setting was not recognized. It must be one of these three values: Weblog, UserName, or Off.");
}
}
}
CacheDependency dep = new CacheDependency(null, new string[]{CSConfiguration.CacheKey});
CSCache.Insert(cacheKey, config, dep);
}
return config;
}
//TODO: Make this dynamic
private WeblogConfiguration()
{
}
private bool _enableThemes = true;
public bool EnableThemes
{
get { return _enableThemes;}
}
private string _themeLocation = "~/Themes/Blogs/";
/// <summary>
/// Property ThemeLocation (string)
/// </summary>
public string ThemeLocation
{
get { return this._themeLocation; }
}
private bool _enableSkinCache = true;
public bool EnableSkinCache
{
get{return _enableSkinCache;}
}
private string _defaultTemplate = "default";
public string DefaultTheme
{
get{return _defaultTemplate;}
}
private int _aggregatePostSize = -1;
public int AggregatePostSize
{
get{return _aggregatePostSize;}
}
public bool TruncateAggregatePost
{
get{return AggregatePostSize > 0; }
}
bool _createBlogDirectories = true;
public bool CreateBlogDirectories
{
get{ return _createBlogDirectories; }
}
private int _servicePostCountLimit = 25;
public int ServicePostCountLimit
{
get{return _servicePostCountLimit;}
}
private int _aggregatePostCount = 25;
public int AggregatePostCount
{
get { return _aggregatePostCount;}
}
private int _individualPostCount = 15;
public int IndividualPostCount
{
get { return _individualPostCount;}
}
private BlogPostedByDisplayType _postedbyDisplay = BlogPostedByDisplayType.Weblog;
public BlogPostedByDisplayType PostedbyDisplay
{
get { return _postedbyDisplay;}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -