protected ViewModelFactory(Autofac.ILifetimeScope container, IFrozenContext frozenCtx, ZetboxConfig cfg, IPerfCounter perfCounter, Func <DialogCreator> dialogFactory) { if (container == null) { throw new ArgumentNullException("container"); } if (frozenCtx == null) { throw new ArgumentNullException("frozenCtx"); } if (cfg == null) { throw new ArgumentNullException("cfg"); } if (dialogFactory == null) { throw new ArgumentNullException("dialogFactory"); } this.Container = container; this.FrozenContext = frozenCtx; this.Configuration = cfg; this.Managers = new Dictionary <IZetboxContext, IMultipleInstancesManager>(); this._viewModelFactoryCache = new Dictionary <VMCacheKey, object>(); this.PerfCounter = perfCounter; this.DialogFactory = dialogFactory; }
public WcfServer(AutofacServiceHostFactory factory, AutofacWebServiceHostFactory webFactory, ZetboxConfig config) { if (factory == null) { throw new ArgumentNullException("factory"); } if (webFactory == null) { throw new ArgumentNullException("webFactory"); } if (config == null) { throw new ArgumentNullException("config"); } _defaultConfig = config; _mainHost = factory.CreateServiceHost(typeof(ZetboxService).AssemblyQualifiedName, new Uri[] { }); _mainHost.UnknownMessageReceived += new EventHandler <UnknownMessageReceivedEventArgs>(host_UnknownMessageReceived); _mainHost.Faulted += host_Faulted; _mainHost.Closed += host_Closed; _mainHost.Opened += host_Opened; _bootstrapperHost = webFactory.CreateServiceHost(typeof(BootstrapperService).AssemblyQualifiedName, new Uri[] { }); }
public override void SetUp() { base.SetUp(); config = scope.Resolve <ZetboxConfig>(); DeleteData(); CreateTestData(); }
public SchemaManager(ISchemaProvider provider, IZetboxContext schema, IZetboxContext savedSchema, ZetboxConfig config) { this.config = config; this.schema = schema; this.db = provider; this.Case = new Cases(schema, provider, savedSchema); }
/// <summary> /// Starts the WCF Server in the background. If the server hasn't /// started successfully within 40 seconds, it is aborted and an /// <see cref="InvalidOperationException"/> is thrown. /// </summary> /// <param name="config">the loaded configuration for the Server</param> public void Start(ZetboxConfig config) { if (config == null) { throw new ArgumentNullException("config"); } if (config.AdditionalCommandlineOptions.ContainsKey(ServerModule.NoWcfKey)) { Log.Info("Not starting embedded WCF Server. As requested by -nowcf."); } else { using (Log.InfoTraceMethodCall("Starting Server")) { serviceThread = new Thread(new ThreadStart(this.RunWCFServer)); serviceThread.Start(); if (!serverStarted.WaitOne(40 * 1000, false)) { throw new InvalidOperationException("Server did not start within 40 sec."); } } } }
public FileViewModel( IViewModelDependencies appCtx, ZetboxConfig config, IZetboxContext dataCtx, ViewModel parent, File obj) : base(appCtx, dataCtx, parent, obj) { this.File = obj; }
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; }
protected virtual ZetboxConfig ReadConfig(List <string> extraArguments) { string configFilePath = null; if (extraArguments == null || extraArguments.Count == 0) { configFilePath = String.Empty; } else if (extraArguments.Count == 1) { configFilePath = extraArguments[0]; } else { Logging.MailNotification.FatalFormat("Unerkannte Argumente: [{0}]", String.Join("], [", extraArguments.ToArray())); PrintHelpAndExit(); } try { return(ZetboxConfig.FromFile(configFilePath, "")); } catch (Exception ex) { Logging.MailNotification.Fatal(String.Format("Fehler beim Lesen der Config von [{0}]", configFilePath), ex); PrintHelpAndExit(); } // never reached return(null); }
public static void EnsureInitialisation(ZetboxConfig config) { if (config == null) { throw new ArgumentNullException("config"); } lock (_lock) { if (_isInitialised) { return; } _isInitialised = true; if (config.AssemblySearchPaths == null) { Log.Info("Not initialising: no AssemblySearchPaths set."); return; } Log.DebugFormat("Initializing {0}", AppDomain.CurrentDomain.FriendlyName); InitialiseTargetAssemblyFolder(config); InitialiseSearchPath(config.AssemblySearchPaths.Paths); // Start resolving Assemblies AppDomain.CurrentDomain.AssemblyResolve += AssemblyLoader.AssemblyResolve; AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += AssemblyLoader.ReflectionOnlyAssemblyResolve; } }
public Launcher(Func <ClientIsolationLevel, IZetboxContext> ctxFactory, IViewModelFactory mdlFactory, IFrozenContext frozenCtx, ZetboxConfig cfg, IPerfCounter perfCounter) { this.frozenCtx = frozenCtx; this.ctxFactory = ctxFactory; this.mdlFactory = mdlFactory; this.cfg = cfg; this.perfCounter = perfCounter; }
public BootstrapperService(ZetboxConfig config) { if (config == null) { throw new ArgumentNullException("config"); } Log.InfoFormat("Starting BootstrapperService from {0}", config.ConfigFilePath); this.config = config; }
protected virtual IContainer CreateMasterContainer(ZetboxConfig config) { var builder = AutoFacBuilder.CreateContainerBuilder(config, config.Server.Modules); ConfigureBuilder(builder); // register deployment-specific components builder.RegisterModule(new ConfigurationSettingsReader("migrationcomponents")); return(builder.Build()); }
/// <summary> /// Internal Constructor /// </summary> public EfDataContext(IMetaDataResolver metaDataResolver, Identity identity, ZetboxConfig config, Func <IFrozenContext> lazyCtx, InterfaceType.Factory iftFactory, EfImplementationType.EfFactory implTypeFactory, IPerfCounter perfCounter) : base(metaDataResolver, identity, config, lazyCtx, iftFactory) { if (perfCounter == null) { throw new ArgumentNullException("perfCounter"); } _ctx = new EfObjectContext(config); _implTypeFactory = implTypeFactory; _perfCounter = perfCounter; }
internal static IContainer CreateMasterContainer(ZetboxConfig config) { var builder = Zetbox.API.Utils.AutoFacBuilder.CreateContainerBuilder(config, config.Server.Modules); // register deployment-specific components builder.RegisterModule(new ConfigurationSettingsReader("servercomponents")); var container = builder.Build(); AutofacServiceHostFactory.Container = container; return(container); }
public TreeItemInstanceListViewModel( IViewModelDependencies appCtx, ZetboxConfig config, IFileOpener fileOpener, ITempFileService tmpService, IZetboxContext dataCtx, ViewModel parent, Func <IZetboxContext> workingCtxFactory, ObjectClass type, Func <IQueryable> qry) : base(appCtx, config, fileOpener, tmpService, dataCtx, parent, workingCtxFactory, type, qry) { }
/// <summary> /// Creates the Connectionstring. /// <remarks>Format is: metadata=res://*;provider={provider};provider connection string='{Provider Connectionstring}'</remarks> /// </summary> /// <returns></returns> private static string BuildConnectionString(ZetboxConfig config) { // Build connectionString // metadata=res://*;provider=System.Data.SqlClient;provider connection string='Data Source=.\SQLEXPRESS;Initial Catalog=Zetbox;Integrated Security=True;MultipleActiveResultSets=true;' var connectionString = config.Server.GetConnectionString(Zetbox.API.Helper.ZetboxConnectionStringKey); StringBuilder sb = new StringBuilder(); sb.AppendFormat("metadata=res://Zetbox.Objects.EfImpl/Zetbox.Objects.EfImpl.Model.csdl|res://Zetbox.Objects.EfImpl/Zetbox.Objects.EfImpl.Model.msl|res://Zetbox.Objects.EfImpl/Zetbox.Objects.EfImpl.Model.{0}.ssdl;", connectionString.SchemaProvider); sb.AppendFormat("provider={0};", connectionString.DatabaseProvider); sb.AppendFormat("provider connection string='{0}'", connectionString.ConnectionString); return(sb.ToString()); }
void CreateMasterContainer(ZetboxConfig config) { var builder = Zetbox.API.Utils.AutoFacBuilder.CreateContainerBuilder(config, config.Server.Modules); // register deployment-specific components builder.RegisterModule(new ConfigurationSettingsReader("servercomponents")); // Store root container for WCF & ASP.NET var container = builder.Build(); AutofacHostFactory.Container = container; _containerProvider = new ContainerProvider(container); }
private static void InitCulture(ZetboxConfig config) { if (config.Client == null) { return; } if (!string.IsNullOrEmpty(config.Client.Culture)) { System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo(config.Client.Culture); } if (!string.IsNullOrEmpty(config.Client.UICulture)) { System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo(config.Client.UICulture); } }
public SimpleCmdLineAction(ZetboxConfig config, string prototype, string description, Action <ILifetimeScope, string> action) : base(config, prototype, description, 1) { _listAction = (scope, args) => { if (args.Length == 0) { action(scope, null); } else { args.ForEach(arg => action(scope, arg)); } }; }
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); }
private IContainer CreateMasterContainer(ZetboxConfig config) { var builder = Zetbox.API.Utils.AutoFacBuilder.CreateContainerBuilder(config, config.Client.Modules); builder .RegisterType <Launcher>() .SingleInstance(); builder .Register <Zetbox.Client.WPF.Toolkit.VisualTypeTemplateSelector>((c, p) => new Zetbox.Client.WPF.Toolkit.VisualTypeTemplateSelector( p.Named <object>("requestedKind"), c.Resolve <IFrozenContext>())) .InstancePerDependency(); return(builder.Build()); }
public void CheckSchema(bool withRepair) { using (Log.InfoTraceMethodCallFormat("CheckSchema", "withRepair=[{0}]", withRepair)) using (var subContainer = container.BeginLifetimeScope()) { IZetboxContext ctx = subContainer.Resolve <BaseMemoryContext>(); ZetboxConfig cfg = subContainer.Resolve <ZetboxConfig>(); var connectionString = cfg.Server.GetConnectionString(Zetbox.API.Helper.ZetboxConnectionStringKey); ISchemaProvider schemaProvider = subContainer.ResolveNamed <ISchemaProvider>(connectionString.SchemaProvider); schemaProvider.Open(connectionString.ConnectionString); SchemaManagement.SchemaManager.LoadSavedSchemaInto(schemaProvider, ctx); var mgr = subContainer.Resolve <SchemaManagement.SchemaManager>(new NamedParameter("newSchema", ctx)); mgr.CheckSchema(withRepair); } }