Skip to content

Commit 3d43bc0

Browse files
committed
Issue #3 - fixed
1 parent c0c06fe commit 3d43bc0

10 files changed

Lines changed: 69 additions & 18 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#region New BSD License
2+
3+
// // Copyright (c) 2013, John Batte
4+
// // All rights reserved.
5+
// //
6+
// // Redistribution and use in source and binary forms, with or without modification, are permitted
7+
// // provided that the following conditions are met:
8+
// //
9+
// // Redistributions of source code must retain the above copyright notice, this list of conditions
10+
// // and the following disclaimer.
11+
// //
12+
// // Redistributions in binary form must reproduce the above copyright notice, this list of conditions
13+
// // and the following disclaimer in the documentation and/or other materials provided with the distribution.
14+
// //
15+
// // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
16+
// // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
17+
// // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
18+
// // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
19+
// // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20+
// // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21+
// // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
22+
// // POSSIBILITY OF SUCH DAMAGE.
23+
24+
#endregion
25+
26+
using Autofac;
27+
28+
using Patterns.Configuration;
29+
30+
namespace Patterns.Autofac.Modules
31+
{
32+
/// <summary>
33+
/// Provides packaged registration instructions for default implementations
34+
/// of public contracts defined in the Patterns.Configuration namespace.
35+
/// </summary>
36+
public class ConfigurationModule : Module
37+
{
38+
protected override void Load(ContainerBuilder builder)
39+
{
40+
builder.RegisterType<ConfigurationWrapper>().As<IConfiguration>();
41+
builder.RegisterType<ConfigurationManagerWrapper>().As<IConfigurationManager>();
42+
builder.RegisterType<ConfigurationSource>().As<IConfigurationSource>();
43+
}
44+
}
45+
}

src/Patterns.Autofac/Modules/CoreModule.cs renamed to src/Patterns.Autofac/Modules/RuntimeModule.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ namespace Patterns.Autofac.Modules
3131
{
3232
/// <summary>
3333
/// Provides packaged registration instructions for default implementations
34-
/// of public contracts defined in the Patterns library.
34+
/// of public contracts defined in the Patterns.Runtime namespace.
3535
/// </summary>
36-
public class CoreModule : Module
36+
public class RuntimeModule : Module
3737
{
3838
protected override void Load(ContainerBuilder builder)
3939
{

src/Patterns.Autofac/Patterns.Autofac.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
<HintPath>..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.Configuration.dll</HintPath>
4444
</Reference>
4545
<Reference Include="System" />
46+
<Reference Include="System.configuration" />
4647
<Reference Include="System.Core" />
4748
<Reference Include="System.Xml.Linq" />
4849
<Reference Include="System.Data.DataSetExtensions" />
@@ -54,7 +55,8 @@
5455
<Compile Include="..\Patterns\SolutionAssemblyInfo.cs">
5556
<Link>Properties\SolutionAssemblyInfo.cs</Link>
5657
</Compile>
57-
<Compile Include="Modules\CoreModule.cs" />
58+
<Compile Include="Modules\ConfigurationModule.cs" />
59+
<Compile Include="Modules\RuntimeModule.cs" />
5860
<Compile Include="Properties\AssemblyInfo.cs" />
5961
<Compile Include="Sources\ResolveAnythingSource.cs" />
6062
</ItemGroup>

src/Patterns.Autofac/Patterns.Autofac.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
<title>$id$</title>
1212
<requireLicenseAcceptance>false</requireLicenseAcceptance>
1313
<description>$description$</description>
14-
<copyright>Copyright © 2012</copyright>
14+
<copyright>Copyright © 2013</copyright>
1515
</metadata>
1616
</package>

src/Patterns.Testing/Patterns.Testing.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
<title>$id$</title>
1212
<requireLicenseAcceptance>false</requireLicenseAcceptance>
1313
<description>$description$</description>
14-
<copyright>Copyright © 2012</copyright>
14+
<copyright>Copyright © 2013</copyright>
1515
</metadata>
1616
</package>

src/Patterns/Configuration/ConfigurationSource.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using System.Collections.Specialized;
34
using System.Configuration;
45
using System.Linq;
@@ -8,11 +9,13 @@ namespace Patterns.Configuration
89
public class ConfigurationSource : IConfigurationSource
910
{
1011
private readonly IConfigurationManager _configManager;
12+
private readonly Func<System.Configuration.Configuration, IConfiguration> _configFactory;
1113

12-
public ConfigurationSource(IConfigurationManager configManager)
14+
public ConfigurationSource(IConfigurationManager configManager, Func<System.Configuration.Configuration, IConfiguration> configFactory)
1315
{
1416
_configManager = configManager;
15-
NameValueCollection appSettings = _configManager.AppSettings;
17+
_configFactory = configFactory;
18+
NameValueCollection appSettings = _configManager.AppSettings;
1619
if(appSettings != null) AppSettings = appSettings.AllKeys.ToDictionary(key => key, key => appSettings[key]);
1720
var connectionStrings = _configManager.ConnectionStrings;
1821
if(connectionStrings != null) ConnectionStrings = connectionStrings.OfType<ConnectionStringSettings>().ToDictionary(settings => settings.Name, settings => settings);
@@ -34,22 +37,22 @@ public virtual TSection GetSection<TSection>(string sectionName) where TSection
3437

3538
public virtual IConfiguration OpenExeConfiguration(string exePath)
3639
{
37-
return new ConfigurationWrapper(_configManager.OpenExeConfiguration(exePath));
40+
return _configFactory(_configManager.OpenExeConfiguration(exePath));
3841
}
3942

4043
public virtual IConfiguration OpenExeConfiguration(ConfigurationUserLevel userLevel)
4144
{
42-
return new ConfigurationWrapper(_configManager.OpenExeConfiguration(userLevel));
45+
return _configFactory(_configManager.OpenExeConfiguration(userLevel));
4346
}
4447

4548
public virtual IConfiguration OpenMachineConfiguration()
4649
{
47-
return new ConfigurationWrapper(_configManager.OpenMachineConfiguration());
50+
return _configFactory(_configManager.OpenMachineConfiguration());
4851
}
4952

5053
public virtual IConfiguration OpenMappedExeConfiguration(ExeConfigurationFileMap fileMap, ConfigurationUserLevel userLevel)
5154
{
52-
return new ConfigurationWrapper(_configManager.OpenMappedExeConfiguration(fileMap, userLevel));
55+
return _configFactory(_configManager.OpenMappedExeConfiguration(fileMap, userLevel));
5356
}
5457

5558
public virtual void RefreshSection(string sectionName)

src/Patterns/SolutionAssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
[assembly: AssemblyCulture(ProductStrings.Empty)]
4040
[assembly: ComVisible(false)]
4141
[assembly: NeutralResourcesLanguage("en-US")]
42-
[assembly: AssemblyVersion("3.3.0")]
43-
[assembly: AssemblyFileVersion("3.3.0.0")]
42+
[assembly: AssemblyVersion("3.3.1")]
43+
[assembly: AssemblyFileVersion("3.3.1.0")]
4444

45-
[assembly: AssemblyInformationalVersion("3.3.0-beta")]
45+
[assembly: AssemblyInformationalVersion("3.3.1-beta")]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<#+
22
public int MajorVersion = 3;
33
public int MinorVersion = 3;
4-
public int Revision = 0;
4+
public int Revision = 1;
55
public bool IsPreRelease = true;
66
#>

src/_specs/Steps/Autofac/ContainerSteps.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static IContainer Container
5353
[Given("I have registered the core module")]
5454
public void RegisterCoreModule()
5555
{
56-
Builder.RegisterModule(new CoreModule());
56+
Builder.RegisterModule(new RuntimeModule());
5757
}
5858

5959
[Given("I have created the container")]

src/_specs/Steps/Factories/ConfigFactory.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ public static IConfigurationSource ConfigSource
4444
[Given(@"I have a new Configuration Source using the mocked config abstraction")]
4545
public void CreateConfigSourceWithMocks()
4646
{
47-
ConfigSource = new ConfigurationSource(MockFactory.Mocks.GetMock<IConfigurationManager>().Object);
47+
ConfigSource = new ConfigurationSource(MockFactory.Mocks.GetMock<IConfigurationManager>().Object,
48+
configuration => new ConfigurationWrapper(configuration));
4849
}
4950
}
5051
}

0 commit comments

Comments
 (0)