From 2c38f7ce7f7ada72eebcc53a242a6cd76025c7ed Mon Sep 17 00:00:00 2001 From: Stephan Date: Thu, 1 Nov 2012 16:46:04 -0100 Subject: [PATCH] fix BaseRest config management - would throw when missing config files --- src/Umbraco.Web.UI/config/restExtensions.Release.config | 2 +- src/Umbraco.Web.UI/config/restExtensions.config | 2 +- src/Umbraco.Web/BaseRest/RestExtensionMethodInfo.cs | 9 +++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web.UI/config/restExtensions.Release.config b/src/Umbraco.Web.UI/config/restExtensions.Release.config index b8af16a1a3..7a6afac72b 100644 --- a/src/Umbraco.Web.UI/config/restExtensions.Release.config +++ b/src/Umbraco.Web.UI/config/restExtensions.Release.config @@ -1,7 +1,7 @@  - + diff --git a/src/Umbraco.Web/BaseRest/RestExtensionMethodInfo.cs b/src/Umbraco.Web/BaseRest/RestExtensionMethodInfo.cs index ba6c299506..b1ffcaeb3b 100644 --- a/src/Umbraco.Web/BaseRest/RestExtensionMethodInfo.cs +++ b/src/Umbraco.Web/BaseRest/RestExtensionMethodInfo.cs @@ -88,6 +88,9 @@ namespace Umbraco.Web.BaseRest var config = (Configuration.BaseRestSection)System.Configuration.ConfigurationManager.GetSection("BaseRestExtensions"); + if (config == null) + return null; // does not exist + // fixme - at the moment we reload the config file each time // we have to support live edits of the config file for backward compatibility reason // so if we want to cache, we'd also need to implement a watcher on the config file... @@ -111,6 +114,9 @@ namespace Umbraco.Web.BaseRest string typeName = eNode.Attributes["type"].Value; Type type = assembly.GetType(typeName); + if (type == null) + return null; // does not exist + var method = type.GetMethod(methodName); if (method == null) @@ -135,6 +141,9 @@ namespace Umbraco.Web.BaseRest { var config = (Configuration.BaseRestSection)System.Configuration.ConfigurationManager.GetSection("BaseRestExtensions"); + if (config == null) + return null; // does not exist + Configuration.ExtensionElement configExtension = config.Items[extensionAlias]; if (configExtension == null) return null; // does not exist