| | 1 | | using System.Reflection; |
| | 2 | | using System.Diagnostics; |
| | 3 | | using System.IO.Abstractions; |
| | 4 | | using Autofac; |
| | 5 | | using Mklinker.Abstractions; |
| | 6 | | using System.Runtime.InteropServices; |
| | 7 | |
|
| | 8 | | namespace Mklinker { |
| | 9 | |
|
| | 10 | | public static class Program { |
| | 11 | |
|
| | 12 | | public const string DEFAULT_LINKER_PATH = "linker.config"; |
| | 13 | |
|
| 0 | 14 | | public static string GetVersion() { |
| 0 | 15 | | return FileVersionInfo.GetVersionInfo(Assembly.GetAssembly(typeof (Program)).Location).ProductVersion; |
| 0 | 16 | | } |
| | 17 | |
|
| 0 | 18 | | public static void Main(string[] args) { |
| 0 | 19 | | var builder = new ContainerBuilder(); |
| | 20 | |
|
| 0 | 21 | | builder.RegisterInstance<Config>(new Config(Program.GetVersion())).As<IConfig>(); |
| | 22 | |
|
| 0 | 23 | | builder.RegisterType<FileSystem>().As<IFileSystem>(); |
| 0 | 24 | | builder.RegisterType<ConfigHandler>().As<IConfigHandler>(); |
| 0 | 25 | | builder.RegisterType<ArgumentParser>().As<IArgumentParser>(); |
| 0 | 26 | | builder.RegisterType<CommandExecutor>().As<ICommandExecutor>(); |
| 0 | 27 | | builder.RegisterType<Process>().As<IProcess>(); |
| 0 | 28 | | builder.RegisterType<Console>().As<IConsole>(); |
| 0 | 29 | | builder.RegisterType<XMLConfigSerializer>().As<IConfigSerializer>(); |
| 0 | 30 | | builder.RegisterType<PathResolver>().As<IPathResolver>(); |
| | 31 | |
|
| | 32 | | // Platform dependent |
| 0 | 33 | | if (RuntimeInformation.IsOSPlatform (OSPlatform.Windows)) { |
| 0 | 34 | | builder.RegisterType<WindowsLinker>().As<ILinker>(); |
| 0 | 35 | | } else { |
| 0 | 36 | | builder.RegisterType<UnixLinker>().As<ILinker>(); |
| 0 | 37 | | } |
| | 38 | |
|
| 0 | 39 | | using (var scope = builder.Build().BeginLifetimeScope()) { |
| 0 | 40 | | scope.Resolve<ICommandExecutor>().Execute(args); |
| 0 | 41 | | } |
| 0 | 42 | | } |
| | 43 | |
|
| | 44 | | } |
| | 45 | |
|
| | 46 | | } |