2012-06-21 33 views

回答

18

的代碼通常是相當不錯的文檔開源項目;)

搶代碼的副本,並期待在dotless.Core>配置> DotlessConfiguration.cs你會看到所有的配置元素一些方便評論 - 這是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上下文)

+3

感謝您的回答凱文。你是對的 - 我應該看看源頭。 ) – cjacques

+1

當您使用Nuget安裝dotless時,它會將此行添加到您的web.config文件中:''。爲什麼會默認'web =「false」?似乎違反直覺。 – d512

相關問題