Skip to content

Commit 6425cf5

Browse files
committed
Merge branch 'feature/milestone-3.8.0' into dev
2 parents 4ed3f4a + 34ba09d commit 6425cf5

18 files changed

Lines changed: 2654 additions & 23 deletions

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
Code Patterns for .NET
1+
Welcome!
22
=============
33

4-
# Welcome! #
54
## You've found my .NET utility belt. ##
6-
## It's constantly growing. ##
7-
## Its entire goal is to make life easier. ##
5+
## It's constantly growing, and its entire goal is to make life easier for .NET developers. ##
86

97
Here are the highlights:
108

changelog.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
11
## Patterns Changelog ##
22

3-
**2/24/2013**
3+
**3.8.0**
44

5-
- Added `IMoqContainer` for issue #41
6-
- Removed test modifier from `Patterns.Testing.tt` for issue #26
7-
- Moved lots of spec framework code into `Patterns.Testing`
5+
- Renamed `Patterns.Autofac.Sources.ResolveAnythingSource` to `Patterns.Autofac.Sources.ResolveCreatableSource` (issue #43)
6+
- Moved Moq-related components from `Patterns.Testing.Autofac` to `Patterns.Testing.Autofac.Moq` (issue #58)
7+
- Added the "strategy dictionary" pattern to the `Patterns.Collections.Strategies` namespace (issue #59)
8+
- Added a short-circuit `Map<TSource,TDestination>` method to `Patterns.Mapping.IMappingServices` (issue #61)
9+
10+
**3.7.2**
11+
12+
**3.7.1**
13+
14+
**3.7.0**
15+
16+
**3.6.0-beta**
17+
18+
**3.5.1-beta**
19+
20+
**3.5.0-beta**
21+
22+
**3.4.0-beta**
23+
24+
**3.3.1-beta**

src/Patterns.Autofac/Patterns.Autofac.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
<Compile Include="Mapping\MappingModule.cs" />
101101
<Compile Include="Modules\RuntimeModule.cs" />
102102
<Compile Include="Properties\AssemblyInfo.cs" />
103-
<Compile Include="Sources\ResolveAnythingSource.cs" />
103+
<Compile Include="Sources\ResolveCreatableSource.cs" />
104104
</ItemGroup>
105105
<ItemGroup>
106106
<ProjectReference Include="..\Patterns\Patterns.csproj">

src/Patterns.Autofac/Sources/ResolveAnythingSource.cs renamed to src/Patterns.Autofac/Sources/ResolveCreatableSource.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace Patterns.Autofac.Sources
4040
/// <remarks>
4141
/// Using this class can have unwanted side effects and is intended for fringe scenarios; use with caution.
4242
/// </remarks>
43-
public class ResolveAnythingSource : IRegistrationSource
43+
public class ResolveCreatableSource : IRegistrationSource
4444
{
4545
#region Implementation of IRegistrationSource
4646

@@ -58,8 +58,7 @@ public IEnumerable<IComponentRegistration> RegistrationsFor(Service service, Fun
5858
{
5959
var ts = service as TypedService;
6060
if (ts == null || ts.ServiceType.IsAbstract || !ts.ServiceType.IsClass) yield break;
61-
IRegistrationBuilder<object, ConcreteReflectionActivatorData, SingleRegistrationStyle> rb = RegistrationBuilder.ForType(ts.ServiceType);
62-
yield return rb.CreateRegistration();
61+
yield return RegistrationBuilder.ForType(ts.ServiceType).CreateRegistration();
6362
}
6463

6564
/// <summary>

src/Patterns.Testing.Autofac/AutofacMoqContainer.cs renamed to src/Patterns.Testing.Autofac/Moq/AutofacMoqContainer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
using Patterns.Autofac;
3232
using Patterns.Testing.Moq;
3333

34-
namespace Patterns.Testing.Autofac
34+
namespace Patterns.Testing.Autofac.Moq
3535
{
3636
/// <summary>
3737
/// Provides a default implementation of the <see cref="IMoqContainer" /> interface.

src/Patterns.Testing.Autofac/IAutofacMoqContainer.cs renamed to src/Patterns.Testing.Autofac/Moq/IAutofacMoqContainer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#region FreeBSD
1+
#region FreeBSD
22

33
// Copyright (c) 2013, John Batte
44
// All rights reserved.
@@ -25,7 +25,7 @@
2525

2626
using Patterns.Testing.Moq;
2727

28-
namespace Patterns.Testing.Autofac
28+
namespace Patterns.Testing.Autofac.Moq
2929
{
3030
/// <summary>
3131
/// Augments <see cref="IMoqContainer"/> with Autofac-specific functionality.

src/Patterns.Testing.Autofac/MoqRegistrationSource.cs renamed to src/Patterns.Testing.Autofac/Moq/MoqRegistrationSource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
using Moq;
1010

11-
namespace Patterns.Testing.Autofac
11+
namespace Patterns.Testing.Autofac.Moq
1212
{
1313
/// <summary>
1414
/// Provides a registration source for Autofac using Moq's MockRepository as a service factory.

src/Patterns.Testing.Autofac/Patterns.Testing.Autofac.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@
6262
<Compile Include="..\Patterns\SolutionAssemblyInfo.cs">
6363
<Link>Properties\SolutionAssemblyInfo.cs</Link>
6464
</Compile>
65-
<Compile Include="IAutofacMoqContainer.cs" />
66-
<Compile Include="AutofacMoqContainer.cs" />
67-
<Compile Include="MoqRegistrationSource.cs" />
65+
<Compile Include="Moq\AutofacMoqContainer.cs" />
66+
<Compile Include="Moq\IAutofacMoqContainer.cs" />
67+
<Compile Include="Moq\MoqRegistrationSource.cs" />
6868
<Compile Include="Properties\AssemblyInfo.cs" />
6969
</ItemGroup>
7070
<ItemGroup>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using System.Collections.Generic;
2+
3+
namespace Patterns.Collections
4+
{
5+
/// <summary>
6+
/// Defines a default implementation of the <see cref="IDictionaryValueRetriever{TKey,TValue}" /> interface.
7+
/// </summary>
8+
/// <typeparam name="TKey">The type of the key.</typeparam>
9+
/// <typeparam name="TValue">The type of the value.</typeparam>
10+
public class DictionaryValueRetriever<TKey, TValue> : IDictionaryValueRetriever<TKey, TValue>
11+
{
12+
private readonly IDictionary<TKey, TValue> _dictionary;
13+
private readonly bool _throwKeyNotFoundExceptions;
14+
15+
/// <summary>
16+
/// Initializes a new instance of the <see cref="DictionaryValueRetriever{TKey, TValue}" /> class.
17+
/// </summary>
18+
/// <param name="dictionary">The dictionary.</param>
19+
/// <param name="throwKeyNotFoundExceptions">
20+
/// if set to <c>true</c>, throw KeyNotFoundExceptions for missing keys.
21+
/// </param>
22+
public DictionaryValueRetriever(IDictionary<TKey, TValue> dictionary, bool throwKeyNotFoundExceptions)
23+
{
24+
_dictionary = dictionary;
25+
_throwKeyNotFoundExceptions = throwKeyNotFoundExceptions;
26+
}
27+
28+
/// <summary>
29+
/// Retrieves the value at the specified key.
30+
/// </summary>
31+
/// <param name="key">The key.</param>
32+
/// <returns></returns>
33+
/// <exception cref="System.NotImplementedException"></exception>
34+
public TValue Retrieve(TKey key)
35+
{
36+
if (!_dictionary.ContainsKey(key))
37+
{
38+
if (_throwKeyNotFoundExceptions) throw new KeyNotFoundException();
39+
40+
return default(TValue);
41+
}
42+
43+
return _dictionary[key];
44+
}
45+
}
46+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace Patterns.Collections
2+
{
3+
/// <summary>
4+
/// Provides a proxy for dictionary value retrieval.
5+
/// </summary>
6+
/// <typeparam name="TKey">The type of the key.</typeparam>
7+
/// <typeparam name="TValue">The type of the value.</typeparam>
8+
public interface IDictionaryValueRetriever<in TKey, out TValue>
9+
{
10+
/// <summary>
11+
/// Retrieves the value at the specified key.
12+
/// </summary>
13+
/// <param name="key">The key.</param>
14+
/// <returns></returns>
15+
TValue Retrieve(TKey key);
16+
}
17+
}

0 commit comments

Comments
 (0)