【问题标题】:What does DotLess' "web" attribute do exactly?DotLess 的“web”属性到底是做什么的?
【发布时间】:2012-06-23 14:45:25
【问题描述】:

dotless documentation 非常有限。我根本找不到关于 configsection 选项的太多信息——尤其是“web”属性的作用。

谁能赐教?

【问题讨论】:

    标签: asp.net web-config dotless


    【解决方案1】:

    代码通常是开源项目的很好的文档;)

    获取代码副本并查看 dotless.Core > configuration > DotlessConfiguration.cs,您将看到一些关于所有配置元素的便捷 cmets - 这是 Web 的

    /// <summary>
    ///  Whether this is used in a web context or not
    /// </summary>
    public bool Web { get; set; }
    

    诚然,它并没有告诉你很多信息,但找到对该属性的引用,你只会在代码中看到一个使用它的地方 -

    if (!configuration.Web)
        RegisterLocalServices(pandora);  
    

    这开始给你一个更好的线索来了解它是做什么的

        protected virtual void RegisterLocalServices(FluentRegistration pandora)
        {
            pandora.Service<ICache>().Implementor<InMemoryCache>();
            pandora.Service<IParameterSource>().Implementor<ConsoleArgumentParameterSource>();
            pandora.Service<ILogger>().Implementor<ConsoleLogger>().Parameters("level").Set("error-level");
            pandora.Service<IPathResolver>().Implementor<RelativePathResolver>();
        }
    

    所以它设置了内存缓存、记录到控制台等(即它使用的服务,如果不是在 Web 上下文中)

    【讨论】:

    • 感谢您的回答凯文。你是对的 - 我应该看看源代码。我仍然认为他们的文档可能会更好;)
    • 当您使用 Nuget 安装 dotless 时,它会将这一行添加到您的 web.config 文件中:&lt;dotless minifyCss="false" cache="true" web="false" strictMath="false" /&gt;。为什么默认web="false"?似乎违反直觉。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-08-06
    • 2013-09-02
    • 2014-01-02
    • 2013-10-10
    • 2017-05-08
    • 2022-01-20
    • 2012-10-17
    相关资源
    最近更新 更多