@@ -9,6 +9,11 @@ namespace Kerberos.NET.Crypto
99{
1010 public abstract class CryptoPal
1111 {
12+ protected CryptoPal ( )
13+ {
14+ this . PlatformCheck ( ) ;
15+ }
16+
1217 protected static bool IsWindows => OSPlatform . IsWindows ;
1318
1419 protected static bool IsLinux => OSPlatform . IsLinux ;
@@ -18,7 +23,7 @@ public abstract class CryptoPal
1823 public static CryptoPal Platform => lazyPlatform . Value ;
1924
2025 private static readonly Lazy < CryptoPal > lazyPlatform
21- = new Lazy < CryptoPal > ( ( ) => CreatePal ( ) ) ;
26+ = new ( ( ) => CreatePal ( ) ) ;
2227
2328 private static Func < CryptoPal > injectedPal ;
2429
@@ -27,6 +32,10 @@ public static void RegisterPal(Func<CryptoPal> palFunc)
2732 injectedPal = palFunc ?? throw new InvalidOperationException ( "Cannot register a null PAL" ) ;
2833 }
2934
35+ protected virtual void PlatformCheck ( )
36+ {
37+ }
38+
3039 private static CryptoPal CreatePal ( )
3140 {
3241 var injected = injectedPal ;
@@ -40,15 +49,13 @@ private static CryptoPal CreatePal()
4049 {
4150 return new WindowsCryptoPal ( ) ;
4251 }
43-
44- if ( IsLinux )
52+ else if ( IsOsX )
4553 {
46- return new LinuxCryptoPal ( ) ;
54+ return new OSXCryptoPal ( ) ;
4755 }
48-
49- if ( IsOsX )
56+ else if ( IsLinux )
5057 {
51- return new OSXCryptoPal ( ) ;
58+ return new LinuxCryptoPal ( ) ;
5259 }
5360
5461 throw PlatformNotSupported ( ) ;
0 commit comments