-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '2.0' into dependabot/nuget/xunit.runner.visualstudio-2.5.0
- Loading branch information
Showing
206 changed files
with
6,583 additions
and
703 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
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace WalletConnectSharp.Common.Logging | ||
{ | ||
public interface ILogger | ||
{ | ||
void Log(string message); | ||
|
||
void LogError(string message); | ||
|
||
void LogError(Exception e); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
Core Modules/WalletConnectSharp.Common/Logging/WCLogger.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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
namespace WalletConnectSharp.Common.Logging | ||
{ | ||
public class WCLogger | ||
{ | ||
public static ILogger Logger; | ||
|
||
public static ILogger WithContext(string context) | ||
{ | ||
return new WrapperLogger(Logger, context); | ||
} | ||
|
||
public static void Log(string message) | ||
{ | ||
if (Logger == null) | ||
return; | ||
|
||
Logger.Log(message); | ||
} | ||
|
||
public static void LogError(string message) | ||
{ | ||
if (Logger == null) | ||
return; | ||
|
||
Logger.LogError(message); | ||
} | ||
|
||
public static void LogError(Exception e) | ||
{ | ||
if (Logger == null) | ||
return; | ||
|
||
Logger.LogError(e); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
Core Modules/WalletConnectSharp.Common/Logging/WrapperLogger.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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
namespace WalletConnectSharp.Common.Logging; | ||
|
||
public class WrapperLogger : ILogger | ||
{ | ||
private ILogger _logger; | ||
private string prefix; | ||
|
||
public WrapperLogger(ILogger logger, string prefix) | ||
{ | ||
_logger = logger; | ||
this.prefix = prefix; | ||
} | ||
|
||
public void Log(string message) | ||
{ | ||
if (_logger == null) return; | ||
_logger.Log($"[{prefix}] {message}"); | ||
} | ||
|
||
public void LogError(string message) | ||
{ | ||
if (_logger == null) return; | ||
_logger.LogError($"[{prefix}] {message}"); | ||
} | ||
|
||
public void LogError(Exception e) | ||
{ | ||
if (_logger == null) return; | ||
_logger.LogError(e); | ||
} | ||
} |
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
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 |
---|---|---|
|
@@ -38,5 +38,7 @@ public IsolatedModule() | |
|
||
activeModules.Add(_guid); | ||
} | ||
|
||
public void Dispose() { } | ||
} | ||
} | ||
} |
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
30 changes: 30 additions & 0 deletions
30
Core Modules/WalletConnectSharp.Common/Utils/DictionaryComparer.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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
namespace WalletConnectSharp.Common.Utils | ||
{ | ||
public class DictionaryComparer<TKey, TValue> : | ||
IEqualityComparer<Dictionary<TKey, TValue>> | ||
{ | ||
private IEqualityComparer<TValue> valueComparer; | ||
public DictionaryComparer(IEqualityComparer<TValue> valueComparer = null) | ||
{ | ||
this.valueComparer = valueComparer ?? EqualityComparer<TValue>.Default; | ||
} | ||
public bool Equals(Dictionary<TKey, TValue> x, Dictionary<TKey, TValue> y) | ||
{ | ||
if (x.Count != y.Count) | ||
return false; | ||
if (x.Keys.Except(y.Keys).Any()) | ||
return false; | ||
if (y.Keys.Except(x.Keys).Any()) | ||
return false; | ||
foreach (var pair in x) | ||
if (!valueComparer.Equals(pair.Value, y[pair.Key])) | ||
return false; | ||
return true; | ||
} | ||
|
||
public int GetHashCode(Dictionary<TKey, TValue> obj) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
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
21 changes: 21 additions & 0 deletions
21
Core Modules/WalletConnectSharp.Common/Utils/ListComparer.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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
namespace WalletConnectSharp.Common.Utils | ||
{ | ||
public class ListComparer<T> : IEqualityComparer<List<T>> | ||
{ | ||
private IEqualityComparer<T> valueComparer; | ||
public ListComparer(IEqualityComparer<T> valueComparer = null) | ||
{ | ||
this.valueComparer = valueComparer ?? EqualityComparer<T>.Default; | ||
} | ||
|
||
public bool Equals(List<T> x, List<T> y) | ||
{ | ||
return x.SetEquals(y, valueComparer); | ||
} | ||
|
||
public int GetHashCode(List<T> obj) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.