-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replaced simpleinjector with internal DI (#4)
* replaced simpleinjector with internal di container * moved ConfigException * target net 45 directly and add netstandard 1.3 as target * fixed runtime errors with new builder
- Loading branch information
Showing
28 changed files
with
568 additions
and
124 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
src/CloudInit.ConfigDrive.Abstractions/CloudInit.ConfigDrive.Abstractions.csproj
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 was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
src/CloudInit.ConfigDrive.Abstractions/Generator/IGenerateableBuilder.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
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,6 @@ | ||
namespace Contiva.CloudInit.ConfigDrive | ||
{ | ||
public interface IBuilder | ||
{ | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ctions/Generator/IConfigDriveGenerator.cs → ...ive.Abstractions/IConfigDriveGenerator.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
28 changes: 28 additions & 0 deletions
28
src/CloudInit.ConfigDrive.Abstractions/Injection/IResolutionContext.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,28 @@ | ||
// copyright: rebus-org https://github.com/rebus-org | ||
// source: https://raw.githubusercontent.com/rebus-org/Rebus/master/Rebus/Injection/IResolutionContext.cs | ||
|
||
using System.Collections; | ||
|
||
namespace Contiva.CloudInit.ConfigDrive.Injection | ||
{ | ||
/// <summary> | ||
/// Represents the context of resolving one root service and can be used throughout the tree to fetch something to be injected | ||
/// </summary> | ||
public interface IResolutionContext | ||
{ | ||
/// <summary> | ||
/// Gets an instance of the specified <typeparamref name="TService"/>. | ||
/// </summary> | ||
TService Get<TService>(); | ||
|
||
/// <summary> | ||
/// Gets all instances resolved within this resolution context at this time. | ||
/// </summary> | ||
IEnumerable TrackedInstances { get; } | ||
|
||
/// <summary> | ||
/// Gets whether there exists a primary registration for the <typeparamref name="TService"/> type | ||
/// </summary> | ||
bool Has<TService>(bool primary = true); | ||
} | ||
} |
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,47 @@ | ||
using Contiva.CloudInit.ConfigDrive.Generator; | ||
using Contiva.CloudInit.ConfigDrive.Injection; | ||
|
||
namespace Contiva.CloudInit.ConfigDrive | ||
{ | ||
public class BaseBuilder: IBuilder | ||
{ | ||
private readonly Injectionist _container; | ||
private readonly BaseBuilder _innerBuilder; | ||
|
||
protected BaseBuilder(Injectionist container) | ||
{ | ||
_container = container; | ||
} | ||
|
||
protected BaseBuilder(IBuilder innerBuilder) | ||
{ | ||
_innerBuilder = innerBuilder as BaseBuilder; | ||
} | ||
|
||
protected Injectionist Container => _container ?? _innerBuilder.Container; | ||
|
||
|
||
public virtual BaseBuilder With<T>(T instance) where T : class | ||
{ | ||
Container.Register(c=> instance); | ||
return this; | ||
} | ||
|
||
protected IConfigDriveGenerator Build() | ||
{ | ||
PrepareBuild(); | ||
|
||
if (!Container.Has<IConfigDriveGenerator>()) | ||
throw new CloudInitConfigurationException("No Config Drive Generator has been configured"); | ||
|
||
return Container.Get<IConfigDriveGenerator>().Instance; | ||
|
||
} | ||
|
||
protected virtual void PrepareBuild() | ||
{ | ||
_innerBuilder?.PrepareBuild(); | ||
} | ||
} | ||
|
||
} |
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
47 changes: 47 additions & 0 deletions
47
src/CloudInit.ConfigDrive.Core/CloudInitConfigurationException.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,47 @@ | ||
using System; | ||
#if NET45 | ||
using System.Runtime.Serialization; | ||
#elif NETSTANDARD2_0 | ||
using System.Runtime.Serialization; | ||
#endif | ||
|
||
namespace Contiva.CloudInit.ConfigDrive | ||
{ | ||
#if NET45 | ||
[Serializable] | ||
#elif NETSTANDARD2_0 | ||
[Serializable] | ||
#endif | ||
public class CloudInitConfigurationException : Exception | ||
{ | ||
public CloudInitConfigurationException() | ||
{ | ||
} | ||
|
||
public CloudInitConfigurationException(string message) : base(message) | ||
{ | ||
} | ||
|
||
public CloudInitConfigurationException(string message, Exception inner) : base(message, inner) | ||
{ | ||
} | ||
|
||
#if NET45 | ||
/// <summary> | ||
/// Constructs the exception | ||
/// </summary> | ||
public CloudInitConfigurationException(SerializationInfo info, StreamingContext context) | ||
: base(info, context) | ||
{ | ||
} | ||
#elif NETSTANDARD2_0 | ||
/// <summary> | ||
/// Constructs the exception | ||
/// </summary> | ||
public CloudInitConfigurationException(SerializationInfo info, StreamingContext context) | ||
: base(info, context) | ||
{ | ||
} | ||
#endif | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
8 changes: 7 additions & 1 deletion
8
src/CloudInit.ConfigDrive.Core/Generator/GeneratableBuilder.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
23 changes: 0 additions & 23 deletions
23
src/CloudInit.ConfigDrive.Core/Generator/GeneratorBuilder.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.