Skip to content

Commit

Permalink
refactor to new namespaces (#734)
Browse files Browse the repository at this point in the history
* refactor to new namespaces

* Add .editorconfig

Co-authored-by: IgorRakityanskiy <[email protected]>
  • Loading branch information
DmyMi and i-rakityanskiy authored Jul 6, 2022
1 parent f970551 commit d148f5f
Show file tree
Hide file tree
Showing 652 changed files with 38,480 additions and 39,031 deletions.
104 changes: 104 additions & 0 deletions OutOfSchool/.editorconfig
Original file line number Diff line number Diff line change
@@ -1 +1,105 @@


[*.cs]
#### Naming styles ####

# Naming rules

dotnet_naming_rule.private_or_internal_field_should_be__fieldname.severity = suggestion
dotnet_naming_rule.private_or_internal_field_should_be__fieldname.symbols = private_or_internal_field
dotnet_naming_rule.private_or_internal_field_should_be__fieldname.style = pascal_case

# Symbol specifications

dotnet_naming_symbols.private_or_internal_field.applicable_kinds = field
dotnet_naming_symbols.private_or_internal_field.applicable_accessibilities = internal, private, private_protected
dotnet_naming_symbols.private_or_internal_field.required_modifiers =

# Naming styles

dotnet_naming_style._fieldname.required_prefix = _
dotnet_naming_style._fieldname.required_suffix =
dotnet_naming_style._fieldname.word_separator =
dotnet_naming_style._fieldname.capitalization = camel_case
csharp_indent_labels = no_change
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:silent
csharp_style_namespace_declarations = file_scoped:error
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_style_throw_expression = true:suggestion

[*.{cs,vb}]
#### Naming styles ####

# Naming rules

dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i

dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case

dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case

# Symbol specifications

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =

dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =

dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =

# Naming styles

dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
indent_size = 4
end_of_line = crlf
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_auto_properties = true:silent
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
dotnet_style_namespace_match_folder = true:suggestion
19 changes: 9 additions & 10 deletions OutOfSchool/OutOfSchool.Common/Config/IMySqlConnectionOptions.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
namespace OutOfSchool.Common.Config
namespace OutOfSchool.Common.Config;

public interface IMySqlConnectionOptions
{
public interface IMySqlConnectionOptions
{
public bool UseOverride { get; set; }
public bool UseOverride { get; set; }

public string Server { get; set; }
public string Server { get; set; }

public uint Port { get; set; }
public uint Port { get; set; }

public string Database { get; set; }
public string Database { get; set; }

public string UserId { get; set; }
public string UserId { get; set; }

public string Password { get; set; }
}
public string Password { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace OutOfSchool.Common.Config
namespace OutOfSchool.Common.Config;

public interface IMySqlGuidConnectionOptions : IMySqlConnectionOptions
{
public interface IMySqlGuidConnectionOptions : IMySqlConnectionOptions
{
public string GuidFormat { get; set; }
}
public string GuidFormat { get; set; }
}
11 changes: 5 additions & 6 deletions OutOfSchool/OutOfSchool.Common/Config/ReverseProxyOptions.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
namespace OutOfSchool.Common.Config
namespace OutOfSchool.Common.Config;

public class ReverseProxyOptions
{
public class ReverseProxyOptions
{
public const string Name = "ReverseProxy";
public const string Name = "ReverseProxy";

public string BasePath { get; set; }
}
public string BasePath { get; set; }
}
33 changes: 16 additions & 17 deletions OutOfSchool/OutOfSchool.Common/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
namespace OutOfSchool.Common
namespace OutOfSchool.Common;

public static class Constants
{
public static class Constants
{
public const int UnifiedUrlLength = 256;
public const int UnifiedUrlLength = 256;

public const string BearerScheme = "Bearer";
public const string BearerScheme = "Bearer";

public const string PhoneNumberFormat = "{0:+380 XX-XXX-XX-XX}";
public const string PhoneNumberFormat = "{0:+380 XX-XXX-XX-XX}";

public const string PhoneNumberRegexViewModel = @"([0-9]{2})([-]?)([0-9]{3})([-]?)([0-9]{2})([-]?)([0-9]{2})";
public const string PhoneNumberRegexViewModel = @"([0-9]{2})([-]?)([0-9]{3})([-]?)([0-9]{2})([-]?)([0-9]{2})";

public const string PhoneNumberRegexModel = @"([\d]{9})";
public const string PhoneNumberRegexModel = @"([\d]{9})";

public const string PhoneErrorMessage = "Error! Please check the number is correct";
public const string PhoneErrorMessage = "Error! Please check the number is correct";

public const int UnifiedPhoneLength = 15;
public const int UnifiedPhoneLength = 15;

public const int MySQLServerMinimalMajorVersion = 8;
public const int MySQLServerMinimalMajorVersion = 8;

public const string NameRegexViewModel = @"^(?i)[А-ЯҐЄІЇ](([\'\-][А-ЯҐЄІЇ])?[А-ЯҐЄІЇ]*)*$";
public const string NameRegexViewModel = @"^(?i)[А-ЯҐЄІЇ](([\'\-][А-ЯҐЄІЇ])?[А-ЯҐЄІЇ]*)*$";

public const string NameErrorMessage = "Check the entered data. Please use only cyrillic and symbols( ' - )";
public const string NameErrorMessage = "Check the entered data. Please use only cyrillic and symbols( ' - )";

public const string EmailRegexViewModel = @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$";
public const string EmailRegexViewModel = @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$";

public const string PasswordRegexViewModel = @"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{6,}$";
public const string PasswordRegexViewModel = @"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{6,}$";

public const string AddressSeparator = ", ";
}
public const string AddressSeparator = ", ";
}
15 changes: 7 additions & 8 deletions OutOfSchool/OutOfSchool.Common/Enums/OwnershipType.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace OutOfSchool.Common.Enums
namespace OutOfSchool.Common.Enums;

[JsonConverter(typeof(StringEnumConverter))]
public enum OwnershipType
{
[JsonConverter(typeof(StringEnumConverter))]
public enum OwnershipType
{
State,
Common,
Private,
}
State,
Common,
Private,
}
25 changes: 12 additions & 13 deletions OutOfSchool/OutOfSchool.Common/Enums/PayRateType.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace OutOfSchool.Common.Enums
namespace OutOfSchool.Common.Enums;

[JsonConverter(typeof(StringEnumConverter))]
public enum PayRateType
{
[JsonConverter(typeof(StringEnumConverter))]
public enum PayRateType
{
Classes = 1,
Month,
Day,
Year,
Hour,
Course,
AllPeriod,
}
}
Classes = 1,
Month,
Day,
Year,
Hour,
Course,
AllPeriod,
}
13 changes: 6 additions & 7 deletions OutOfSchool/OutOfSchool.Common/Enums/WorkshopStatus.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace OutOfSchool.Common.Enums
namespace OutOfSchool.Common.Enums;

[JsonConverter(typeof(StringEnumConverter))]
public enum WorkshopStatus
{
[JsonConverter(typeof(StringEnumConverter))]
public enum WorkshopStatus
{
Open = 1,
Closed,
}
Open = 1,
Closed,
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,37 @@
using System.Security.Claims;
using OutOfSchool.Common.PermissionsModule;

namespace OutOfSchool.Common.Extensions
namespace OutOfSchool.Common.Extensions;

/// <summary>
/// Extention methods for the <see cref="ClaimsPrincipal"/> class.
/// </summary>
public static class ClaimsPrincipalExtentions
{
/// <summary>
/// Extention methods for the <see cref="ClaimsPrincipal"/> class.
/// Gets the property value from the <see cref="ClaimsPrincipal"/> by the identity resource claim type.
/// </summary>
public static class ClaimsPrincipalExtentions
/// <param name="principal"><see cref="ClaimsPrincipal"/> object.</param>
/// <param name="identityResourceClaim">Identity resource claim type.</param>
/// <returns>Property value if exist, otherwise <see langword="null"/>.</returns>
/// <exception cref="System.ArgumentNullException">
/// thrown when:
/// <paramref name="principal"/> is null
/// or
/// <paramref name="identityResourceClaim"/> is null or empty.
/// </exception>
public static string GetUserPropertyByClaimType(this ClaimsPrincipal principal, string identityResourceClaim)
{
/// <summary>
/// Gets the property value from the <see cref="ClaimsPrincipal"/> by the identity resource claim type.
/// </summary>
/// <param name="principal"><see cref="ClaimsPrincipal"/> object.</param>
/// <param name="identityResourceClaim">Identity resource claim type.</param>
/// <returns>Property value if exist, otherwise <see langword="null"/>.</returns>
/// <exception cref="System.ArgumentNullException">
/// thrown when:
/// <paramref name="principal"/> is null
/// or
/// <paramref name="identityResourceClaim"/> is null or empty.
/// </exception>
public static string GetUserPropertyByClaimType(this ClaimsPrincipal principal, string identityResourceClaim)
if (principal == null)
{
if (principal == null)
{
throw new ArgumentNullException(nameof(principal));
}

if (string.IsNullOrEmpty(identityResourceClaim))
{
throw new ArgumentNullException(nameof(identityResourceClaim));
}
throw new ArgumentNullException(nameof(principal));
}

return principal.FindFirst(identityResourceClaim)?.Value;
if (string.IsNullOrEmpty(identityResourceClaim))
{
throw new ArgumentNullException(nameof(identityResourceClaim));
}

return principal.FindFirst(identityResourceClaim)?.Value;
}
}
}
Loading

0 comments on commit d148f5f

Please sign in to comment.