namespace dotless.Core.configuration { using System; using Input; using Loggers; using Plugins; using System.Collections.Generic; public enum DotlessSessionStateMode { /// /// Session is not used. /// Disabled, /// /// Session is loaded for each request to Dotless HTTP handler. /// Enabled, /// /// Session is loaded when URL QueryString parameter specified by is truthy. /// QueryParam } public class DotlessConfiguration { public const string DEFAULT_SESSION_QUERY_PARAM_NAME = "sstate"; public const int DefaultHttpExpiryInMinutes = 10080; //7 days public static DotlessConfiguration GetDefault() { return new DotlessConfiguration(); } public static DotlessConfiguration GetDefaultWeb() { return new DotlessConfiguration { Web = true }; } public DotlessConfiguration() { LessSource = typeof (FileReader); MinifyOutput = false; Debug = false; CacheEnabled = true; HttpExpiryInMinutes = DefaultHttpExpiryInMinutes; Web = false; SessionMode = DotlessSessionStateMode.Disabled; SessionQueryParamName = DEFAULT_SESSION_QUERY_PARAM_NAME; Logger = null; LogLevel = LogLevel.Error; Optimization = 1; Plugins = new List(); MapPathsToWeb = true; HandleWebCompression = true; KeepFirstSpecialComment = false; RootPath = ""; StrictMath = false; } public DotlessConfiguration(DotlessConfiguration config) { LessSource = config.LessSource; MinifyOutput = config.MinifyOutput; Debug = config.Debug; CacheEnabled = config.CacheEnabled; Web = config.Web; SessionMode = config.SessionMode; SessionQueryParamName = config.SessionQueryParamName; Logger = null; LogLevel = config.LogLevel; Optimization = config.Optimization; Plugins = new List(); Plugins.AddRange(config.Plugins); MapPathsToWeb = config.MapPathsToWeb; DisableUrlRewriting = config.DisableUrlRewriting; InlineCssFiles = config.InlineCssFiles; ImportAllFilesAsLess = config.ImportAllFilesAsLess; HandleWebCompression = config.HandleWebCompression; DisableParameters = config.DisableParameters; KeepFirstSpecialComment = config.KeepFirstSpecialComment; RootPath = config.RootPath; StrictMath = config.StrictMath; } /// /// Keep first comment begining /** /// public bool KeepFirstSpecialComment { get; set; } /// /// Disable using parameters /// public bool DisableParameters { get; set; } /// /// Stops URL's being adjusted depending on the imported file location /// public bool DisableUrlRewriting { get; set; } /// /// Allows you to add a path to every generated import and url in your output css. /// This corresponds to 'rootpath' option of lessc. /// public string RootPath { get; set; } /// /// Disables variables being redefined, so less will search from the bottom of the input up. /// Makes dotless behave like less.js with regard variables /// [Obsolete("The Variable Redefines feature has been removed to align with less.js")] public bool DisableVariableRedefines { get; set; } /// /// Disables hex color shortening /// [Obsolete("The Color Compression feature has been removed to align with less.js")] public bool DisableColorCompression { get; set; } /// /// Inlines css files into the less output /// public bool InlineCssFiles { get; set; } /// /// import all files (even if ending in .css) as less files /// public bool ImportAllFilesAsLess { get; set; } /// /// When this is a web configuration, whether to map the paths to the website or just /// be relative to the current directory /// public bool MapPathsToWeb { get; set; } /// /// Whether to minify the ouput /// public bool MinifyOutput { get; set; } /// /// Prints helpful comments in the output while debugging. /// public bool Debug { get; set; } /// /// For web handlers output in a cached mode. Reccommended on. /// public bool CacheEnabled { get; set; } /// /// When is set to true, use this parameter to set how far in the future the expires header will be set. /// For example, to have the browser cache the CSS for five minutes, set this property to 5. /// public int HttpExpiryInMinutes { get; set; } /// /// IFileReader type to use to get imported files /// public Type LessSource { get; set; } /// /// Whether this is used in a web context or not /// public bool Web { get; set; } /// /// Specifies the mode the HttpContext.Session is loaded. /// public DotlessSessionStateMode SessionMode { get; set; } /// /// Gets or sets the URL QueryString parameter name used in conjunction with set to . /// public string SessionQueryParamName { get; set; } /// /// The ILogger type /// public Type Logger { get; set; } /// /// The Log level /// public LogLevel LogLevel { get; set; } /// /// Optimisation int /// 0 - do not chunk up the input /// > 0 - chunk up output /// /// Recommended value - 1 /// public int Optimization { get; set; } /// /// Whether to handle the compression (e.g. look at Accept-Encoding) - true or leave it to IIS - false /// public bool HandleWebCompression { get; set; } /// /// Plugins to use /// public List Plugins { get; private set; } /// /// Whether to only evaluate mathematical expressions when they are wrapped in an extra set of parentheses. /// public bool StrictMath { get; set; } } }