SEBWIN-219: Minor refactoring.

This commit is contained in:
dbuechel 2018-03-14 11:13:30 +01:00
parent be761fd72c
commit 6334294e4d
3 changed files with 17 additions and 5 deletions

View file

@ -82,11 +82,13 @@ namespace SafeExamBrowser.Browser
{ {
var instance = new BrowserApplicationInstance(settings, text, uiFactory, instances.Count == 0); var instance = new BrowserApplicationInstance(settings, text, uiFactory, instances.Count == 0);
instance.Initialize();
instance.ConfigurationDetected += Instance_ConfigurationDetected;
instance.Terminated += Instance_Terminated;
button.RegisterInstance(instance); button.RegisterInstance(instance);
instances.Add(instance); instances.Add(instance);
instance.ConfigurationDetected += Instance_ConfigurationDetected;
instance.Terminated += Instance_Terminated;
instance.Window.Show(); instance.Window.Show();
} }

View file

@ -19,6 +19,10 @@ namespace SafeExamBrowser.Browser
{ {
private IBrowserControl control; private IBrowserControl control;
private IBrowserWindow window; private IBrowserWindow window;
private bool isMainInstance;
private BrowserSettings settings;
private IText text;
private IUserInterfaceFactory uiFactory;
public Guid Id { get; private set; } public Guid Id { get; private set; }
public string Name { get; private set; } public string Name { get; private set; }
@ -29,10 +33,17 @@ namespace SafeExamBrowser.Browser
public event NameChangedEventHandler NameChanged; public event NameChangedEventHandler NameChanged;
public BrowserApplicationInstance(BrowserSettings settings, IText text, IUserInterfaceFactory uiFactory, bool isMainInstance) public BrowserApplicationInstance(BrowserSettings settings, IText text, IUserInterfaceFactory uiFactory, bool isMainInstance)
{
this.isMainInstance = isMainInstance;
this.settings = settings;
this.text = text;
this.uiFactory = uiFactory;
}
internal void Initialize()
{ {
Id = Guid.NewGuid(); Id = Guid.NewGuid();
// TODO: Move to initialize method!
control = new BrowserControl(settings, text); control = new BrowserControl(settings, text);
control.AddressChanged += Control_AddressChanged; control.AddressChanged += Control_AddressChanged;
(control as BrowserControl).ConfigurationDetected += (url, args) => ConfigurationDetected?.Invoke(url, args); (control as BrowserControl).ConfigurationDetected += (url, args) => ConfigurationDetected?.Invoke(url, args);

View file

@ -137,8 +137,7 @@ namespace SafeExamBrowser.Runtime.Behaviour
return false; return false;
} }
logger.Info("Client has been successfully started and initialized."); logger.Info("Client has been successfully started and initialized. Creating communication proxy for client host...");
logger.Info("Creating communication proxy for client host...");
configuration.CurrentSession.ClientProxy = proxyFactory.CreateClientProxy(configuration.RuntimeInfo.ClientAddress); configuration.CurrentSession.ClientProxy = proxyFactory.CreateClientProxy(configuration.RuntimeInfo.ClientAddress);
if (!configuration.CurrentSession.ClientProxy.Connect(configuration.CurrentSession.StartupToken)) if (!configuration.CurrentSession.ClientProxy.Connect(configuration.CurrentSession.StartupToken))