Esempio n. 1
0
        public EditRole(string serviceTitle, MultiHostConfiguration multiHostConfiguration, string multiHostConfigurationFilePath)
        {
            _serviceTitle                   = serviceTitle;
            _multiHostConfiguration         = multiHostConfiguration;
            _multiHostConfigurationFilePath = multiHostConfigurationFilePath;

            RoleConfiguration = _multiHostConfiguration.Roles.Single(x => x.Title == _serviceTitle);
        }
Esempio n. 2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            try
            {
                MultiHostConfigurationFilePath = null;

                if (e.Args.Length != 1)
                {
                    var d = new OpenFileDialog();
                    d.Title           = "LightBlue MultiHost: please select multi-host configuration file (.json)";
                    d.Filter          = "MultiHost Configuration Files (.json)|*.json";
                    d.CheckFileExists = true;
                    if (d.ShowDialog().GetValueOrDefault())
                    {
                        MultiHostConfigurationFilePath = d.FileName;
                    }
                }
                else
                {
                    MultiHostConfigurationFilePath = e.Args.Single();
                }

                if (string.IsNullOrWhiteSpace(MultiHostConfigurationFilePath))
                {
                    Configuration = new MultiHostConfiguration
                    {
                        Roles = new[]
                        {
                            new RoleConfiguration {
                                Title = "Demo Web Site", RoleName = "WebRole"
                            },
                            new RoleConfiguration
                            {
                                Title             = "Demo Web Site 2",
                                RoleName          = "WebRole",
                                RoleIsolationMode = "AppDomain"
                            },
                            new RoleConfiguration {
                                Title = "Demo Domain", RoleName = "CommandProcessor"
                            },
                            new RoleConfiguration
                            {
                                Title             = "Demo Domain 2",
                                RoleName          = "ReadModelPopulator",
                                RoleIsolationMode = "AppDomain"
                            }
                        },
                    };
                }
                else
                {
                    var configDir = Path.GetDirectoryName(MultiHostConfigurationFilePath);
                    var json      = File.ReadAllText(MultiHostConfigurationFilePath);
                    Configuration = JsonConvert.DeserializeObject <MultiHostConfiguration>(json);

                    foreach (var c in Configuration.Roles)
                    {
                        c.ConfigurationPath = Path.GetFullPath(Path.Combine(configDir, c.ConfigurationPath));
                        c.Assembly          = Path.GetFullPath(Path.Combine(configDir, c.Assembly));
                    }

                    var query =
                        from c in Configuration.Roles
                        let relativePath = c.Assembly.ToLowerInvariant().EndsWith(".dll") ||
                                           c.Assembly.ToLowerInvariant().EndsWith(".exe")
                            ? Path.GetDirectoryName(c.Assembly)
                            : c.Assembly
                                           select relativePath;

                    var assemblyLocations = query.ToArray();

                    ThreadRunnerAssemblyCache.Initialise(assemblyLocations);
                    IisExpressHelper.KillIisExpressProcesses();
                    LightBlueConfiguration.SetAsMultiHost();
                }

                base.OnStartup(e);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could not start multi-host: " + ex.ToTraceMessage());
            }
        }