Last active
April 25, 2020 09:51
-
-
Save PaulStovell/c2274018a1262506c120752e43db319c to your computer and use it in GitHub Desktop.
Nevermore marker interfaces & shims
This file contains hidden or 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
namespace Nevermore.Contracts | |
{ | |
public interface IDocument : IId, INamed | |
{ | |
} | |
} |
This file contains hidden or 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
namespace Nevermore.Contracts | |
{ | |
public interface IId | |
{ | |
string Id { get; } | |
} | |
} |
This file contains hidden or 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
namespace Nevermore | |
{ | |
public interface IInitializeRelationalStore | |
{ | |
void Initialize(IRelationalStore store); | |
} | |
} |
This file contains hidden or 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
namespace Nevermore.Contracts | |
{ | |
public interface INamed | |
{ | |
string Name { get; } | |
} | |
} |
This file contains hidden or 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
using System; | |
using System.Collections.Generic; | |
namespace Nevermore.Contracts | |
{ | |
/// <summary> | |
/// A case-insensitive collection of unique strings used for holding document ID's. | |
/// </summary> | |
public class ReferenceCollection : HashSet<string>, IReadOnlyCollection<string> | |
{ | |
public ReferenceCollection() | |
: base(StringComparer.OrdinalIgnoreCase) | |
{ | |
} | |
public ReferenceCollection(string singleValue) | |
: this(new[] { singleValue }) | |
{ | |
} | |
public ReferenceCollection(IEnumerable<string> values) | |
: base(values ?? new string[0], StringComparer.OrdinalIgnoreCase) | |
{ | |
} | |
public void ReplaceAll(IEnumerable<string> newItems) | |
{ | |
Clear(); | |
if (newItems == null) return; | |
foreach (var item in newItems) | |
{ | |
Add(item); | |
} | |
} | |
public ReferenceCollection Clone() | |
{ | |
return new ReferenceCollection(this); | |
} | |
public override string ToString() | |
{ | |
return string.Join(", ", this); | |
} | |
public static ReferenceCollection One(string item) | |
{ | |
return new ReferenceCollection { item }; | |
} | |
} | |
} |
This file contains hidden or 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
namespace Nevermore | |
{ | |
public class StoreInitializer : IStoreInitializer | |
{ | |
readonly IRelationalStore store; | |
readonly IInitializeRelationalStore[] initializers; | |
public StoreInitializer(IRelationalStore store, IInitializeRelationalStore[] initializers) | |
{ | |
this.store = store; | |
this.initializers = initializers; | |
} | |
public void Initialize() | |
{ | |
foreach (var initializer in initializers) | |
{ | |
initializer.Initialize(store); | |
} | |
} | |
public void Stop() | |
{ | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment