public PluginAssembly(IPluginAssemblyManagerFactory asmManagerFactory, IPluginBootstrapService pluginBootstrapService, IPluginCoreUsabilityCheckService pluginCoreUsabilityCheckService, IPluginControllerValidationService pluginControllerValidationService, IPluginMetadataBundleCheckService pluginMetadataCheckService, IPluginAssemblyInitialisationResultFactory pluginAssemblyInitialisationResultFactory, IPluginInstanceFactory pluginInstanceFactory, string netAssemblyPath) { if (string.IsNullOrEmpty(netAssemblyPath)) throw new ArgumentNullException("Assembly path must be supplied"); _asmManagerFactory = asmManagerFactory; _pluginBootstrapService = pluginBootstrapService; _pluginCoreUsabilityCheckService = pluginCoreUsabilityCheckService; _pluginControllerValidationService = pluginControllerValidationService; _pluginMetadataBundleCheckService = pluginMetadataCheckService; _pluginAsmInitialisationResultFactory = pluginAssemblyInitialisationResultFactory; _pluginInstanceFactory = pluginInstanceFactory; _netAssemblyPath = netAssemblyPath; }
public IPluginController CreateControllerOfType(Type type, IPluginControllerValidationService controllerValidator) { if (type == null) throw new ArgumentNullException("type must be supplied"); try { var controllerValidationResult = controllerValidator.ValidateControllerType(type); if (!controllerValidationResult.Success) { throw new InvalidOperationException(string.Format("Cannot use type to create controller, type failed validation: {0}", controllerValidationResult.ResultTwo.ToString())); } else { return (IPluginController)Activator.CreateInstance(type); } } catch (Exception ex) { throw new ApplicationException("Failed to create controller of given type", ex); } }