private void Initialize() { Logging.Configure(); Log.InfoFormat("Starting Migration for [{0}] with arguments [{1}]", _name, String.Join("], [", _arguments)); _options = CreateOptionSet(); List <string> extraArguments = null; try { extraArguments = _options.Parse(_arguments); } catch (OptionException e) { Logging.MailNotification.Fatal("Error in commandline", e); PrintHelpAndExit(); } _config = ReadConfig(extraArguments); AssemblyLoader.Bootstrap(AppDomain.CurrentDomain, _config); _container = CreateMasterContainer(_config); _applicationScope = _container.BeginLifetimeScope(); ValidateConfig(); _isInitialized = true; }
public void Start(ZetboxConfig config) { if (container != null) { throw new InvalidOperationException("already started"); } Logging.Configure(); AssemblyLoader.Bootstrap(AppDomain.CurrentDomain, config); container = Program.CreateMasterContainer(config); wcfServer = container.Resolve <IZetboxAppDomain>(); wcfServer.Start(config); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); try { if (System.Configuration.ConfigurationManager.AppSettings["ShowDebugConsole"] == "true") { DebugConsole.Show(); } Logging.Configure(); using (Logging.Log.InfoTraceMethodCall("Starting Client")) { string configFilePath; var args = HandleCommandline(e.Args, out configFilePath); var config = ZetboxConfig.FromFile(configFilePath, "Zetbox.WPF.xml"); AssemblyLoader.Bootstrap(AppDomain.CurrentDomain, config); InitCulture(config); InitializeClient(args, config); } } catch (Exception ex) { ShowExceptionReporter(ex); // unable to start, exit System.Environment.Exit(1); } // The WPFToolkit library is not translated and does not support changeing the DateTimePickerTextbox.Watermark. // Therefore, we have to replace the underlying ResourceManager. try { var srType = typeof(Microsoft.Windows.Controls.DatePicker).Assembly.GetTypes().Single(t => t.Name == "SR"); var resourceManagerField = srType.GetField("_resourceManager", BindingFlags.Static | BindingFlags.NonPublic); resourceManagerField.SetValue(null, WpfToolkitResources.ResourceManager); } catch (Exception /* ex */) { // ignore this //ShowExceptionReporter(ex); } }
void context_BeginRequest(object sender, EventArgs e) { if (container == null) { Logging.Configure(); var config = ZetboxConfig.FromFile(HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["configFile"]), "AspNet.xml"); AssemblyLoader.Bootstrap(AppDomain.CurrentDomain, config); var builder = Zetbox.API.Utils.AutoFacBuilder.CreateContainerBuilder(config, config.Client.Modules); container = builder.Build(); ViewModelFactory = container.Resolve <IViewModelFactory>(); IftFactory = container.Resolve <InterfaceType.Factory>(); } ZetboxContext = container.Resolve <IZetboxContext>(); }
public void SetUpTestFixture() { using (Log.InfoTraceMethodCall("EarlySetup")) { EarlySetup(); } using (Log.InfoTraceMethodCall("Starting up")) { var config = ZetboxConfig.FromFile(null, GetConfigFile()); AssemblyLoader.Bootstrap(AppDomain.CurrentDomain, config); ContainerBuilder builder; switch (GetHostType()) { case HostType.Server: Log.Info("Adding Server Modules"); builder = Zetbox.API.Utils.AutoFacBuilder.CreateContainerBuilder(config, config.Server.Modules); break; case HostType.Client: Log.Info("Adding Client Modules"); builder = Zetbox.API.Utils.AutoFacBuilder.CreateContainerBuilder(config, config.Client.Modules); break; case HostType.None: Log.Info("Adding no Modules"); builder = Zetbox.API.Utils.AutoFacBuilder.CreateContainerBuilder(config); break; default: throw new InvalidOperationException("GetHostType() returned an unknown type"); } // TODO: totally replace this with test mocks? Log.Info("Adding Interface Module"); builder.RegisterModule <Zetbox.Objects.InterfaceModule>(); builder.RegisterInstance <TypeMapAssembly>(new TypeMapAssembly(this.GetType().Assembly)); SetupBuilder(builder); container = builder.Build(); SetUp(container); } }
static void Main() { var config = ZetboxConfig.FromFile(null, "DefaultFormsConfig.xml"); AssemblyLoader.Bootstrap(AppDomain.CurrentDomain, config); var builder = Zetbox.API.Utils.AutoFacBuilder.CreateContainerBuilder(config, config.Client.Modules); container = builder.Build(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var mdlFactory = container.Resolve <IViewModelFactory>(); var initialWorkspace = mdlFactory.CreateViewModel <WorkspaceViewModel.Factory>().Invoke(container.Resolve <IZetboxContext>(), null); mdlFactory.ShowModel(initialWorkspace, true); Application.Run(); }
protected void Application_Start(object sender, EventArgs e) { Logging.Configure(); Log.Info("Starting HttpService Application"); var cfgFile = System.Configuration.ConfigurationManager.AppSettings["ConfigFile"]; var appBasePath = Server.MapPath("~/"); var zbBasePath = Path.Combine(appBasePath, ".."); var configsPath = Path.Combine(zbBasePath, "Configs"); var config = ZetboxConfig.FromFile( string.IsNullOrEmpty(cfgFile) ? string.Empty : Server.MapPath(cfgFile), ZetboxConfig.GetDefaultConfigName("Zetbox.Server.HttpService.xml", configsPath)); // Make DocumentStore relative to HttpService config.Server.DocumentStore = Path.Combine(appBasePath, config.Server.DocumentStore); AssemblyLoader.Bootstrap(AppDomain.CurrentDomain, config); CreateMasterContainer(config); }
public void Start(ZetboxConfig config) { using (Logging.Log.DebugTraceMethodCall("Start", "Starting AppDomain for Server")) { serverDomain = AppDomain.CreateDomain("ServerAppDomain", AppDomain.CurrentDomain.Evidence, AppDomain.CurrentDomain.SetupInformation); AssemblyLoader.Bootstrap(serverDomain, config); serverManager = (IZetboxAppDomain)serverDomain.CreateInstanceAndUnwrap( "Zetbox.Server.Service", "Zetbox.Server.Service.ServerManager"); serverManager.Start(config); if (clientSponsor == null) { clientSponsor = new ClientSponsor(); clientSponsor.RenewalTime = TimeSpan.FromMinutes(2); } clientSponsor.Register(serverManager as MarshalByRefObject); } }
public static int Main(string[] arguments) { Logging.Configure(); Log.InfoFormat("Starting Zetbox Server with args [{0}]", String.Join(" ", arguments)); try { var config = ExtractConfig(ref arguments); AssemblyLoader.Bootstrap(AppDomain.CurrentDomain, config); using (var container = CreateMasterContainer(config)) { OptionSet options = new OptionSet(); // activate all registered options container.Resolve <IEnumerable <Option> >().OrderBy(o => o.Prototype).ForEach(o => options.Add(o)); List <string> extraArguments = null; try { extraArguments = options.Parse(arguments); } catch (OptionException e) { Log.Fatal("Error in commandline", e); return(1); } if (extraArguments != null && extraArguments.Count > 0) { Log.FatalFormat("Unrecognized arguments on commandline: {0}", string.Join(", ", extraArguments.ToArray())); return(1); } var actions = config.AdditionalCommandlineActions; // process command line if (actions.Count > 0) { using (Log.DebugTraceMethodCall("CmdLineActions", "processing commandline actions")) { foreach (var action in actions) { using (var innerContainer = container.BeginLifetimeScope()) { action(innerContainer); } } } Log.Info("Shutting down"); } else { IServiceControlManager scm = null; if (container.TryResolve <IServiceControlManager>(out scm)) { Log.Info("Starting zetbox Services"); scm.Start(); Log.Info("Waiting for console input to shutdown"); Console.WriteLine("Services started, press the anykey to exit"); Console.ReadKey(); Log.Info("Shutting down"); } else { Log.Error("No IServiceControlManager registered"); } if (scm != null) { scm.Stop(); } } } Log.Info("Exiting"); return(0); } catch (Exception ex) { Log.Error("Server Application failed:", ex); return(1); } }