public void Initialize() { ("Extension Manager Initialize").Log(); Mubox.Control.Network.Server.ClientAccepted += Server_ClientAccepted; Mubox.Control.Network.Server.ClientRemoved += Server_ClientRemoved; // TODO: additionally, we may want to raise an event to extensions when the active profile changes foreach (var L_profile in Mubox.Configuration.MuboxConfigSection.Default.Profiles.Cast <Mubox.Configuration.ProfileSettings>()) { L_profile.ActiveClientChanged += ActiveClientChanged; } var extensionsPath = Path.Combine(Environment.CurrentDirectory); var files = System.IO.Directory.EnumerateFiles(extensionsPath, "ext.*.dll"); foreach (var file in files) { file.LogInfo(); var friendlyName = Path.GetFileNameWithoutExtension(file); var appDomain = AppDomain.CreateDomain(friendlyName); var bridge = new Extensibility.MuboxBridge(this); var loader = (Extensibility.Loader)appDomain .CreateInstanceAndUnwrap("Mubox.Extensibility", "Mubox.Extensibility.Loader"); _clients .ToList() .ForEach(bridge.Clients.Add); var extensionState = new ExtensionState() { Name = friendlyName, AppDomain = appDomain, Loader = loader, Bridge = bridge, }; _extensions.Add(extensionState.Name, extensionState); // actual extension load and initializes at this point loader.Initialize(bridge, file); } }
public void Initialize() { ("Extension Manager Initialize").Log(); Mubox.Control.Network.Server.ClientAccepted += Server_ClientAccepted; Mubox.Control.Network.Server.ClientRemoved += Server_ClientRemoved; // TODO: additionally, we may want to raise an event to extensions when the active profile changes foreach (var L_profile in Mubox.Configuration.MuboxConfigSection.Default.Profiles.Cast<Mubox.Configuration.ProfileSettings>()) { L_profile.ActiveClientChanged += ActiveClientChanged; } var extensionsPath = Path.Combine(Environment.CurrentDirectory); var files = System.IO.Directory.EnumerateFiles(extensionsPath, "ext.*.dll"); foreach (var file in files) { file.LogInfo(); var friendlyName = Path.GetFileNameWithoutExtension(file); var appDomain = AppDomain.CreateDomain(friendlyName); var bridge = new Extensibility.MuboxBridge(this); var loader = (Extensibility.Loader)appDomain .CreateInstanceAndUnwrap("Mubox.Extensibility", "Mubox.Extensibility.Loader"); _clients .ToList() .ForEach(bridge.Clients.Add); var extensionState = new ExtensionState() { Name = friendlyName, AppDomain = appDomain, Loader = loader, Bridge = bridge, }; _extensions.Add(extensionState.Name, extensionState); // actual extension load and initializes at this point loader.Initialize(bridge, file); } }