Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: format code with dotnet-format #41

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/Configuration/CompositeChangeToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ namespace Microsoft.Extensions.DependencyInjection;

public class CompositeChangeToken(params IChangeToken[] changeTokens) : IChangeToken
{
private readonly IChangeToken[] _changeTokens = changeTokens;
public bool ActiveChangeCallbacks => Exists(_changeTokens, t => t.ActiveChangeCallbacks);
public bool HasChanged => Exists(_changeTokens, t => t.HasChanged);
public IDisposable RegisterChangeCallback(Action<object?> callback, object? state) =>
new CompositeDisposable(
_changeTokens.Select(t => t.RegisterChangeCallback(callback, state))
);
private readonly IChangeToken[] _changeTokens = changeTokens;

public bool ActiveChangeCallbacks => Exists(_changeTokens, t => t.ActiveChangeCallbacks);

public bool HasChanged => Exists(_changeTokens, t => t.HasChanged);

public IDisposable RegisterChangeCallback(Action<object?> callback, object? state) =>
new CompositeDisposable(
_changeTokens.Select(t => t.RegisterChangeCallback(callback, state))
);
}
4 changes: 2 additions & 2 deletions src/Configuration/JsonFileConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ bool recursive
.EnumerateFiles(
"*.json",
recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly
)
// .Where(IsForThisEnvironment)
)
// .Where(IsForThisEnvironment)
.OrderBy(jsonFile => jsonFile.Name);

internal static string RemoveEnvironmentIfIsForThisEnvironment(this string jsonFileName) =>
Expand Down
6 changes: 3 additions & 3 deletions src/Http/Mime/ApplicationMediaTypeNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ public static class ApplicationMediaTypeNames
public const string OpenApiV2Yaml = $"{OpenApiYaml}; version=2.x";

/// <value><inheritdoc cref="OpenApiJson" path="/value" />; version=3.x</value>
public const string OpenApiV3Json = $"{OpenApiJson}; version=3.x";
/// <value><inheritdoc cref="OpenApiYaml" path="/value" />; version=3.x</value>
public const string OpenApiV3Json = $"{OpenApiJson}; version=3.x";

/// <value><inheritdoc cref="OpenApiYaml" path="/value" />; version=3.x</value>
public const string OpenApiV3Yaml = $"{OpenApiYaml}; version=3.x";
}
128 changes: 64 additions & 64 deletions src/Http/Mime/TempMediaType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,68 +21,68 @@ namespace Dgmjr.Mime;
public readonly record struct TempMediaType(string Name)
: IMediaType
{
public string DisplayName { get; } = Name;
private static readonly MD5 MD5 = MD5.Create();
public string[] Synonyms { get; init; } = Empty<string>();
Uri IHaveAUri.Uri => new(UriString);
object IIdentifiable.Id => Id;
public int Id => 0;
public int Value => Id;
public string UriString => "urn:publicid:temp:media-type:" + DisplayName.ToKebabCase();
public string GuidString => MD5.ComputeHash(UriString.ToUTF8Bytes()).ToHexString();
public guid Guid => new(GuidString);
public string Description => Name;
public string GroupName => Name;
public string ShortName => Name;
public string Name => DisplayName;
public int Order => 0;
public string Prompt => "";
uri IMediaType.Uri => UriString;
uri IHaveAuri.Uri => UriString;
object IHaveAValue.Value => Value;
int IHaveAValue<int>.Value => Id;
MediaTypes IHaveAValue<MediaTypes>.Value => MediaTypes.Any;
TypeCode IConvertible.GetTypeCode() => TypeCode.Object;
bool IConvertible.ToBoolean(IFormatProvider? provider) => true;
byte IConvertible.ToByte(IFormatProvider? provider) => Convert.ToByte(Value);
char IConvertible.ToChar(IFormatProvider? provider) => Convert.ToChar(Value);
datetime IConvertible.ToDateTime(IFormatProvider? provider) => Convert.ToDateTime(Value);
decimal IConvertible.ToDecimal(IFormatProvider? provider) => Convert.ToDecimal(Value);
double IConvertible.ToDouble(IFormatProvider? provider) => Convert.ToDouble(Value);
short IConvertible.ToInt16(IFormatProvider? provider) => Convert.ToInt16(Value);
int IConvertible.ToInt32(IFormatProvider? provider) => Convert.ToInt32(Value);
long IConvertible.ToInt64(IFormatProvider? provider) => Convert.ToInt64(Value);
sbyte IConvertible.ToSByte(IFormatProvider? provider) => Convert.ToSByte(Value);
float IConvertible.ToSingle(IFormatProvider? provider) => Convert.ToSingle(Value);
string IConvertible.ToString(IFormatProvider? provider) => Convert.ToString(Value);
object IConvertible.ToType(type conversionType, IFormatProvider? provider) =>
Convert.ChangeType(Value, conversionType);
ushort IConvertible.ToUInt16(IFormatProvider? provider) => Convert.ToUInt16(Value);
uint IConvertible.ToUInt32(IFormatProvider? provider) => Convert.ToUInt32(Value);
ulong IConvertible.ToUInt64(IFormatProvider? provider) => Convert.ToUInt64(Value);
bool IEquatable<int>.Equals(int other) => Id == other;
bool IEquatable<IMediaType>.Equals(IMediaType other) => this.Matches(other);
public string DisplayName { get; } = Name;
private static readonly MD5 MD5 = MD5.Create();
public string[] Synonyms { get; init; } = Empty<string>();
Uri IHaveAUri.Uri => new(UriString);
object IIdentifiable.Id => Id;
public int Id => 0;
public int Value => Id;
public string UriString => "urn:publicid:temp:media-type:" + DisplayName.ToKebabCase();
public string GuidString => MD5.ComputeHash(UriString.ToUTF8Bytes()).ToHexString();
public guid Guid => new(GuidString);
public string Description => Name;
public string GroupName => Name;
public string ShortName => Name;
public string Name => DisplayName;
public int Order => 0;
public string Prompt => "";

uri IMediaType.Uri => UriString;
uri IHaveAuri.Uri => UriString;

object IHaveAValue.Value => Value;

int IHaveAValue<int>.Value => Id;

MediaTypes IHaveAValue<MediaTypes>.Value => MediaTypes.Any;

TypeCode IConvertible.GetTypeCode() => TypeCode.Object;

bool IConvertible.ToBoolean(IFormatProvider? provider) => true;

byte IConvertible.ToByte(IFormatProvider? provider) => Convert.ToByte(Value);

char IConvertible.ToChar(IFormatProvider? provider) => Convert.ToChar(Value);

datetime IConvertible.ToDateTime(IFormatProvider? provider) => Convert.ToDateTime(Value);

decimal IConvertible.ToDecimal(IFormatProvider? provider) => Convert.ToDecimal(Value);

double IConvertible.ToDouble(IFormatProvider? provider) => Convert.ToDouble(Value);

short IConvertible.ToInt16(IFormatProvider? provider) => Convert.ToInt16(Value);

int IConvertible.ToInt32(IFormatProvider? provider) => Convert.ToInt32(Value);

long IConvertible.ToInt64(IFormatProvider? provider) => Convert.ToInt64(Value);

sbyte IConvertible.ToSByte(IFormatProvider? provider) => Convert.ToSByte(Value);

float IConvertible.ToSingle(IFormatProvider? provider) => Convert.ToSingle(Value);

string IConvertible.ToString(IFormatProvider? provider) => Convert.ToString(Value);

object IConvertible.ToType(type conversionType, IFormatProvider? provider) =>
Convert.ChangeType(Value, conversionType);

ushort IConvertible.ToUInt16(IFormatProvider? provider) => Convert.ToUInt16(Value);

uint IConvertible.ToUInt32(IFormatProvider? provider) => Convert.ToUInt32(Value);

ulong IConvertible.ToUInt64(IFormatProvider? provider) => Convert.ToUInt64(Value);

bool IEquatable<int>.Equals(int other) => Id == other;

bool IEquatable<IMediaType>.Equals(IMediaType other) => this.Matches(other);
}
12 changes: 6 additions & 6 deletions src/Http/ResponseCodes/ResponseCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public enum StatusCode : ushort
/// <value>200</value>
/// <see href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200" />
[Display(
Name = "OK",
// Description = "The request has succeeded. The meaning of the success depends on the HTTP method:"
Name = "OK",
// Description = "The request has succeeded. The meaning of the success depends on the HTTP method:"
Description = "Yay! You didn't fuck up!"
)]
[Uri($"{UriBase}200")]
Expand All @@ -63,8 +63,8 @@ public enum StatusCode : ushort
/// <value>201</value>
/// <see href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201" />
[Display(
Name = "Created",
// Description = "The request has succeeded and a new resource has been created as a result. This is typically the response sent after a PUT request."
Name = "Created",
// Description = "The request has succeeded and a new resource has been created as a result. This is typically the response sent after a PUT request."
Description = "I created the thing for you."
)]
[Uri($"{UriBase}201")]
Expand All @@ -75,8 +75,8 @@ public enum StatusCode : ushort
/// <value>202</value>
/// <see href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202" />
[Display(
Name = "Accepted",
// Description = "The request has been received but not yet acted upon. It is non-committal, meaning that there is no way in HTTP to later send an asynchronous response indicating the outcome of processing the request. It is intended for cases where another process or server handles the request, or for batch processing."
Name = "Accepted",
// Description = "The request has been received but not yet acted upon. It is non-committal, meaning that there is no way in HTTP to later send an asynchronous response indicating the outcome of processing the request. It is intended for cases where another process or server handles the request, or for batch processing."
Description = "I got it and you can go do other stuff while I work on it for you."
)]
[Uri($"{UriBase}202")]
Expand Down
6 changes: 3 additions & 3 deletions src/Http/Services/AddHttpServicesExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,23 @@ public static IHostApplicationBuilder AddHttpServices(
);
}

if(options.IIS != null)
if (options.IIS != null)
{
builder.Services.Configure<IISServerOptions>(
options =>
builder.Configuration.Bind($"{configurationSectionKey}:{IIS}", options)
);
}

if(options.Kestrel != null)
if (options.Kestrel != null)
{
builder.Services.Configure<KestrelServerOptions>(
options =>
builder.Configuration.Bind($"{configurationSectionKey}:{Kestrel}", options)
);
}

if(options.ExceptionHandling != null)
if (options.ExceptionHandling != null)
{
builder.Services.Configure<ExceptionHandlerOptions>(
options =>
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Services/CorsOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Dgmjr.AspNetCore.Http.Services;
string,
Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy
>;
using ICorsPolicyCollection = ICollection<KeyValuePair<string, Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy>>;
using ICorsPolicyCollection = ICollection<KeyValuePair<string, Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy>>;
using ICorsPolicyEnumerable = IEnumerable<KeyValuePair<string, Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy>>;

public class CorsOptions
Expand Down
16 changes: 8 additions & 8 deletions src/Http/Services/CorsOptionsConfigurator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ namespace Dgmjr.AspNetCore.Http.Services;

public class CorsOptionsConfigurator(IConfiguration configuration) : IConfigureOptions<CorsOptions>
{
public const string CorsOptionsSection = $"{Http}:{Cors}";
private readonly IConfiguration _configuration = configuration;
public void Configure(CorsOptions options)
{
var corsPolicyDictionary = _configuration.GetSection(CorsOptionsSection).Get<Dictionary<string, CorsPolicy>>();
}
public const string CorsOptionsSection = $"{Http}:{Cors}";

private readonly IConfiguration _configuration = configuration;

public void Configure(CorsOptions options)
{
var corsPolicyDictionary = _configuration.GetSection(CorsOptionsSection).Get<Dictionary<string, CorsPolicy>>();
}
}
26 changes: 13 additions & 13 deletions src/Http/Services/UseHttpServicesExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static IApplicationBuilder UseHttpServices(this IApplicationBuilder app)
{
var options = app.ApplicationServices.GetRequiredService<IOptions<HttpServicesOptions>>().Value;

if(options.UseRequestDecompression)
if (options.UseRequestDecompression)
{
app.UseRequestDecompression();
}
Expand All @@ -21,37 +21,37 @@ public static IApplicationBuilder UseHttpServices(this IApplicationBuilder app)
app.UseResponseCompression();
}

if(options.UseFileServer)
if (options.UseFileServer)
{
app.UseFileServer(options.FileServer);

if(options.FileServer.EnableDefaultFiles)
if (options.FileServer.EnableDefaultFiles)
{
app.UseDefaultFiles(options.FileServer.DefaultFilesOptions);
}

if(options.FileServer.EnableDirectoryBrowsing)
if (options.FileServer.EnableDirectoryBrowsing)
{
app.UseDirectoryBrowser(options.FileServer.DirectoryBrowserOptions);
}

if(options.FileServer.StaticFileOptions != null || options.UseStaticFiles)
if (options.FileServer.StaticFileOptions != null || options.UseStaticFiles)
{
app.UseStaticFiles(options.FileServer.StaticFileOptions);
}
}

if(options.UseResponseCaching)
if (options.UseResponseCaching)
{
app.UseResponseCaching();
}

if(options.UseForwardedHeaders)
if (options.UseForwardedHeaders)
{
app.UseForwardedHeaders(options.ForwardedHeaders);
}

if(options.UseCors)
if (options.UseCors)
{
app.UseCors();
// _ = app.UseCors(corsOptions => corsOptions
Expand All @@ -63,27 +63,27 @@ public static IApplicationBuilder UseHttpServices(this IApplicationBuilder app)
// );
}

if(options.UseCookiePolicy)
if (options.UseCookiePolicy)
{
app.UseCookiePolicy(options.CookiePolicy);
}

if(options.UseSession)
if (options.UseSession)
{
app.UseSession(options.Session);
}

if(options.UseHsts)
if (options.UseHsts)
{
app.UseHsts();
}

if(options.UseHttpsRedirection)
if (options.UseHttpsRedirection)
{
app.UseHttpsRedirection();
}

if(options.UseExceptionHandler)
if (options.UseExceptionHandler)
{
app.UseExceptionHandler(options.ExceptionHandling);
}
Expand Down
Loading
Loading