Skip to content

Commit

Permalink
Fixing issue with the config processor and enum types, fixed issue wi…
Browse files Browse the repository at this point in the history
…th missing web.confg files in the services project.
  • Loading branch information
ucswift committed Mar 2, 2019
1 parent f8b74f5 commit e0a3ef1
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 17 deletions.
25 changes: 20 additions & 5 deletions Core/Resgrid.Config/ConfigProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,37 @@ public static bool LoadAndProcessConfig(string path = null)
FieldInfo prop = configObj.GetField(parts[1]);
if (null != prop)
{
Type t = Nullable.GetUnderlyingType(prop.FieldType) ?? prop.FieldType;
object safeValue = Convert.ChangeType(configValue.Value, t);
prop.SetValue(configObj, safeValue);
if (prop.FieldType.BaseType == typeof(Enum))
{
Type t = Nullable.GetUnderlyingType(prop.FieldType) ?? prop.FieldType;

String name = Enum.GetName(t, int.Parse(configValue.Value));
Object enumValue = Enum.Parse(t, name, false);

object safeValue = Convert.ChangeType(enumValue, t);
prop.SetValue(configObj, safeValue);
}
else
{
Type t = Nullable.GetUnderlyingType(prop.FieldType) ?? prop.FieldType;
object safeValue = Convert.ChangeType(configValue.Value, t);
prop.SetValue(configObj, safeValue);
}
}
}
}
}
}

return true;
}
}
catch
catch (Exception ex)
{
return false;
}

return true;
return false;
}
}
}
41 changes: 41 additions & 0 deletions Web/Resgrid.Services/Areas/HelpPage/Views/Web.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0"?>

<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>

<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
</system.web.webPages.razor>

<appSettings>
<add key="webpages:Enabled" value="false" />
</appSettings>

<system.web>
<compilation debug="true">
<assemblies>
<add assembly="System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</assemblies>
</compilation>
</system.web>

<system.webServer>
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
</configuration>
11 changes: 0 additions & 11 deletions Web/Resgrid.Services/Resgrid.Web.Services.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -632,12 +632,6 @@
<Content Include="Web.config">
<SubType>Designer</SubType>
</Content>
<Content Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</Content>
<Content Include="Web.Release.config">
<DependentUpon>Web.config</DependentUpon>
</Content>
<Content Include="Views\Web.config" />
<Content Include="Views\Shared\Error.cshtml" />
</ItemGroup>
Expand Down Expand Up @@ -711,11 +705,6 @@
<Name>Resgrid.Repositories.DataRepository</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="Web.Azure.config">
<DependentUpon>Web.config</DependentUpon>
</None>
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
Expand Down
2 changes: 1 addition & 1 deletion Web/Resgrid.Services/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void Configuration(IAppBuilder app)
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);

if (Config.ServiceBusConfig.SignalRServiceBusConnectionString != "NOTSET")
if (!String.IsNullOrWhiteSpace(Config.ServiceBusConfig.SignalRServiceBusConnectionString))
GlobalHost.DependencyResolver.UseServiceBus(Config.ServiceBusConfig.SignalRServiceBusConnectionString, Config.ServiceBusConfig.SignalRTopicName);

// Branch the pipeline here for requests that start with "/signalr"
Expand Down
59 changes: 59 additions & 0 deletions Web/Resgrid.Services/Views/Web.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0"?>

<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>

<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization"/>
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
</system.web.webPages.razor>

<appSettings>
<add key="webpages:Enabled" value="false" />
</appSettings>

<system.web>
<httpHandlers>
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>

<!--
Enabling request validation in view pages would cause validation to occur
after the input has already been processed by the controller. By default
MVC performs request validation before a controller processes the input.
To change this behavior apply the ValidateInputAttribute to a
controller or action.
-->
<pages
validateRequest="false"
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<controls>
<add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
</system.web>

<system.webServer>
<validation validateIntegratedModeConfiguration="false" />

<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
</configuration>
1 change: 1 addition & 0 deletions Web/Resgrid.Services/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
</configSections>
<connectionStrings configSource="Configs\connectionStrings.config" />
<appSettings file="Configs\appSettings.config">
<add key="ConfigPath" value="C:\\Resgrid\\Config\\ResgridConfig.json" />
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
Expand Down

0 comments on commit e0a3ef1

Please sign in to comment.