本文整理汇总了C#中DotlessConfiguration类的典型用法代码示例。如果您正苦于以下问题:C# DotlessConfiguration类的具体用法?C# DotlessConfiguration怎么用?C# DotlessConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DotlessConfiguration类属于命名空间,在下文中一共展示了DotlessConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BaseSetup
public void BaseSetup()
{
HttpContext = new Mock<HttpContextBase>();
HttpRequest = new Mock<HttpRequestBase>();
HttpResponse = new Mock<HttpResponseBase>();
HttpSession = new Mock<HttpSessionStateBase>();
HttpServer = new Mock<HttpServerUtilityBase>();
HttpCache = new Mock<HttpCachePolicyBase>();
Http = new Mock<IHttp>();
Clock = new Mock<IClock>();
ConfigManager = new Mock<IConfigurationManager>();
QueryString = new NameValueCollection();
Form = new NameValueCollection();
Headers = new NameValueCollection();
Config = DotlessConfiguration.GetDefaultWeb();
Http.SetupGet(h => h.Context).Returns(HttpContext.Object);
ConfigManager.Setup(c => c.GetSection<DotlessConfiguration>(It.IsRegex("^dotless$"))).Returns(Config);
DotlessConfiguration.ConfigurationManager = ConfigManager.Object;
Now = DateTime.Now;
Clock.Setup(c => c.GetUtcNow()).Returns(Now);
HttpContext.SetupGet(c => c.Request).Returns(HttpRequest.Object);
HttpContext.SetupGet(c => c.Response).Returns(HttpResponse.Object);
HttpContext.SetupGet(c => c.Server).Returns(HttpServer.Object);
HttpContext.SetupGet(c => c.Session).Returns(HttpSession.Object);
HttpResponse.SetupGet(r => r.Cache).Returns(HttpCache.Object);
HttpResponse.SetupGet(r => r.Filter).Returns(new MemoryStream(new byte[1000], true));
HttpRequest.SetupGet(r => r.QueryString).Returns(QueryString);
HttpRequest.SetupGet(r => r.Form).Returns(Form);
HttpRequest.SetupGet(r => r.Headers).Returns(Headers);
}
示例2: RegisterWebServices
private void RegisterWebServices(FluentRegistration pandora, DotlessConfiguration configuration)
{
pandora.Service<IHttp>().Implementor<Http>().Lifestyle.Transient();
pandora.Service<HandlerImpl>().Implementor<HandlerImpl>().Lifestyle.Transient();
if (!configuration.DisableParameters)
{
pandora.Service<IParameterSource>().Implementor<QueryStringParameterSource>().Lifestyle.Transient();
}
var responseService = configuration.CacheEnabled ?
pandora.Service<IResponse>().Implementor<CachedCssResponse>() :
pandora.Service<IResponse>().Implementor<CssResponse>();
pandora.Service<IClock>().Implementor<Clock>();
responseService.Parameters("isCompressionHandledByResponse").Set("default-is-compression-handled-by-response").Lifestyle.Transient();
pandora.Service<bool>("default-is-compression-handled-by-response").Instance(configuration.HandleWebCompression);
if (configuration.CacheEnabled)
{
responseService.Parameters("httpExpiryInMinutes").Set("http-expiry-in-minutes").Lifestyle.Transient();
pandora.Service<int>("http-expiry-in-minutes").Instance(configuration.HttpExpiryInMinutes);
}
pandora.Service<ICache>().Implementor<HttpCache>().Lifestyle.Transient();
pandora.Service<ILogger>().Implementor<AspResponseLogger>().Parameters("level").Set("error-level").Lifestyle.Transient();
if (configuration.MapPathsToWeb)
pandora.Service<IPathResolver>().Implementor<AspServerPathResolver>().Lifestyle.Transient();
else
pandora.Service<IPathResolver>().Implementor<AspRelativePathResolver>().Lifestyle.Transient();
}
示例3: RegisterCoreServices
private void RegisterCoreServices(FluentRegistration pandora, DotlessConfiguration configuration)
{
pandora.Service<LogLevel>("error-level")
.Instance(configuration.LogLevel);
pandora.Service<int>("default-optimization")
.Instance(configuration.Optimization);
pandora.Service<bool>("minify-output")
.Instance(configuration.MinifyOutput);
pandora.Service<IStylizer>()
.Implementor<PlainStylizer>();
pandora.Service<Parser.Parser>()
.Implementor<Parser.Parser>()
.Parameters("optimization").Set("default-optimization")
.Lifestyle.Transient();
pandora.Service<ILessEngine>()
.Implementor<ParameterDecorator>().Lifestyle.Transient();
if (configuration.CacheEnabled)
pandora.Service<ILessEngine>()
.Implementor<CacheDecorator>().Lifestyle.Transient();
pandora.Service<ILessEngine>()
.Implementor<LessEngine>()
.Parameters("compress").Set("minify-output")
.Lifestyle.Transient();
pandora.Service<IFileReader>()
.Implementor(configuration.LessSource);
}
示例4: RegisterCoreServices
protected virtual void RegisterCoreServices(FluentRegistration pandora, DotlessConfiguration configuration)
{
pandora.Service<LogLevel>("error-level").Instance(configuration.LogLevel);
pandora.Service<IStylizer>().Implementor<PlainStylizer>();
var importer = pandora.Service<IImporter>().Implementor<Importer>();
importer.Parameters("inlineCssFiles").Set("default-inline-css-files").Lifestyle.Transient();
importer.Parameters("disableUrlRewriting").Set("default-disable-url-rewriting").Lifestyle.Transient();
importer.Parameters("importAllFilesAsLess").Set("default-import-all-files-as-less").Lifestyle.Transient();
pandora.Service<bool>("default-disable-url-rewriting").Instance(configuration.DisableUrlRewriting);
pandora.Service<bool>("default-inline-css-files").Instance(configuration.InlineCssFiles);
pandora.Service<bool>("default-import-all-files-as-less").Instance(configuration.ImportAllFilesAsLess);
pandora.Service<Parser.Parser>().Implementor<Parser.Parser>().Parameters("optimization").Set("default-optimization").Lifestyle.Transient();
pandora.Service<int>("default-optimization").Instance(configuration.Optimization);
pandora.Service<ILessEngine>().Implementor<ParameterDecorator>().Lifestyle.Transient();
if (configuration.CacheEnabled)
pandora.Service<ILessEngine>().Implementor<CacheDecorator>().Lifestyle.Transient();
pandora.Service<ILessEngine>().Implementor<LessEngine>().Parameters("compress").Set("minify-output").Lifestyle.Transient();
pandora.Service<bool>("minify-output").Instance(configuration.MinifyOutput);
pandora.Service<ILessEngine>().Implementor<LessEngine>().Parameters("plugins").Set("default-plugins").Lifestyle.Transient();
pandora.Service<IEnumerable<IPluginConfigurator>>("default-plugins").Instance(configuration.Plugins);
pandora.Service<IFileReader>().Implementor(configuration.LessSource);
}
示例5: CreateContainer
/// <summary>
/// Used to create the Container for the HttpHandler. Not used by Console Compiler and T4CSS
/// </summary>
/// <param name="configuration">Configuration for the HttpHandler</param>
/// <returns></returns>
private PandoraContainer CreateContainer(DotlessConfiguration configuration)
{
var container = new PandoraContainer();
container.Register(p =>
{
p.Service<ILessSource>()
.Implementor(configuration.LessSource);
p.Service<ICache>()
.Implementor<CssCache>();
p.Service<IRequest>()
.Implementor<Request>();
if (!configuration.CacheEnabled)
{
p.Service<IResponse>()
.Implementor<CssResponse>();
}
else
{
p.Service<IResponse>()
.Implementor<CachedCssResponse>();
p.Service<ILessEngine>()
.Implementor<AspCacheDecorator>();
}
});
return RegisterCoreServices(container, configuration);
}
示例6: RegisterServices
private void RegisterServices(FluentRegistration pandora, DotlessConfiguration configuration)
{
OverrideServices(pandora, configuration);
RegisterLocalServices(pandora);
RegisterCoreServices(pandora, configuration);
}
示例7: GetContainer
public IServiceLocator GetContainer(DotlessConfiguration configuration)
{
Container = new PandoraContainer();
Container.Register(pandora => RegisterServices(pandora, configuration));
return new CommonServiceLocatorAdapter(Container);
}
示例8: RegisterServices
protected override void RegisterServices(FluentRegistration pandora, DotlessConfiguration configuration)
{
base.RegisterServices(pandora, configuration);
RegisterParameterSource(pandora, configuration);
RegisterWebServices(pandora, configuration);
}
示例9: Parse
public static string Parse(string less, DotlessConfiguration config)
{
if (config.Web)
{
throw new Exception("Please use dotless.Core.LessWeb.Parse for web applications. This makes sure all web features are available.");
}
return new EngineFactory(config).GetEngine().TransformToCss(less, null);
}
示例10: IfMinifyOptionSetEngineIsLessEngine
public void IfMinifyOptionSetEngineIsLessEngine()
{
var config = new DotlessConfiguration { MinifyOutput = true, CacheEnabled = false };
var engine = GetEngine(config);
Assert.That(engine, Is.TypeOf<LessEngine>());
}
示例11: RegisterServices
protected virtual void RegisterServices(FluentRegistration pandora, DotlessConfiguration configuration)
{
OverrideServices(pandora, configuration);
if (!configuration.Web)
RegisterLocalServices(pandora);
RegisterCoreServices(pandora, configuration);
}
示例12: IfCacheOptionSetCacheIsInMemoryCache
public void IfCacheOptionSetCacheIsInMemoryCache()
{
var config = new DotlessConfiguration { Web = false, CacheEnabled = true };
var serviceLocator = new ContainerFactory().GetContainer(config);
var cache = serviceLocator.GetInstance<ICache>();
Assert.That(cache, Is.TypeOf<InMemoryCache>());
}
示例13: CompilerConfiguration
public CompilerConfiguration(DotlessConfiguration config)
{
LessSource = config.LessSource;
LogLevel = config.LogLevel;
MinifyOutput = config.MinifyOutput;
Optimization = config.Optimization;
CacheEnabled = false;
Web = false;
}
示例14: CanPassCustomLogger
public void CanPassCustomLogger()
{
var config = new DotlessConfiguration { Logger = typeof(DummyLogger) };
var serviceLocator = new ContainerFactory().GetContainer(config);
var logger = serviceLocator.GetInstance<ILogger>();
Assert.That(logger, Is.TypeOf<DummyLogger>());
}
示例15: CanOverrideOptimization
public void CanOverrideOptimization()
{
var config = new DotlessConfiguration { Optimization = 7 };
var serviceLocator = new ContainerFactory().GetContainer(config);
var parser = serviceLocator.GetInstance<Parser>();
Assert.That(parser.Tokenizer.Optimization, Is.EqualTo(7));
}