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<IPluginConfigurator>(); Plugins.AddRange(config.Plugins); MapPathsToWeb = config.MapPathsToWeb; DisableUrlRewriting = config.DisableUrlRewriting; InlineCssFiles = config.InlineCssFiles; ImportAllFilesAsLess = config.ImportAllFilesAsLess; HandleWebCompression = config.HandleWebCompression; DisableParameters = config.DisableParameters; DisableVariableRedefines = config.DisableVariableRedefines; DisableColorCompression = config.DisableColorCompression; KeepFirstSpecialComment = config.KeepFirstSpecialComment; RootPath = config.RootPath; StrictMath = config.StrictMath; }
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 <IPluginConfigurator>(); Plugins.AddRange(config.Plugins); MapPathsToWeb = config.MapPathsToWeb; DisableUrlRewriting = config.DisableUrlRewriting; InlineCssFiles = config.InlineCssFiles; ImportAllFilesAsLess = config.ImportAllFilesAsLess; HandleWebCompression = config.HandleWebCompression; DisableParameters = config.DisableParameters; DisableVariableRedefines = config.DisableVariableRedefines; DisableColorCompression = config.DisableColorCompression; KeepFirstSpecialComment = config.KeepFirstSpecialComment; RootPath = config.RootPath; }
public void Process(BundleContext context, BundleResponse response) { var config = new DotlessConfiguration(); // config.Plugins.Add(new BuildNumberPluginConfigurator()); response.Content = Less.Parse(response.Content, config); response.ContentType = "text/css"; }
protected override void RegisterParameterSource(FluentRegistration pandora, DotlessConfiguration configuration) { if (!configuration.DisableParameters) { pandora.Service<IParameterSource>().Implementor<QueryStringParameterSource>().Lifestyle.Transient(); } }
public void HandlerImplInstanceIsTransient() { var config = new DotlessConfiguration { Web = true }; var serviceLocator = new AspNetContainerFactory().GetContainer(config); var handler1 = serviceLocator.GetInstance<HandlerImpl>(); var handler2 = serviceLocator.GetInstance<HandlerImpl>(); Assert.That(handler1, Is.Not.SameAs(handler2)); var http1 = handler1.Http; var http2 = handler2.Http; Assert.That(http1, Is.Not.SameAs(http2)); var response1 = handler1.Response; var response2 = handler2.Response; Assert.That(response1, Is.Not.SameAs(response2)); var engine1 = handler1.Engine; var engine2 = handler2.Engine; Assert.That(engine1, Is.Not.SameAs(engine2)); }
public static ILessEngine GetEngine(DotlessConfiguration config) { if (config == null) { config = new WebConfigConfigurationLoader().GetConfiguration(); } return new EngineFactory(config).GetEngine(new AspNetContainerFactory()); }
public DotlessConfiguration(DotlessConfiguration config) { LessSource = config.LessSource; MinifyOutput = config.MinifyOutput; CacheEnabled = config.CacheEnabled; Web = config.Web; Logger = null; LogLevel = config.LogLevel; Optimization = config.Optimization; }
public string FilterContent(string content, ContentFilterContext context) { var config = new DotlessConfiguration { MinifyOutput = context.Minify, Web = HttpContext.Current != null, LessSource = typeof(VirtualPathFileReader), CacheEnabled = false /* no need to cache as we let the Assman framework manage its own cache */ }; return dotless.Core.Less.Parse(content, config); }
public void HttpInstanceIsTransient() { var config = new DotlessConfiguration { Web = true }; var serviceLocator = new AspNetContainerFactory().GetContainer(config); var http1 = serviceLocator.GetInstance<IHttp>(); var http2 = serviceLocator.GetInstance<IHttp>(); Assert.That(http1, Is.Not.SameAs(http2)); }
public DotlessConfiguration Process(XmlNode section) { var dotlessConfiguration = DotlessConfiguration.GetDefaultWeb(); dotlessConfiguration.MinifyOutput = GetBoolValue(section, "minifyCss") ?? dotlessConfiguration.MinifyOutput; dotlessConfiguration.Debug = GetBoolValue(section, "debug") ?? dotlessConfiguration.Debug; dotlessConfiguration.CacheEnabled = GetBoolValue(section, "cache") ?? dotlessConfiguration.CacheEnabled; dotlessConfiguration.Optimization = GetIntValue(section, "optimization") ?? dotlessConfiguration.Optimization; dotlessConfiguration.DisableUrlRewriting = GetBoolValue(section, "disableUrlRewriting") ?? dotlessConfiguration.DisableUrlRewriting; dotlessConfiguration.InlineCssFiles = GetBoolValue(section, "inlineCssFiles") ?? dotlessConfiguration.InlineCssFiles; dotlessConfiguration.ImportAllFilesAsLess = GetBoolValue(section, "importAllFilesAsLess") ?? dotlessConfiguration.ImportAllFilesAsLess; dotlessConfiguration.MapPathsToWeb = GetBoolValue(section, "mapPathsToWeb") ?? dotlessConfiguration.MapPathsToWeb; dotlessConfiguration.HandleWebCompression = GetBoolValue(section, "handleWebCompression") ?? dotlessConfiguration.HandleWebCompression; dotlessConfiguration.DisableParameters = GetBoolValue(section, "disableParameters") ?? dotlessConfiguration.DisableParameters; var logLevel = GetStringValue(section, "log") ?? "default"; switch (logLevel.ToLowerInvariant()) { case "info": dotlessConfiguration.LogLevel = LogLevel.Info; break; case "debug": dotlessConfiguration.LogLevel = LogLevel.Debug; break; case "warn": dotlessConfiguration.LogLevel = LogLevel.Warn; break; case "error": dotlessConfiguration.LogLevel = LogLevel.Error; break; case "default": break; default: break; } var source = GetTypeValue(section, "source"); if (source != null) { dotlessConfiguration.LessSource = source; } dotlessConfiguration.Logger = GetTypeValue(section, "logger"); dotlessConfiguration.Plugins.AddRange(GetPlugins(section)); return(dotlessConfiguration); }
public DotlessConfiguration GetConfiguration() { if (mDotConfigCache == null) { mDotConfigCache = (DotlessConfiguration)ConfigurationManager.GetSection("dotless"); if (mDotConfigCache == null) mDotConfigCache = DotlessConfiguration.DefaultWeb; } return mDotConfigCache; }
/// <summary> /// Construct LESS Parser /// </summary> /// <param name="file"></param> /// <param name="config"></param> /// <returns></returns> private static Parser GetParser(string file, DotlessConfiguration config) { var fullPath = HttpContext.Current.Server.MapPath(file); var parser = new Parser(); var fileReader = new WebFileReader(new WebPathResolver(fullPath)); var importer = new WebImporter(fileReader, config.DisableUrlRewriting, config.InlineCssFiles, config.ImportAllFilesAsLess); parser.Importer = importer; return parser; }
public DotlessConfiguration(DotlessConfiguration config) { LessSource = config.LessSource; MinifyOutput = config.MinifyOutput; CacheEnabled = config.CacheEnabled; Web = config.Web; Logger = null; LogLevel = config.LogLevel; Optimization = config.Optimization; Plugins = new List<IPluginConfigurator>(); Plugins.AddRange(config.Plugins); }
public DotlessConfiguration(DotlessConfiguration config) { LessSource = config.LessSource; MinifyOutput = config.MinifyOutput; CacheEnabled = config.CacheEnabled; Web = config.Web; Logger = null; LogLevel = config.LogLevel; Optimization = config.Optimization; Plugins = new List <IPluginConfigurator>(); Plugins.AddRange(config.Plugins); }
public void Process(BundleContext context, BundleResponse response) { var config = new DotlessConfiguration { MinifyOutput = true, ImportAllFilesAsLess = true, CacheEnabled = true, LessSource = typeof (VirtualFileReader) }; response.Content = Less.Parse(response.Content, config); response.ContentType = "text/css"; }
public void Process(BundleContext context, BundleResponse response) { DotlessConfiguration config = new DotlessConfiguration(); config.MinifyOutput = false; config.ImportAllFilesAsLess = true; config.CacheEnabled = false; config.LessSource = typeof(VirtualFileReader); #if DEBUG config.Logger = typeof(DiagnosticsLogger); #endif response.Content = Less.Parse(response.Content, config); response.ContentType = "text/css"; }
public DotlessConfiguration GetConfiguration() { var webconfig = ConfigurationManager.GetSection <DotlessConfiguration>("dotless"); if (webconfig == null) { return(DotlessConfiguration.GetDefaultWeb()); } webconfig.Web = true; return(webconfig); }
public DotlessConfiguration GetConfiguration() { if (mDotConfigCache == null) { mDotConfigCache = (DotlessConfiguration)ConfigurationManager.GetSection("dotless"); if (mDotConfigCache == null) { mDotConfigCache = DotlessConfiguration.DefaultWeb; } } return(mDotConfigCache); }
public LessHandler(IFileWrapper fileWrapper) { this.fileWrapper = fileWrapper; var config = new DotlessConfiguration { CacheEnabled = false, Logger = typeof(LessLogger), Web = HttpContext.Current != null, }; var engineFactory = new EngineFactory(config); if (HttpContext.Current == null) engine = engineFactory.GetEngine(); else engine = engineFactory.GetEngine(new AspNetContainerFactory()); }
public object Create(object parent, object configContext, XmlNode section) { var configuration = new DotlessConfiguration(); //Default try { var interpreter = new XmlConfigurationInterpreter(); configuration = interpreter.Process(section); } catch (Exception) { //TODO: Log the errormessage to somewhere } return configuration; }
public DotlessConfiguration(DotlessConfiguration config) { LessSource = config.LessSource; MinifyOutput = config.MinifyOutput; CacheEnabled = config.CacheEnabled; Web = config.Web; Logger = null; LogLevel = config.LogLevel; Optimization = config.Optimization; Plugins = new List<IPluginConfigurator>(); Plugins.AddRange(config.Plugins); MapPathsToWeb = config.MapPathsToWeb; DisableUrlRewriting = config.DisableUrlRewriting; InlineCssFiles = config.InlineCssFiles; ImportAllFilesAsLess = config.ImportAllFilesAsLess; }
public object Create(object parent, object configContext, XmlNode section) { var configuration = DotlessConfiguration.GetDefault(); try { var interpreter = new XmlConfigurationInterpreter(); configuration = interpreter.Process(section); } catch (Exception) { //TODO: Log the errormessage to somewhere } return(configuration); }
public void Process(BundleContext context, BundleResponse response) { var config = new DotlessConfiguration { MinifyOutput = false, ImportAllFilesAsLess = true, CacheEnabled = false, //#if DEBUG //Logger = typeof (DiagnosticsLogger), //#endif LessSource = typeof(VirtualFileReader) }; response.Content = Less.Parse(response.Content, config); response.ContentType = "text/css"; }
public void Process(BundleContext context, BundleResponse response) { bool debugMode = !BundleTable.EnableOptimizations; var config = new DotlessConfiguration { Debug = debugMode, MinifyOutput = !debugMode, CacheEnabled = !debugMode, }; string content = dotless.Core.Less.Parse(response.Content, config); response.ContentType = "text/css"; response.Content = string.Format(CultureInfo.InvariantCulture, "/* dotLess - Debug: {0} - Date: {1:yyyy-MM-dd HH:mm:ss} */\n\n{2}", debugMode, DateTime.Now, content); }
public void CssResponseInstanceIsTransient() { var config = new DotlessConfiguration { Web = true, CacheEnabled = false }; var serviceLocator = new AspNetContainerFactory().GetContainer(config); var response1 = serviceLocator.GetInstance<IResponse>(); var response2 = serviceLocator.GetInstance<IResponse>(); Assert.That(response1, Is.Not.SameAs(response2)); var http1 = (response1 as CssResponse).Http; var http2 = (response2 as CssResponse).Http; Assert.That(http1, Is.Not.SameAs(http2)); }
/// <summary> /// /// </summary> /// <param name="LessCode"></param> /// <returns></returns> async static protected Task<string> TransformAsync(string LessCode, string FileName = "unknown.less") { return await TaskEx.RunPropagatingExceptionsAsync(() => { if (Config == null) { Config = new DotlessConfiguration() { MinifyOutput = true, }; } if (Engine == null) { Engine = new EngineFactory(Config).GetEngine(); } return Engine.TransformToCss(LessCode, FileName); }); }
public DotlessConfiguration(DotlessConfiguration config) { LessSource = config.LessSource; MinifyOutput = config.MinifyOutput; Debug = config.Debug; CacheEnabled = config.CacheEnabled; Web = config.Web; Logger = null; LogLevel = config.LogLevel; Optimization = config.Optimization; Plugins = new List <IPluginConfigurator>(); Plugins.AddRange(config.Plugins); MapPathsToWeb = config.MapPathsToWeb; DisableUrlRewriting = config.DisableUrlRewriting; InlineCssFiles = config.InlineCssFiles; ImportAllFilesAsLess = config.ImportAllFilesAsLess; HandleWebCompression = config.HandleWebCompression; DisableParameters = config.DisableParameters; }
public LessHandler(IFileWrapper fileWrapper) { this.fileWrapper = fileWrapper; var config = new DotlessConfiguration { CacheEnabled = false, Logger = typeof(LessLogger), Web = HttpContext.Current != null, }; if (HttpContext.Current == null) engine = new EngineFactory(config).GetEngine(); else { var dotLessAssembly = Assembly.GetAssembly(typeof (ContainerFactory)); var factoryType = dotLessAssembly.GetType("dotless.Core.AspNetContainerFactory"); var fac = (ContainerFactory)(factoryType.InvokeMember("", BindingFlags.CreateInstance, null, null, null)); var locator = factoryType.InvokeMember("GetContainer", BindingFlags.InvokeMethod, null, fac, new object[] {config}); engine = (ILessEngine) (dotLessAssembly.GetType("Microsoft.Practices.ServiceLocation.IServiceLocator").InvokeMember( "GetInstance", BindingFlags.InvokeMethod, null, locator, new object[] {typeof (ILessEngine)})); } }
public void IfWebAndCacheOptionsSetCacheIsHttpCache() { var config = new DotlessConfiguration { Web = true, CacheEnabled = true }; var serviceLocator = new AspNetContainerFactory().GetContainer(config); var cache = serviceLocator.GetInstance<ICache>(); Assert.That(cache, Is.TypeOf<HttpCache>()); }
public void IfWebOptionSetButCachedIsFalseEngineIsLessEngine() { var config = new DotlessConfiguration { Web = true, CacheEnabled = false }; var engine = GetEngine(config); Assert.That(engine, Is.TypeOf<LessEngine>()); }
public void IfWebCacheAndMinifyOptionsSetEngineIsCacheDecoratorThenLessEngine() { var config = new DotlessConfiguration { Web = true, CacheEnabled = true, MinifyOutput = true }; var engine = GetEngine(config); Assert.That(engine, Is.TypeOf<CacheDecorator>()); var aspEngine = (CacheDecorator)engine; Assert.That(aspEngine.Underlying, Is.TypeOf<LessEngine>()); }
public static string Parse(string less, DotlessConfiguration config) { return new EngineFactory(config).GetEngine(new AspNetContainerFactory()).TransformToCss(less, null); }
/// <summary> /// Parse the given LESS content /// <br/> /// In case that the content contains @import directives set the virtual path of the file where the content came from /// </summary> /// <param name="content"></param> /// <param name="fileVirtualPath"></param> /// <param name="config"></param> /// <returns></returns> public static string Parse(string content, string fileVirtualPath = null, DotlessConfiguration config = null) { return GetEngine(fileVirtualPath, config).TransformToCss(content, fileVirtualPath); }
public LessCompiler(DotlessConfiguration configuration) { this.configuration = configuration; }
public void Process(BundleContext context, BundleResponse response) { setBasePath(context); var config = new DotlessConfiguration(DotlessConfiguration.GetDefault()); config.LessSource = typeof(TwitterBootstrapLessMinifyBundleFileReader); response.Content = Less.Parse(response.Content, config); response.ContentType = "text/css"; }
private ILessEngine GetEngine(DotlessConfiguration config) { var container = new AspNetContainerFactory().GetContainer(config); return ((ParameterDecorator)container.GetInstance<ILessEngine>()).Underlying; }
public CompilerConfiguration(DotlessConfiguration config) : base(config) { CacheEnabled = false; Web = false; }
public DotlessConfiguration Process(XmlNode section) { var dotlessConfiguration = DotlessConfiguration.GetDefaultWeb(); dotlessConfiguration.MinifyOutput = GetBoolValue(section, "minifyCss") ?? dotlessConfiguration.MinifyOutput; dotlessConfiguration.Debug = GetBoolValue(section, "debug") ?? dotlessConfiguration.Debug; dotlessConfiguration.CacheEnabled = GetBoolValue(section, "cache") ?? dotlessConfiguration.CacheEnabled; dotlessConfiguration.HttpExpiryInMinutes = GetIntValue(section, "httpExpiryInMinutes") ?? dotlessConfiguration.HttpExpiryInMinutes; dotlessConfiguration.Optimization = GetIntValue(section, "optimization") ?? dotlessConfiguration.Optimization; dotlessConfiguration.DisableUrlRewriting = GetBoolValue(section, "disableUrlRewriting") ?? dotlessConfiguration.DisableUrlRewriting; dotlessConfiguration.InlineCssFiles = GetBoolValue(section, "inlineCssFiles") ?? dotlessConfiguration.InlineCssFiles; dotlessConfiguration.ImportAllFilesAsLess = GetBoolValue(section, "importAllFilesAsLess") ?? dotlessConfiguration.ImportAllFilesAsLess; dotlessConfiguration.MapPathsToWeb = GetBoolValue(section, "mapPathsToWeb") ?? dotlessConfiguration.MapPathsToWeb; dotlessConfiguration.HandleWebCompression = GetBoolValue(section, "handleWebCompression") ?? dotlessConfiguration.HandleWebCompression; dotlessConfiguration.DisableParameters = GetBoolValue(section, "disableParameters") ?? dotlessConfiguration.DisableParameters; dotlessConfiguration.KeepFirstSpecialComment = GetBoolValue(section, "keepFirstSpecialComment") ?? dotlessConfiguration.KeepFirstSpecialComment; dotlessConfiguration.RootPath = GetStringValue(section, "rootPath") ?? dotlessConfiguration.RootPath; dotlessConfiguration.DisableVariableRedefines = GetBoolValue(section, "disableVariableRedefines") ?? dotlessConfiguration.DisableVariableRedefines; dotlessConfiguration.DisableColorCompression = GetBoolValue(section, "disableColorCompression") ?? dotlessConfiguration.DisableColorCompression; dotlessConfiguration.StrictMath = GetBoolValue(section, "strictMath") ?? dotlessConfiguration.StrictMath; var logLevel = GetStringValue(section, "log") ?? "default"; switch (logLevel.ToLowerInvariant()) { case "info": dotlessConfiguration.LogLevel = LogLevel.Info; break; case "debug": dotlessConfiguration.LogLevel = LogLevel.Debug; break; case "warn": dotlessConfiguration.LogLevel = LogLevel.Warn; break; case "error": dotlessConfiguration.LogLevel = LogLevel.Error; break; case "default": break; } var source = GetTypeValue(section, "source"); if (source != null) { dotlessConfiguration.LessSource = source; } dotlessConfiguration.Logger = GetTypeValue(section, "logger"); dotlessConfiguration.Plugins.AddRange(GetPlugins(section)); var sessionMode = GetStringValue(section, "sessionMode"); dotlessConfiguration.SessionMode = string.IsNullOrEmpty(sessionMode) ? DotlessSessionStateMode.Disabled : (DotlessSessionStateMode)Enum.Parse(typeof(DotlessSessionStateMode), sessionMode, true); dotlessConfiguration.SessionQueryParamName = GetStringValue(section, "sessionQueryParamName") ?? DotlessConfiguration.DEFAULT_SESSION_QUERY_PARAM_NAME; if (dotlessConfiguration.SessionMode == DotlessSessionStateMode.QueryParam && string.IsNullOrEmpty(dotlessConfiguration.SessionQueryParamName)) { throw new ConfigurationErrorsException("The 'sessionQueryParamName' should be not empty when sessionMode is set to 'queryParam'", section); } return(dotlessConfiguration); }