public SS14Server(ICommandLineArgs args) { var assemblies = new List <Assembly>(); string assemblyDir = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath); assemblies.Add(Assembly.LoadFrom(Path.Combine(assemblyDir, "SS14.Server.Services.dll"))); IoCManager.AddAssemblies(assemblies); IoCManager.Resolve <ISS14Server>().SetServerInstance(this); //Init serializer var serializer = IoCManager.Resolve <ISS14Serializer>(); Runlevel = RunLevel.Init; _singleton = this; var configMgr = IoCManager.Resolve <IServerConfigurationManager>(); configMgr.Initialize(PathHelpers.ExecutableRelativeFile("server_config.xml")); string logPath = configMgr.LogPath; if (!Path.IsPathRooted(logPath)) { logPath = PathHelpers.ExecutableRelativeFile(logPath); } LogManager.Initialize(logPath, configMgr.LogLevel); TickRate = IoCManager.Resolve <IServerConfigurationManager>().TickRate; ServerRate = 1000.0f / TickRate; }
public static IFileAggregateReportProcessor Create(ICommandLineArgs commandLineArgs) { return(new ServiceCollection() .AddSingleton(commandLineArgs) .AddTransient <IFileAggregateReportProcessor, FileAggregateReportProcessor>() .AddTransient <IAggregateReportParser, AggregateReportParser>() .AddTransient <IMimeMessageFactory, MimeMessageFactory>() .AddTransient <IAttachmentStreamNormaliser, AttachmentStreamNormaliser>() .AddTransient <IAggregateReportDeserialiser, AggregateReportDeserialiser>() .AddTransient <IContentTypeProvider, ContentTypeProvider>() .AddTransient <IGZipDecompressor, GZipDecompressor>() .AddTransient <IZipDecompressor, ZipDecompressor>() .AddTransient <IReportMetadataDeserialiser, ReportMetadataDeserialiser>() .AddTransient <IPolicyPublishedDeserialiser, PolicyPublishedDeserialiser>() .AddTransient <IRecordDeserialiser, RecordDeserialiser>() .AddTransient <IDomainValidator, DomainValidator>() .AddTransient <IRowDeserialiser, RowDeserialiser>() .AddTransient <IIdentifiersDeserialiser, IdentifiersDeserialiser>() .AddTransient <IAuthResultDeserialiser, AuthResultDeserialiser>() .AddTransient <IPolicyEvaluatedDeserialiser, PolicyEvaluatedDeserialiser>() .AddTransient <IPolicyOverrideReasonDeserialiser, PolicyOverrideReasonDeserialiser>() .AddTransient <IDkimAuthResultDeserialiser, DkimAuthResultDeserialiser>() .AddTransient <ISpfAuthResultDeserialiser, SpfAuthResultDeserialiser>() .AddTransient <IAggregateReportPersistorComposite, AggregateReportPersistorComposite>() .AddTransientConditional <IAggregateReportPersistor, DenormalisedRecordPersistorAdaptor>(commandLineArgs.CsvFile != null || commandLineArgs.SqlFile != null) .AddTransientConditional <IDenormalisedRecordPersistorComposite, DenormalisedRecordPersistorComposite>(commandLineArgs.CsvFile != null || commandLineArgs.SqlFile != null) .AddTransientConditional <ICsvDenormalisedRecordSerialiser, CsvDenormalisedRecordSerialiser>(commandLineArgs.CsvFile != null) .AddTransientConditional <IAggregateReportPersistor, XmlAttachmentPersistor>(commandLineArgs.XmlDirectory != null) .AddTransientConditional <IDenormalisedRecordPersistor, CsvPersistor>(commandLineArgs.CsvFile != null) .AddTransientConditional <IDenormalisedRecordPersistor, SqlLitePersistor>(commandLineArgs.SqlFile != null) .AddSerilogLogging() .BuildServiceProvider() .GetRequiredService <IFileAggregateReportProcessor>()); }
public CsvPersistor( ICommandLineArgs args, ICsvDenormalisedRecordSerialiser csvDenormalisedRecordSerialiser) { _args = args; _csvDenormalisedRecordSerialiser = csvDenormalisedRecordSerialiser; }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); commandLineArgs = new CommandLineArgs(e.Args); ViewManager.SetImplementation(new DefaultViewManager(t => kernel.Get(t))); var splashVM = new SplashScreenVM(); ViewManager.ShowWindow(splashVM); // in order to ensure the UI stays responsive, we need to // do the work on a different thread Task.Factory.StartNew(() => { ConfigureContainer(splashVM); Dispatcher.Invoke(() => { ViewManager.ShowWindow <MainVM>(); splashVM.Close(); }); }); Dispatcher.UnhandledException += (s, ea) => { string message = $"An unhandled exception occurred:\n\n{ea.Exception.Message}\nStack trace:\n\n{ea.Exception.StackTrace}"; Trace.TraceError(message); ViewManager.ShowMessageBox("Error", message, MessageBoxButton.OK); ea.Handled = true; }; }
/// <summary> /// Try to parse command line arguments /// </summary> /// <param name="args">The arguments to parse.</param> /// <param name="result">The parsed result if successful. Null if parse failed.</param> /// <returns><c>true</c> if arguments were successfully parsed, <c>false</c> otherwise.</returns> public virtual bool TryParse(string[] args, out ICommandLineArgs result) { if (args == null || args.Length == 0) { result = null; return(false); } result = Parse(args); return(result != null); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); commandLineArgs = new CommandLineArgs(e.Args); ViewManager.SetImplementation(new DefaultViewManager(t => kernel.Get(t))); Log.SetImplementation((DefaultLogger)LogManager.GetLogger("", typeof(DefaultLogger))); if (commandLineArgs.Contains("-debug", StringComparer.OrdinalIgnoreCase)) { Log.Level = "Debug"; } Log.Info($"Starting Astrarium {FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion}"); var splashVM = new SplashScreenVM(); ViewManager.ShowWindow(splashVM); // in order to ensure the UI stays responsive, we need to // do the work on a different thread Task.Factory.StartNew(() => { ConfigureContainer(splashVM); Dispatcher.Invoke(() => { ViewManager.ShowWindow <MainVM>(); splashVM.Close(); }); }); Dispatcher.UnhandledException += (s, ea) => { string message = $"An unhandled exception occurred:\n\n{ea.Exception.Message}\nStack trace:\n\n{ea.Exception.StackTrace}"; Log.Error(message); ViewManager.ShowMessageBox("Error", message, MessageBoxButton.OK); ea.Handled = true; }; }
private static void HandleArgs(string[] args) { //TODO parse args Logger.LogInfo("Parsing CommandLine Args"); commandLineArgs = new CommandLineArgs(); try { if (!args.Any()) { } else if (args.Any(x => x.StartsWith("-h"))) { Logger.LogInfo(HelpText); } if (args.Any(x => x.StartsWith("-f"))) { var files = args.FirstOrDefault(x => x.Contains("-f"))?.Split('=', ','); files = files.Where(x => x != "-f" && x != "=").ToArray(); commandLineArgs.FilesToProcess = files; } if (args.Any(x => x.StartsWith("-w"))) { var wDir = args.FirstOrDefault(x => x.Contains("-w"))?.Split('='); var dir = wDir.FirstOrDefault(x => x != "-w" && x != "="); commandLineArgs.WorkingDir = dir; } if (args.Any(x => x.StartsWith("-o"))) { var oDir = args.FirstOrDefault(x => x.Contains("-o"))?.Split('='); var dir = oDir.FirstOrDefault(x => x != "-o" && x != "="); commandLineArgs.OutputLocation = dir; } } catch (Exception ex) { Logger.LogError("Got an invalid Command Line argument", ex); } }
public CommandLineConfigurationProvider(ICommandLineArgs args) { this.m_Args = args; }
public CommandLineConfigurationSource(ICommandLineArgs args) { _args = args; }
public SqlLitePersistor(ICommandLineArgs commandLineArgs) { _commandLineArgs = commandLineArgs; }
public CommandLine(ICommandLineArgs commandLineArgs, IConsole console) { _commandLineArgs = commandLineArgs; _console = console; }
public Worker(ICommandLineArgs commandLineArgs) { this.commandLineArgs = commandLineArgs; csvRows = new List <PlotPOLCNTOutput>(); }
public SkyMap(ISettings settings, ICommandLineArgs commandLineArgs) { this.settings = settings; this.commandLineArgs = commandLineArgs; }
public XmlAttachmentPersistor(ICommandLineArgs commandLineArgs) { _commandLineArgs = commandLineArgs; }