|
23 | 23 |
|
24 | 24 | #endregion Coypright and GPL License
|
25 | 25 |
|
26 |
| -using System.Reflection; |
27 | 26 | using System.Runtime.CompilerServices;
|
28 | 27 | using System.Text;
|
29 | 28 |
|
30 | 29 | using AxCrypt.Abstractions;
|
31 | 30 | using AxCrypt.Abstractions.Algorithm;
|
32 |
| -using AxCrypt.Api; |
33 | 31 | using AxCrypt.Core;
|
34 | 32 | using AxCrypt.Core.Crypto;
|
35 |
| -using AxCrypt.Core.Extensions; |
| 33 | +using AxCrypt.Core.Crypto.Asymmetric; |
36 | 34 | using AxCrypt.Core.IO;
|
| 35 | +using AxCrypt.Core.Portable; |
37 | 36 | using AxCrypt.Core.Runtime;
|
38 |
| -using AxCrypt.Core.Service; |
39 | 37 | using AxCrypt.Core.UI;
|
40 | 38 | using AxCrypt.Mono;
|
41 | 39 | using AxCrypt.Mono.Portable;
|
|
49 | 47 | using Xecrets.Cli.Run;
|
50 | 48 | using Xecrets.Licensing.Abstractions;
|
51 | 49 | using Xecrets.Licensing.Implementation;
|
| 50 | +using Xecrets.Net.Api.Implementation; |
| 51 | +using Xecrets.Net.Core; |
52 | 52 |
|
53 | 53 | using static AxCrypt.Abstractions.TypeResolve;
|
54 | 54 |
|
|
58 | 58 |
|
59 | 59 | var options = new OptionsParser(Environment.CommandLine);
|
60 | 60 |
|
61 |
| -RuntimeEnvironment.RegisterTypeFactories(); |
| 61 | +TypeMap.Register.Singleton<IRuntimeEnvironment>(() => new RuntimeEnvironment(".axx")); |
| 62 | +TypeMap.Register.Singleton<IPortableFactory>(() => new PortableFactory()); |
| 63 | +TypeMap.Register.Singleton<ILogging>(() => new Logging()); |
| 64 | +TypeMap.Register.Singleton<IPlatform>(() => new MonoPlatform()); |
| 65 | +TypeMap.Register.Singleton<IPath>(() => new PortablePath()); |
| 66 | + |
| 67 | +TypeMap.Register.New<string, IDataStore>((path) => new DataStore(path)); |
| 68 | +TypeMap.Register.New<string, IDataContainer>((path) => new DataContainer(path)); |
| 69 | +TypeMap.Register.New<string, IDataItem>((path) => DataItem.Create(path)); |
62 | 70 |
|
63 | 71 | string workFolderPath = Path.Combine(Path.GetTempPath(), "Axantum/XecretsCli".Replace('/', Path.DirectorySeparatorChar));
|
64 |
| -Directory.CreateDirectory(workFolderPath); |
65 |
| -Resolve.RegisterTypeFactories(workFolderPath, []); |
| 72 | +Directory.CreateDirectory(workFolderPath); |
| 73 | + |
| 74 | +TypeMap.Register.Singleton(() => new UserSettingsVersion()); |
| 75 | +TypeMap.Register.Singleton(() => new UserSettings(New<ISettingsStore>(), New<IterationCalculator>())); |
| 76 | +TypeMap.Register.Singleton<IRandomGenerator>(() => new RandomGenerator()); |
| 77 | +TypeMap.Register.Singleton<IAsymmetricFactory>(() => new BouncyCastleAsymmetricFactory()); |
| 78 | +TypeMap.Register.Singleton(() => new CryptoFactory([])); |
| 79 | + |
| 80 | +TypeMap.Register.New(() => new AxCryptFactory()); |
| 81 | +TypeMap.Register.New(() => new AxCryptFile()); |
| 82 | +TypeMap.Register.New<int, Salt>((size) => new Salt(size)); |
| 83 | +TypeMap.Register.New(() => new IterationCalculator()); |
| 84 | +TypeMap.Register.Singleton<IStringSerializer>(() => new SystemTextJsonStringSerializer(JsonSourceGenerationContext.CreateJsonSerializerContext())); |
| 85 | + |
| 86 | +TypeMap.Register.Singleton(() => new WorkFolder(workFolderPath), () => { }); |
66 | 87 |
|
67 | 88 | TypeMap.Register.Singleton(() => new FileLocker());
|
68 |
| -TypeMap.Register.Singleton<IProtectedData>(() => new ProtectedDataImplementation("Xecrets.Cli")); |
69 |
| -TypeMap.Register.New<ILauncher>(() => new Launcher()); |
70 | 89 | TypeMap.Register.New(() => PortableFactory.AxCryptHMACSHA1());
|
71 | 90 | TypeMap.Register.New<HMACSHA512>(() => new AxCrypt.Mono.Cryptography.HMACSHA512Wrapper(new AxCrypt.Desktop.Cryptography.HMACSHA512CryptoServiceProvider()));
|
72 | 91 | TypeMap.Register.New<Aes>(() => new AxCrypt.Mono.Cryptography.AesWrapper(System.Security.Cryptography.Aes.Create()));
|
73 | 92 | TypeMap.Register.New<Sha1>(() => PortableFactory.SHA1Managed());
|
74 | 93 | TypeMap.Register.New<Sha256>(() => PortableFactory.SHA256Managed());
|
75 | 94 | TypeMap.Register.New<CryptoStreamBase>(() => PortableFactory.CryptoStream());
|
76 | 95 | TypeMap.Register.New(() => PortableFactory.RandomNumberGenerator());
|
77 |
| -TypeMap.Register.New<LogOnIdentity, IAccountService>((LogOnIdentity identity) => new CachingAccountService(new DeviceAccountService(new LocalAccountService(identity, Resolve.WorkFolder.FileInfo), new ApiAccountService(new AxCryptApiClient(identity.ToRestIdentity(), Resolve.UserSettings.RestApiBaseUrl, Resolve.UserSettings.ApiTimeout))))); |
78 |
| -TypeMap.Register.New(() => new GlobalApiClient(Resolve.UserSettings.RestApiBaseUrl, Resolve.UserSettings.ApiTimeout)); |
79 |
| -TypeMap.Register.New(() => new AxCryptApiClient(Resolve.KnownIdentities.DefaultEncryptionIdentity.ToRestIdentity(), Resolve.UserSettings.RestApiBaseUrl, Resolve.UserSettings.ApiTimeout)); |
80 | 96 | TypeMap.Register.New<ISystemCryptoPolicy>(() => new ProCryptoPolicy());
|
81 |
| -TypeMap.Register.New<ICryptoPolicy>(() => New<LicensePolicy>().Capabilities.CryptoPolicy); |
82 | 97 |
|
83 | 98 | TypeMap.Register.Singleton<IReport>(() => new Report(Resolve.WorkFolder.FileInfo.FullName, 1000000));
|
84 | 99 | TypeMap.Register.Singleton(() => TimeProvider.System);
|
85 | 100 | TypeMap.Register.Singleton<INow>(() => new TimeProviderNow());
|
86 |
| -TypeMap.Register.New<string, IFileWatcher>((path) => new FileWatcher()); |
87 | 101 |
|
88 | 102 | // Avoid JSON deserialization errors when the user settings file is empty.
|
89 | 103 | IDataStore settings = Resolve.WorkFolder.FileInfo.FileItemInfo("UserSettings.txt");
|
|
93 | 107 | }
|
94 | 108 | TypeMap.Register.Singleton<ISettingsStore>(() => new SettingsStore(settings));
|
95 | 109 |
|
96 |
| -TypeMap.Register.Singleton<IUIThread>(() => new UIThread()); |
97 | 110 | TypeMap.Register.Singleton(() => new ConsoleOut(Console.Error));
|
98 | 111 | TypeMap.Register.Singleton<IEmailParser>(() => new EmailParser());
|
99 | 112 | TypeMap.Register.Singleton(() => new Splash(Resource.splash));
|
|
0 commit comments