Search code examples
asp.netweb-configdotless

What does DotLess' "web" attribute do exactly?


The dotless documentation is quite limited. I can't find much information at all about the configsection options - especially what the "web" attribute does.

Can anyone enlighten me?


Solution

  • The code is normally pretty good documentation for open source projects ;)

    Grab a copy of the code and look in dotless.Core > configuration > DotlessConfiguration.cs you will see some handy comments about all the config elements - this is the Web one

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

    Admittedly it doesn't tell you a great deal but find the references to that property and you come across only one place in the code where it is used -

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

    Which starts to give you a better clue as to what it does which is this

        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>();
        }
    

    So it sets up in memory caching, logging to the console etc (i.e services it uses if not in a web context)