Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The dotLess parser traps Exceptions and outputs them to a Logger. The snippet from dotLess's source that performs this is <code>LessEngine.TransformToCss</code>:</p> <pre><code>public string TransformToCss(string source, string fileName) { try { Ruleset ruleset = this.Parser.Parse(source, fileName); Env env = new Env(); env.Compress = this.Compress; Env env2 = env; return ruleset.ToCSS(env2); } catch (ParserException exception) { this.Logger.Error(exception.Message); } return ""; } </code></pre> <p><code>Less.Parse</code> has an overload that takes a <code>DotlessConfiguration</code> object, which provides several properties that you can use:</p> <pre><code>public class DotlessConfiguration { // Properties public bool CacheEnabled { get; set; } public Type LessSource { get; set; } public Type Logger { get; set; } public LogLevel LogLevel { get; set; } public bool MinifyOutput { get; set; } public int Optimization { get; set; } public bool Web { get; set; } } </code></pre> <p>You will notice that the <code>Logger</code> property is of type <code>Type</code>. Whatever type you supply must implement <code>dotless.Core.Loggers.ILogger</code>:</p> <pre><code>public interface ILogger { // Methods void Debug(string message); void Error(string message); void Info(string message); void Log(LogLevel level, string message); void Warn(string message); } </code></pre> <p>As we saw in the first snippet, the <code>Error</code> method on the logger will get called when an error is encountered during parsing.</p> <p>Now, the one sticky point of all this is how exactly an instance of the type that implements <code>ILogger</code> gets instantiated. Internally, dotLess uses an IoC container that is baked into the DLL. Following the method calls, it appears that it will eventually call <code>Activator.CreateInstance</code> to instantiate your ILogger.</p> <p>I hope this is at least somewhat helpful.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload