📄 galleryconfiguration.cs
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
// Copyright (c) Telligent Systems Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System.IO;
using System.Web.Caching;
using System.Xml;
using CommunityServer.Components;
using CommunityServer.Configuration;
namespace CommunityServer.Galleries.Components
{
/// <summary>
/// Summary description for GalleryConfiguration.
/// </summary>
public class GalleryConfiguration
{
#region Private Members
private bool enableFileSystemStorage = false;
private string fileSystemStorageLocation = "~/photos/storage";
private string calculatedLocation = null;
private bool enableThemes = true;
private string defaultTemplate = "default";
private bool enableSkinCache = true;
private string themeLocation = "~/Themes/Galleries/";
#endregion
#region Public Properties
public bool EnableFileSystemStorage
{
get { return enableFileSystemStorage; }
}
public string FileSystemStorageLocation
{
get { return fileSystemStorageLocation; }
}
public bool EnableThemes
{
get { return enableThemes; }
}
public string DefaultTemplate
{
get { return defaultTemplate; }
}
public bool EnableSkinCache
{
get { return enableSkinCache; }
}
public string ThemeLocation
{
get { return themeLocation; }
}
#endregion
private GalleryConfiguration() {}
#region Public Methods
public string CalculateFileSystemStorageLocation()
{
if(calculatedLocation == null)
{
// Make sure it isn't a drive reference like "c:\blah" or a UNC name like "\\machine\share"
if((fileSystemStorageLocation.IndexOf( ":\\" ) != -1) || (fileSystemStorageLocation.IndexOf( "\\\\" ) != -1))
calculatedLocation = fileSystemStorageLocation;
else
calculatedLocation = CSContext.Current.MapPath( fileSystemStorageLocation );
// Add the end directory separator if missing
if(!calculatedLocation.EndsWith( Path.DirectorySeparatorChar.ToString() ))
calculatedLocation += Path.DirectorySeparatorChar;
}
return calculatedLocation;
}
public string CalculatePictureFileSystemLocation(int settingsID, int sectionID, int pictureID)
{
return string.Format( "{0}{1}.{2}.{3}", CalculateFileSystemStorageLocation(), settingsID, sectionID, pictureID );
}
#endregion
#region Public Static Methods
public static GalleryConfiguration Instance()
{
string cacheKey = "GalleryConfiguration";
GalleryConfiguration config = CSCache.Get(cacheKey) as GalleryConfiguration;
if(config == null)
{
XmlNode node = CSConfiguration.GetConfig().GetConfigSection("CommunityServer/Gallery");
config = new GalleryConfiguration();
if(node != null)
{
XmlAttributeCollection attributeCollection = node.Attributes;
try { config.enableFileSystemStorage = bool.Parse( attributeCollection["enableFileSystemStorage"].Value ); }
catch { config.enableFileSystemStorage = false; }
config.fileSystemStorageLocation = attributeCollection["fileSystemStorageLocation"].Value;
if(attributeCollection["enableThemes"] != null)
config.enableThemes = bool.Parse(attributeCollection["enableThemes"].Value);
if(attributeCollection["defaultTemplate"] != null)
config.defaultTemplate = attributeCollection["defaultTemplate"].Value;
if(attributeCollection["enableSkinCache"] != null)
config.enableSkinCache = bool.Parse(attributeCollection["enableSkinCache"].Value);
if(attributeCollection["themeLocation"] != null)
config.themeLocation = attributeCollection["themeLocation"].Value;
}
CacheDependency dep = new CacheDependency(null, new string[]{CSConfiguration.CacheKey});
CSCache.Insert(cacheKey, config, dep);
}
return config;
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -