diff --git a/SalesCatalog/CatalogHelper.cs b/SalesCatalog/CatalogHelper.cs
index de5d1327..e6b493f5 100644
--- a/SalesCatalog/CatalogHelper.cs
+++ b/SalesCatalog/CatalogHelper.cs
@@ -15,15 +15,13 @@ namespace SalesCatalog
public static CatalogProvidersConfigurationSection Config {get; set; }
- public static void Load () {
- if (Config != null)
- return ;
+ public static void LoadConfig () {
Config = ConfigurationManager.GetSection ("system.web/catalog") as CatalogProvidersConfigurationSection;
if (Config == null)
throw new ConfigurationErrorsException("The configuration bloc for the catalog provider was not found");
- foreach (CatalogProviderConfigurationElement e in Config.Providers) {
- CreateProvider (e);
- }
+ /* foreach (CatalogProviderConfigurationElement e in Config.Providers) {
+ Providers.Add(CreateProvider (e));
+ } */
}
private static CatalogProvider CreateProvider(CatalogProviderConfigurationElement celt) {
if (celt == null)
@@ -47,9 +45,15 @@ namespace SalesCatalog
cp.Initialize (celt.Name, c);
return cp;
}
-
+ ///
+ /// Gets the default provider.
+ ///
+ ///
+ /// The default provider.
public static CatalogProvider GetDefaultProvider ()
{
+ if (Config == null)
+ throw new Exception ("Configuration wanted, use a call to \"Load\".");
CatalogProviderConfigurationElement celt =
Config.Providers.GetElement (Config.DefaultProvider);
diff --git a/SalesCatalog/CatalogManager.cs b/SalesCatalog/CatalogManager.cs
index 080860b2..a6f71d2c 100644
--- a/SalesCatalog/CatalogManager.cs
+++ b/SalesCatalog/CatalogManager.cs
@@ -9,10 +9,16 @@ namespace SalesCatalog
///
public static class CatalogManager
{
+ private static CatalogProvider defaultProvider = null;
public static Catalog GetCatalog ()
{
- CatalogProvider p = CatalogHelper.GetDefaultProvider ();
- return p.GetCatalog ();
+ if (defaultProvider == null) {
+ if (CatalogHelper.Config == null)
+ CatalogHelper.LoadConfig ();
+ defaultProvider = CatalogHelper.GetDefaultProvider ();
+
+ }
+ return defaultProvider.GetCatalog ();
}
}
}
diff --git a/web/Web.csproj b/web/Web.csproj
index 206c6c08..39583068 100644
--- a/web/Web.csproj
+++ b/web/Web.csproj
@@ -72,18 +72,19 @@
-
- ..\..\..\..\..\usr\lib\mono\4.5\System.Web.Http.WebHost.dll
- False
-
-
+
..\..\..\..\..\usr\lib\mono\4.5\System.Net.Http.Formatting.dll
False
+
+ ..\..\..\..\..\usr\lib\mono\4.5\System.Web.Http.WebHost.dll
+ False
+
+