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

EHD-1411: Reduce code in Core project #602

Merged
merged 35 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
59b98db
EHD-1411: Reduce code in Core project: Move Obfuscator
jamesgriff Nov 4, 2024
c111766
EHD-1411: Reduce code in Core project: Move Autofac ContainerIOC from…
jamesgriff Nov 4, 2024
d3883f6
EHD-1411: Reduce code in Core project: Move CsvWriter
jamesgriff Nov 4, 2024
1e762d0
EHD-1411: Reduce code in Core project: Simplify SecurityHeaderMiddleware
jamesgriff Nov 4, 2024
1637c6d
EHD-1411: Reduce code in Core project: Replace use of custom HttpCont…
jamesgriff Nov 4, 2024
3c9c604
EHD-1411: Reduce code in Core project: Inline Extensions.Middleware code
jamesgriff Nov 4, 2024
5ddf820
EHD-1411: Reduce code in Core project: Inline GetRequestCookie code
jamesgriff Nov 4, 2024
d26093c
EHD-1411: Reduce code in Core project: Move, rename HttpContextHelper…
jamesgriff Nov 4, 2024
bf99599
EHD-1411: Reduce code in Core project: Inline Extensions.SetResponseH…
jamesgriff Nov 4, 2024
8d4206e
EHD-1411: Reduce code in Core project: Move middlewares
jamesgriff Nov 4, 2024
4abb9d6
EHD-1411: Reduce code in Core project: Move Basic Auth helper
jamesgriff Nov 4, 2024
c73ac0b
EHD-1411: Reduce code in Core project: Move ThreadCountHelper
jamesgriff Nov 4, 2024
7b98d63
EHD-1411: Reduce code in Core project: Move FeatureFlagHelper
jamesgriff Nov 4, 2024
ce9ba89
EHD-1411: Reduce code in Core project: Move ChangeEmailVerificationToken
jamesgriff Nov 4, 2024
6aa19f1
EHD-1411: Reduce code in Core project: Move DownloadResult
jamesgriff Nov 4, 2024
54bc9aa
EHD-1411: Reduce code in Core project: Move GetAccountingStartDate
jamesgriff Nov 4, 2024
e7ca432
EHD-1411: Reduce code in Core project: Move methods out of Extensions…
jamesgriff Nov 4, 2024
2cacce3
EHD-1411: Reduce code in Core project: Move methods out of Extensions…
jamesgriff Nov 4, 2024
0523da2
EHD-1411: Reduce code in Core project: Simplify PITP pin generation
jamesgriff Nov 4, 2024
cd39daf
EHD-1411: Reduce code in Core project: Remove ToDelimitedString
jamesgriff Nov 4, 2024
b10ec01
EHD-1411: Reduce code in Core project: Replace non-standard ForEach e…
jamesgriff Nov 4, 2024
47032c1
EHD-1411: Reduce code in Core project: Replace non-standard SplitI ex…
jamesgriff Nov 4, 2024
d864d70
EHD-1411: Reduce code in Core project: Remove unused code
jamesgriff Nov 4, 2024
2f55cb4
EHD-1411: Reduce code in Core project: Replace long-winded GetAttribu…
jamesgriff Nov 4, 2024
e914236
EHD-1411: Reduce code in Core project: Move methods out of Crypto
jamesgriff Nov 5, 2024
c5a4c12
EHD-1411: Reduce code in Core project: Move some methods out of Misc
jamesgriff Nov 5, 2024
ed29996
EHD-1411: Reduce code in Core project: Move FindParentWithAttribute o…
jamesgriff Nov 5, 2024
a0f5b6a
EHD-1411: Reduce code in Core project: Replace non-standard extension…
jamesgriff Nov 5, 2024
cc7320b
EHD-1411: Reduce code in Core project: Replace use of extension methods
jamesgriff Nov 5, 2024
0aee7d9
EHD-1411: Reduce code in Core project: Replace non-standard extension…
jamesgriff Nov 5, 2024
5d771ea
EHD-1411: Reduce code in Core project: Remove some unused using state…
jamesgriff Nov 5, 2024
507bc83
EHD-1411: Reduce code in Core project: Move EventLog
jamesgriff Nov 5, 2024
5900a9b
EHD-1411: Reduce code in Core project: Simplify Encryption and use ne…
jamesgriff Nov 6, 2024
99c1f58
EHD-1411: Reduce code in Core project: Simplify Encryption: Fix unit …
jamesgriff Nov 6, 2024
ad4f79b
EHD-1411: Reduce code in Core project: Remove / simplify some unused …
jamesgriff Nov 8, 2024
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
49 changes: 0 additions & 49 deletions GenderPayGap.Core/Classes/Extensions.cs

This file was deleted.

25 changes: 25 additions & 0 deletions GenderPayGap.Core/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ public static bool IsInScopeVariant(this ScopeStatuses scopeStatus)
{
return scopeStatus == ScopeStatuses.InScope || scopeStatus == ScopeStatuses.PresumedInScope;
}
public static bool IsOutOfScopeVariant(this ScopeStatuses scopeStatus)
{
return scopeStatus == ScopeStatuses.OutOfScope || scopeStatus == ScopeStatuses.PresumedOutOfScope;
}

public static bool IsScopePresumed(this ScopeStatuses scopeStatus)
{
Expand Down Expand Up @@ -152,6 +156,27 @@ public enum OrganisationSizes

}

public static class OrganisationSizesExtensions
{
public static string GetDisplayName(this OrganisationSizes organisationSize)
{
DisplayAttribute displayAttribute = organisationSize.GetType()
.GetMember(organisationSize.ToString())
.FirstOrDefault()
?.GetCustomAttribute<DisplayAttribute>();

return displayAttribute?.Name;
}

public static RangeAttribute GetRange(this OrganisationSizes organisationSize)
{
return organisationSize.GetType()
.GetMember(organisationSize.ToString())
.FirstOrDefault()
?.GetCustomAttribute<RangeAttribute>();
}
}

public enum AuditedAction
{
[Display(Name = "Admin changed late flag")]
Expand Down

This file was deleted.

46 changes: 44 additions & 2 deletions GenderPayGap.Core/Extensions/AspNetCore/Config.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using Microsoft.Extensions.Configuration;

Expand Down Expand Up @@ -46,7 +47,7 @@ public static string EnvironmentName
_EnvironmentName = Environment.GetEnvironmentVariable("Environment"); //This is used by webjobs SDK v3
}

if (string.IsNullOrWhiteSpace(_EnvironmentName) && Environment.GetEnvironmentVariable("DEV_ENVIRONMENT").ToBoolean())
if (string.IsNullOrWhiteSpace(_EnvironmentName) && Environment.GetEnvironmentVariable("DEV_ENVIRONMENT") == "true")
{
_EnvironmentName = "Local";
}
Expand Down Expand Up @@ -104,7 +105,7 @@ public static bool IsEnvironment(params string[] environmentNames)
{
foreach (string environmentName in environmentNames)
{
if (EnvironmentName.EqualsI(environmentName))
if (EnvironmentName.Equals(environmentName, StringComparison.InvariantCultureIgnoreCase))
{
return true;
}
Expand All @@ -121,6 +122,47 @@ public static string GetAppSetting(string key, string defaultValue = null)
return string.IsNullOrWhiteSpace(value) ? defaultValue : value;
}

public static bool GetAppSettingBool(string key, bool defaultValue = false)
{
string settingValue = GetAppSetting(key);

if (bool.TryParse(settingValue, out bool settingValueBool))
{
return settingValueBool;
}

return defaultValue;
}

public static int GetAppSettingInt(string key, int defaultValue = 0)
{
string settingValue = GetAppSetting(key);

if (int.TryParse(settingValue, out int settingValueInt))
{
return settingValueInt;
}

return defaultValue;
}

public static DateTime GetAppSettingDateTime(string key)
{
string settingValue = GetAppSetting(key);

if (DateTime.TryParseExact(settingValue, "yyMMddHHmmss", null, DateTimeStyles.AssumeLocal, out DateTime parsedValueShortFormat))
{
return parsedValueShortFormat;
}

if (DateTime.TryParse(settingValue, out DateTime parsedValueOtherFormat))
{
return parsedValueOtherFormat;
}

return DateTime.MinValue;
}

private static IConfiguration GetAppSettings()
{
IConfiguration appSettings = Configuration.GetSection("AppSettings");
Expand Down
29 changes: 0 additions & 29 deletions GenderPayGap.Core/Extensions/AspNetCore/Extensions.Middleware.cs

This file was deleted.

68 changes: 0 additions & 68 deletions GenderPayGap.Core/Extensions/AspNetCore/Extensions.cs

This file was deleted.

95 changes: 0 additions & 95 deletions GenderPayGap.Core/Extensions/AspNetCore/HttpContext.cs

This file was deleted.

Loading