protected override void Load(ContainerBuilder builder) { builder.RegisterSettingsManager(c => c.WithProvider <LocalConfigurationProvider>()); builder.RegisterType <LocalConfiguration>().As <ILocalConfiguration>().SingleInstance(); builder.Register(c => c.Resolve <IEventAggregator>().GetEvent <ConfigEventDispatcher, IConfigEvent>()).SingleInstance(); builder.RegisterType <ClusterConnectionTracker>().As <IClusterConnectionTracker>().SingleInstance(); builder.RegisterType <DatabaseConfig>().As <IDatabaseConfig>().SingleInstance(); builder.RegisterType <ServerConfigurationApi>().As <IServerConfigurationApi>().SingleInstance(); builder.RegisterType <PropertyChangedNotifer>().As <IPropertyChangedNotifer>().SingleInstance(); builder.RegisterFeature <ClusterNodeManagerRef, IClusterNodeManager>(ClusterHostManagerActor.New()); builder.RegisterFeature <ApiEventDispatcherRef, IApiEventDispatcher>(ApiEventDispatcherActor.New()); builder.RegisterFeature <ProcessServiceHostRef, IProcessServiceHost>(ProcessServiceHostActor.New()); builder.Register(c => DeploymentApi.CreateProxy(c.Resolve <ActorSystem>())).SingleInstance(); builder.Register(c => RepositoryApi.CreateProxy(c.Resolve <ActorSystem>())).SingleInstance(); builder.Register(c => ConfigurationApi.CreateProxy(c.Resolve <ActorSystem>())).SingleInstance(); builder.RegisterStartUpAction <ActorStartUp>(); base.Load(builder); }
//TODO Refactor for StateManager public SetupBuilderViewModel(ILifetimeScope lifetimeScope, Dispatcher dispatcher, AppConfig config, DeploymentServices deploymentServices, IActionInvoker actionInvoker) : base(lifetimeScope, dispatcher, actionInvoker) { _config = config; _server = new SetupServer(s => UICall(() => TerminalLines !.Add(s)), Context.System.Settings.Config); _deploymentApi = DeploymentApi.CreateProxy(Context.System, "SetupBuilder_DeploymentApi"); _repositoryApi = RepositoryApi.CreateProxy(Context.System, "SetupBuilder_RepositoryApi"); AddShortcut = RegisterProperty <bool>(nameof(AddShortcut)); CurrentError = RegisterProperty <string>(nameof(CurrentError)); AddSeed = RegisterProperty <bool>(nameof(AddSeed)); TerminalLines = this.RegisterUiCollection <string>(nameof(TerminalLines)).AndAsync(); var hostEntrys = new HashSet <string>(); _api = HostApi.CreateOrGet(Context.System); Receive <HostEntryChanged>(e => { if (string.IsNullOrWhiteSpace(e.Name)) { return; } if (e.Removed) { hostEntrys.Remove(e.Name); } else { hostEntrys.Add(e.Name); } }); Func <string, string?> HostNameValidator(Func <UIProperty <string> > counterPart) { return(s => { if (string.IsNullOrWhiteSpace(s)) { return LocLocalizer.Inst.SetupBuilderView.ErrorEmptyHostName; } return hostEntrys.Contains(s) || s == counterPart().Value ? LocLocalizer.Inst.SetupBuilderView.ErrorDuplicateHostName : null; }); } HostName = RegisterProperty <string>(nameof(HostName)) .WithValidator(SetError(HostNameValidator(() => SeedHostName !))) .OnChange(s => SeedHostName += s + "_Seed"); SeedHostName = RegisterProperty <string>(nameof(SeedHostName)) .WithValidator(SetError(HostNameValidator(() => HostName))); NewCommad .WithCanExecute(b => b.And( deploymentServices.IsReadyQuery(b), b.FromProperty(_buildRunning, i => i == 0), b.FromProperty(HostName.IsValid), b.Or( b.FromProperty(AddSeed, s => !s), b.FromProperty(SeedHostName.IsValid)))) .WithExecute(ExecuteBuild) .ThenRegister("CreateSeupCommand"); }