Skip to content

Commit 082984b

Browse files
author
Kristifor
committed
Code refactoring, moving static dependencies to DI scoped services. Creating interfaces for all service providers.
1 parent c4bf4c4 commit 082984b

File tree

328 files changed

+772
-562
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

328 files changed

+772
-562
lines changed

.editorconfig

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
[*.cs]
2+
3+
# IDE0011: Add braces
4+
csharp_prefer_braces = when_multiline:silent
5+
csharp_indent_labels = one_less_than_current
6+
csharp_using_directive_placement = outside_namespace:silent
7+
csharp_prefer_simple_using_statement = true:suggestion
8+
csharp_style_namespace_declarations = block_scoped:silent
9+
csharp_style_prefer_method_group_conversion = true:silent
10+
csharp_style_prefer_top_level_statements = true:silent
11+
csharp_style_expression_bodied_methods = false:silent
12+
csharp_style_expression_bodied_constructors = false:silent
13+
csharp_style_expression_bodied_operators = false:silent
14+
csharp_style_expression_bodied_properties = true:silent
15+
csharp_style_expression_bodied_indexers = true:silent
16+
csharp_style_expression_bodied_accessors = true:silent
17+
csharp_style_expression_bodied_lambdas = true:silent
18+
csharp_style_expression_bodied_local_functions = false:silent
19+
csharp_style_throw_expression = true:suggestion
20+
csharp_style_prefer_null_check_over_type_check = true:suggestion
21+
csharp_prefer_simple_default_expression = true:suggestion
22+
csharp_style_prefer_local_over_anonymous_function = true:suggestion
23+
csharp_space_around_binary_operators = before_and_after
24+
25+
[*.{cs,vb}]
26+
#### Naming styles ####
27+
28+
# Naming rules
29+
30+
dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
31+
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
32+
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
33+
34+
dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
35+
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
36+
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
37+
38+
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
39+
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
40+
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
41+
42+
# Symbol specifications
43+
44+
dotnet_naming_symbols.interface.applicable_kinds = interface
45+
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
46+
dotnet_naming_symbols.interface.required_modifiers =
47+
48+
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
49+
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
50+
dotnet_naming_symbols.types.required_modifiers =
51+
52+
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
53+
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
54+
dotnet_naming_symbols.non_field_members.required_modifiers =
55+
56+
# Naming styles
57+
58+
dotnet_naming_style.begins_with_i.required_prefix = I
59+
dotnet_naming_style.begins_with_i.required_suffix =
60+
dotnet_naming_style.begins_with_i.word_separator =
61+
dotnet_naming_style.begins_with_i.capitalization = pascal_case
62+
63+
dotnet_naming_style.pascal_case.required_prefix =
64+
dotnet_naming_style.pascal_case.required_suffix =
65+
dotnet_naming_style.pascal_case.word_separator =
66+
dotnet_naming_style.pascal_case.capitalization = pascal_case
67+
68+
dotnet_naming_style.pascal_case.required_prefix =
69+
dotnet_naming_style.pascal_case.required_suffix =
70+
dotnet_naming_style.pascal_case.word_separator =
71+
dotnet_naming_style.pascal_case.capitalization = pascal_case
72+
dotnet_style_operator_placement_when_wrapping = beginning_of_line
73+
tab_width = 4
74+
indent_size = 4
75+
end_of_line = crlf
76+
dotnet_style_coalesce_expression = true:suggestion
77+
dotnet_style_null_propagation = true:suggestion
78+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
79+
dotnet_style_prefer_auto_properties = true:silent
80+
dotnet_style_object_initializer = true:suggestion
81+
dotnet_style_collection_initializer = true:suggestion
82+
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
83+
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
84+
dotnet_style_prefer_conditional_expression_over_return = true:silent
85+
dotnet_style_explicit_tuple_names = true:suggestion
86+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
87+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
88+
dotnet_style_prefer_compound_assignment = true:suggestion
89+
dotnet_style_prefer_simplified_interpolation = true:suggestion
90+
dotnet_style_namespace_match_folder = true:suggestion

Data/AuthenicationHandler.cs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
1-
using Nethereum.Hex.HexConvertors.Extensions;
21
using Nethereum.Web3.Accounts;
32
using Newtonsoft.Json;
4-
using NFTLock.Models;
53
using SYNCWallet;
64
using SYNCWallet.Models;
7-
using SYNCWallet.Services.Implementation;
8-
using System.Diagnostics;
9-
using System.Text;
10-
using static SYNCWallet.Models.GithubTokensModel;
5+
using SYNCWallet.Services;
6+
using SYNCWallet.Services.Definitions;
117

128
namespace NFTLock.Data;
139

14-
public class AuthenicationHandler
10+
public class AuthenicationHandler : IAuthenicationService
1511
{
1612
ContractService _contractService { get; set; }
17-
13+
IUtilities Utilities { get; set; }
14+
IContractService ContractService { get; set; }
15+
IHardwareService HardwareService { get; set; }
16+
public AuthenicationHandler()
17+
{
18+
Utilities = ServiceHelper.GetService<IUtilities>();
19+
ContractService = ServiceHelper.GetService<IContractService>();
20+
HardwareService = ServiceHelper.GetService<IHardwareService>();
21+
}
22+
1823
public string CreateAccountInitial()
1924
{
2025
//WIP
@@ -104,10 +109,9 @@ public bool ImportToken(string contractAddress, string symbol, int delimiter, in
104109
}
105110

106111

107-
internal Account UnlockWallet(string pass)
112+
public Account UnlockWallet(string pass)
108113
{
109-
var hs = new HardwareService();
110-
var privateKey = hs.DecryptAesEncoded(MauiProgram.PK, pass);
114+
var privateKey = HardwareService.DecryptAesEncoded(MauiProgram.PK, pass);
111115

112116
if (string.IsNullOrEmpty(privateKey))
113117
return null;
@@ -129,15 +133,14 @@ public async Task<List<Token>> GetSupportedTokens(int networkId)
129133

130134
}
131135

132-
private string ToHex(byte[] value, bool prefix = false)
136+
string IAuthenicationService.ToHex(byte[] value, bool prefix)
133137
{
134138
return System.Text.Encoding.UTF8.GetString(value);
135139
}
136140

137-
static byte ConvertBinaryToText(string seq)
141+
byte IAuthenicationService.ConvertBinaryToText(string seq)
138142
{
139143
return Convert.ToByte(seq, 2);
140-
141144
}
142145
}
143146

0 commit comments

Comments
 (0)