private static IResolver CreateResolver() { // Step 1 - Create a logger. var log = NLogWrapper.GetLog("Default"); // Step 2 - Create a container. var container = new TactContainer(log); // Step 3 - Read and aggregate configuration files. var config = container.BuildConfiguration(cb => cb.AddJsonFile("AppSettings.json")); // Step 4 - Load assemblies from the configuration. var assemblies = config.LoadAssembliesFromConfig(); // Step 5 - Create and validate configuration objects. container.ConfigureByAttribute(config, assemblies); // Step 6 - Register services by reflection using attributes. container.RegisterByAttribute(assemblies); // Step 7 - Initialize / start services in the container. container.InitializeByAttribute(assemblies); return(container); }
public static int Main(string[] args) { // Determine what mode the application is running in. if (!Enum.TryParse(args.FirstOrDefault() ?? "Both", out AppMode appMode)) { var modes = string.Join(", ", Enum.GetNames(typeof(AppMode))); Console.WriteLine($"First argument must specify a mode: {modes}"); return(-1); } // Step 1 - Create a logger. var log = NLogWrapper.GetLog("Default"); // Step 2 - Create a container. using (var container = new TactContainer(log)) { // Step 3 - Read and aggregate configuration files. var config = container.BuildConfiguration(cb => cb .AddJsonFile("AppSettings.json") .AddJsonFile($"AppSettings.{appMode}.json")); // Step 4 - Load assemblies from the configuration. var assemblies = config.LoadAssembliesFromConfig(); // Step 5 - Create and validate configuration objects. container.ConfigureByAttribute(config, assemblies); // Step 6 - Register services by reflection using attributes. container.RegisterByAttribute(assemblies); // Step 7 - Initialize / start services in the container. container.InitializeByAttribute(assemblies); // Wait for the user to press enter to exit the application. TestApplication(container, appMode).Wait(); } return(0); }