-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4354d4a
commit 12b92e0
Showing
184 changed files
with
5,817 additions
and
6,000 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
namespace Cupboard | ||
namespace Cupboard; | ||
|
||
public abstract class Catalog | ||
{ | ||
public abstract class Catalog | ||
public virtual bool CanRun(FactCollection facts) | ||
{ | ||
public virtual bool CanRun(FactCollection facts) | ||
{ | ||
return true; | ||
} | ||
|
||
public abstract void Execute(CatalogContext context); | ||
return true; | ||
} | ||
|
||
public abstract void Execute(CatalogContext context); | ||
} |
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 |
---|---|---|
@@ -1,29 +1,28 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Cupboard | ||
namespace Cupboard; | ||
|
||
public sealed class CatalogContext | ||
{ | ||
public sealed class CatalogContext | ||
{ | ||
private readonly HashSet<Type> _manifests; | ||
private readonly HashSet<Type> _manifests; | ||
|
||
public FactCollection Facts { get; } | ||
public FactCollection Facts { get; } | ||
|
||
public CatalogContext(FactCollection facts) | ||
{ | ||
Facts = facts ?? throw new ArgumentNullException(nameof(facts)); | ||
_manifests = new HashSet<Type>(); | ||
} | ||
public CatalogContext(FactCollection facts) | ||
{ | ||
Facts = facts ?? throw new ArgumentNullException(nameof(facts)); | ||
_manifests = new HashSet<Type>(); | ||
} | ||
|
||
public void UseManifest<TManifest>() | ||
where TManifest : Manifest | ||
{ | ||
_manifests.Add(typeof(TManifest)); | ||
} | ||
public void UseManifest<TManifest>() | ||
where TManifest : Manifest | ||
{ | ||
_manifests.Add(typeof(TManifest)); | ||
} | ||
|
||
public IEnumerable<Type> GetManifests() | ||
{ | ||
return _manifests; | ||
} | ||
public IEnumerable<Type> GetManifests() | ||
{ | ||
return _manifests; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,8 +1,7 @@ | ||
namespace Cupboard | ||
namespace Cupboard; | ||
|
||
public enum ErrorOptions | ||
{ | ||
public enum ErrorOptions | ||
{ | ||
IgnoreErrors = 0, | ||
Abort = 1, | ||
} | ||
IgnoreErrors = 0, | ||
Abort = 1, | ||
} |
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 |
---|---|---|
@@ -1,20 +1,19 @@ | ||
using Spectre.IO; | ||
|
||
namespace Cupboard | ||
namespace Cupboard; | ||
|
||
public static class FileSystemExtensions | ||
{ | ||
public static class FileSystemExtensions | ||
public static bool CreateSymbolicLinkSafe(this IFileProvider fileProvider, FilePath source, FilePath destination) | ||
{ | ||
public static bool CreateSymbolicLinkSafe(this IFileProvider fileProvider, FilePath source, FilePath destination) | ||
try | ||
{ | ||
fileProvider.CreateSymbolicLink(source, destination); | ||
return true; | ||
} | ||
catch | ||
{ | ||
try | ||
{ | ||
fileProvider.CreateSymbolicLink(source, destination); | ||
return true; | ||
} | ||
catch | ||
{ | ||
return false; | ||
} | ||
return false; | ||
} | ||
} | ||
} |
99 changes: 49 additions & 50 deletions
99
src/Cupboard.Core/Extensions/ICupboardLoggerExtensions.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 |
---|---|---|
@@ -1,65 +1,64 @@ | ||
namespace Cupboard | ||
namespace Cupboard; | ||
|
||
public static class ICupboardLoggerExtensions | ||
{ | ||
public static class ICupboardLoggerExtensions | ||
public static void Fatal(this ICupboardLogger logger, string markup) | ||
{ | ||
public static void Fatal(this ICupboardLogger logger, string markup) | ||
{ | ||
logger?.Log(Verbosity.Quiet, LogLevel.Fatal, markup); | ||
} | ||
logger?.Log(Verbosity.Quiet, LogLevel.Fatal, markup); | ||
} | ||
|
||
public static void Error(this ICupboardLogger logger, string markup) | ||
{ | ||
logger?.Log(Verbosity.Quiet, LogLevel.Error, markup); | ||
} | ||
public static void Error(this ICupboardLogger logger, string markup) | ||
{ | ||
logger?.Log(Verbosity.Quiet, LogLevel.Error, markup); | ||
} | ||
|
||
public static void Warning(this ICupboardLogger logger, string markup) | ||
{ | ||
logger?.Log(Verbosity.Minimal, LogLevel.Warning, markup); | ||
} | ||
public static void Warning(this ICupboardLogger logger, string markup) | ||
{ | ||
logger?.Log(Verbosity.Minimal, LogLevel.Warning, markup); | ||
} | ||
|
||
public static void Information(this ICupboardLogger logger, string markup) | ||
{ | ||
logger?.Log(Verbosity.Normal, LogLevel.Information, markup); | ||
} | ||
public static void Information(this ICupboardLogger logger, string markup) | ||
{ | ||
logger?.Log(Verbosity.Normal, LogLevel.Information, markup); | ||
} | ||
|
||
public static void Verbose(this ICupboardLogger logger, string markup) | ||
{ | ||
logger?.Log(Verbosity.Verbose, LogLevel.Verbose, markup); | ||
} | ||
public static void Verbose(this ICupboardLogger logger, string markup) | ||
{ | ||
logger?.Log(Verbosity.Verbose, LogLevel.Verbose, markup); | ||
} | ||
|
||
public static void Debug(this ICupboardLogger logger, string markup) | ||
{ | ||
logger?.Log(Verbosity.Diagnostic, LogLevel.Debug, markup); | ||
} | ||
public static void Debug(this ICupboardLogger logger, string markup) | ||
{ | ||
logger?.Log(Verbosity.Diagnostic, LogLevel.Debug, markup); | ||
} | ||
|
||
public static void Fatal(this ICupboardLogger logger, string title, string markup) | ||
{ | ||
logger?.Log(Verbosity.Quiet, LogLevel.Fatal, title, markup); | ||
} | ||
public static void Fatal(this ICupboardLogger logger, string title, string markup) | ||
{ | ||
logger?.Log(Verbosity.Quiet, LogLevel.Fatal, title, markup); | ||
} | ||
|
||
public static void Error(this ICupboardLogger logger, string title, string markup) | ||
{ | ||
logger?.Log(Verbosity.Quiet, LogLevel.Error, title, markup); | ||
} | ||
public static void Error(this ICupboardLogger logger, string title, string markup) | ||
{ | ||
logger?.Log(Verbosity.Quiet, LogLevel.Error, title, markup); | ||
} | ||
|
||
public static void Warning(this ICupboardLogger logger, string title, string markup) | ||
{ | ||
logger?.Log(Verbosity.Minimal, LogLevel.Warning, title, markup); | ||
} | ||
public static void Warning(this ICupboardLogger logger, string title, string markup) | ||
{ | ||
logger?.Log(Verbosity.Minimal, LogLevel.Warning, title, markup); | ||
} | ||
|
||
public static void Information(this ICupboardLogger logger, string title, string markup) | ||
{ | ||
logger?.Log(Verbosity.Normal, LogLevel.Information, title, markup); | ||
} | ||
public static void Information(this ICupboardLogger logger, string title, string markup) | ||
{ | ||
logger?.Log(Verbosity.Normal, LogLevel.Information, title, markup); | ||
} | ||
|
||
public static void Verbose(this ICupboardLogger logger, string title, string markup) | ||
{ | ||
logger?.Log(Verbosity.Verbose, LogLevel.Verbose, title, markup); | ||
} | ||
public static void Verbose(this ICupboardLogger logger, string title, string markup) | ||
{ | ||
logger?.Log(Verbosity.Verbose, LogLevel.Verbose, title, markup); | ||
} | ||
|
||
public static void Debug(this ICupboardLogger logger, string title, string markup) | ||
{ | ||
logger?.Log(Verbosity.Diagnostic, LogLevel.Debug, title, markup); | ||
} | ||
public static void Debug(this ICupboardLogger logger, string title, string markup) | ||
{ | ||
logger?.Log(Verbosity.Diagnostic, LogLevel.Debug, title, markup); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,14 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Cupboard | ||
namespace Cupboard; | ||
|
||
public static class IEnumerableExtensions | ||
{ | ||
public static class IEnumerableExtensions | ||
public static IReadOnlyList<T> ToReadOnlyList<T>(this IEnumerable<T> source) | ||
{ | ||
public static IReadOnlyList<T> ToReadOnlyList<T>(this IEnumerable<T> source) | ||
{ | ||
return source as IReadOnlyList<T> | ||
?? new List<T>(source ?? Array.Empty<T>()); | ||
} | ||
return source as IReadOnlyList<T> | ||
?? new List<T>(source ?? Array.Empty<T>()); | ||
} | ||
} |
45 changes: 22 additions & 23 deletions
45
src/Cupboard.Core/Extensions/IWindowsRegistryExtensions.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 |
---|---|---|
@@ -1,33 +1,32 @@ | ||
using System; | ||
|
||
namespace Cupboard | ||
namespace Cupboard; | ||
|
||
public static class IWindowsRegistryExtensions | ||
{ | ||
public static class IWindowsRegistryExtensions | ||
public static IWindowsRegistryKey? GetKey(this IWindowsRegistry registry, RegistryPath path, bool writable) | ||
{ | ||
public static IWindowsRegistryKey? GetKey(this IWindowsRegistry registry, RegistryPath path, bool writable) | ||
if (registry is null) | ||
{ | ||
if (registry is null) | ||
{ | ||
throw new ArgumentNullException(nameof(registry)); | ||
} | ||
throw new ArgumentNullException(nameof(registry)); | ||
} | ||
|
||
if (path is null) | ||
{ | ||
throw new ArgumentNullException(nameof(path)); | ||
} | ||
if (path is null) | ||
{ | ||
throw new ArgumentNullException(nameof(path)); | ||
} | ||
|
||
var root = path.Hive switch | ||
{ | ||
RegistryHive.ClassesRoot => registry.ClassesRoot, | ||
RegistryHive.CurrentUser => registry.CurrentUser, | ||
RegistryHive.LocalMachine => registry.LocalMachine, | ||
RegistryHive.Users => registry.Users, | ||
RegistryHive.CurrentConfig => registry.CurrentConfig, | ||
RegistryHive.PerformanceData => registry.PerformanceData, | ||
_ => throw new InvalidOperationException("Unknown registry root"), | ||
}; | ||
var root = path.Hive switch | ||
{ | ||
RegistryHive.ClassesRoot => registry.ClassesRoot, | ||
RegistryHive.CurrentUser => registry.CurrentUser, | ||
RegistryHive.LocalMachine => registry.LocalMachine, | ||
RegistryHive.Users => registry.Users, | ||
RegistryHive.CurrentConfig => registry.CurrentConfig, | ||
RegistryHive.PerformanceData => registry.PerformanceData, | ||
_ => throw new InvalidOperationException("Unknown registry root"), | ||
}; | ||
|
||
return root.OpenSubKey(path.SubKey, writable); | ||
} | ||
return root.OpenSubKey(path.SubKey, writable); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,26 +1,25 @@ | ||
namespace Cupboard | ||
namespace Cupboard; | ||
|
||
public static class ResourceExtensions | ||
{ | ||
public static class ResourceExtensions | ||
public static IResourceBuilder<T> OnError<T>(this IResourceBuilder<T> builder, ErrorOptions options) | ||
where T : Resource | ||
{ | ||
public static IResourceBuilder<T> OnError<T>(this IResourceBuilder<T> builder, ErrorOptions options) | ||
where T : Resource | ||
{ | ||
builder.Configure(res => res.Error = options); | ||
return builder; | ||
} | ||
builder.Configure(res => res.Error = options); | ||
return builder; | ||
} | ||
|
||
public static IResourceBuilder<T> OnReboot<T>(this IResourceBuilder<T> builder, RebootOptions options) | ||
where T : Resource | ||
{ | ||
builder.Configure(res => res.Reboot = options); | ||
return builder; | ||
} | ||
public static IResourceBuilder<T> OnReboot<T>(this IResourceBuilder<T> builder, RebootOptions options) | ||
where T : Resource | ||
{ | ||
builder.Configure(res => res.Reboot = options); | ||
return builder; | ||
} | ||
|
||
public static IResourceBuilder<T> RequireAdministrator<T>(this IResourceBuilder<T> builder) | ||
where T : Resource | ||
{ | ||
builder.Configure(res => res.RequireAdministrator = true); | ||
return builder; | ||
} | ||
public static IResourceBuilder<T> RequireAdministrator<T>(this IResourceBuilder<T> builder) | ||
where T : Resource | ||
{ | ||
builder.Configure(res => res.RequireAdministrator = true); | ||
return builder; | ||
} | ||
} |
Oops, something went wrong.