forked from samus/mongodb-csharp
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote branch 'craig/master' into 090beta2
- Loading branch information
Showing
9 changed files
with
180 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
source/MongoDB/Configuration/Builders/IdOverridesBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using MongoDB.Configuration.Mapping.Auto; | ||
using MongoDB.Configuration.IdGenerators; | ||
|
||
namespace MongoDB.Configuration.Builders | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public class IdOverridesBuilder | ||
{ | ||
private readonly IdOverrides _overrides; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="MemberOverridesBuilder"/> class. | ||
/// </summary> | ||
/// <param name="overrides">The overrides.</param> | ||
internal IdOverridesBuilder(IdOverrides overrides) | ||
{ | ||
if (overrides == null) | ||
throw new ArgumentNullException("overrides"); | ||
|
||
_overrides = overrides; | ||
} | ||
|
||
public IdOverridesBuilder GeneratedBy<T>() where T : IIdGenerator, new() | ||
{ | ||
return GeneratedBy(new T()); | ||
} | ||
|
||
public IdOverridesBuilder GeneratedBy(IIdGenerator generator) | ||
{ | ||
_overrides.Generator = generator; | ||
return this; | ||
} | ||
|
||
public IdOverridesBuilder UnsavedValue(object unsavedValue) | ||
{ | ||
_overrides.UnsavedValue = unsavedValue; | ||
return this; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Reflection; | ||
using MongoDB.Configuration.IdGenerators; | ||
|
||
namespace MongoDB.Configuration.Mapping.Auto | ||
{ | ||
public class IdOverrides | ||
{ | ||
/// <summary> | ||
/// Gets or sets the member. | ||
/// </summary> | ||
/// <value>The member.</value> | ||
public MemberInfo Member { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the generator. | ||
/// </summary> | ||
/// <value>The generator.</value> | ||
public IIdGenerator Generator { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the unsaved value. | ||
/// </summary> | ||
/// <value>The unsaved value.</value> | ||
public object UnsavedValue { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters