/// <summary> /// Lists assembly load errors and attempts to construct instances of all Types declared as Exports (which are ICheckable) /// </summary> /// <param name="notifier"></param> public void Check(ICheckNotifier notifier) { foreach (KeyValuePair <string, Exception> badAssembly in _mefPlugins.ListBadAssemblies()) { notifier.OnCheckPerformed(new CheckEventArgs("Could not load assembly " + badAssembly.Key, CheckResult.Fail, badAssembly.Value)); } foreach (Type t in _mefPlugins.GetAllTypes()) { notifier.OnCheckPerformed(new CheckEventArgs("Found Type " + t, CheckResult.Success, null)); if (typeof(ICheckable).IsAssignableFrom(t)) { try { _mefPlugins.CreateA <ICheckable>(t.FullName); } catch (Exception ex) { notifier.OnCheckPerformed(new CheckEventArgs( "Class " + t.FullName + " implements ICheckable but could not be created as an ICheckable.", CheckResult.Warning, ex)); } } } }
public IDilutionOperation Create(Type operation) { if (operation == null) { throw new ArgumentNullException("operation"); } if (!typeof(IDilutionOperation).IsAssignableFrom(operation)) { throw new ArgumentException("Requested operation Type " + operation + " did was not an IDilutionOperation"); } var instance = _mef.CreateA <IDilutionOperation>(operation.FullName); instance.ColumnToDilute = _targetColumn; return(instance); }
public AttacherRuntimeTask(IProcessTask task, RuntimeArgumentCollection args, MEF mef) : base(task, args) { //All attachers must be marked as mounting stages, and therefore we can pull out the RAW Server and Name var mountingStageArgs = args.StageSpecificArguments; if (mountingStageArgs.LoadStage != LoadStage.Mounting) { throw new Exception("AttacherRuntimeTask can only be called as a Mounting stage process"); } if (string.IsNullOrWhiteSpace(task.Path)) { throw new ArgumentException("Path is blank for ProcessTask '" + task + "' - it should be a class name of type " + typeof(IAttacher).Name); } Attacher = mef.CreateA <IAttacher>(ProcessTask.Path); SetPropertiesForClass(RuntimeArguments, Attacher); Attacher.Initialize(args.StageSpecificArguments.RootDir, RuntimeArguments.StageSpecificArguments.DbInfo); }
public DataProviderRuntimeTask(IProcessTask task, RuntimeArgumentCollection args, MEF mef) : base(task, args) { string classNameToInstantiate = task.Path; if (string.IsNullOrWhiteSpace(task.Path)) { throw new ArgumentException("Path is blank for ProcessTask '" + task + "' - it should be a class name of type " + typeof(IDataProvider).Name); } Provider = mef.CreateA <IDataProvider>(classNameToInstantiate); try { SetPropertiesForClass(RuntimeArguments, Provider); } catch (Exception e) { throw new Exception("Error when trying to set the properties for '" + task.Name + "'", e); } Provider.Initialize(args.StageSpecificArguments.RootDir, RuntimeArguments.StageSpecificArguments.DbInfo); }
public MutilateDataTablesRuntimeTask(IProcessTask task, RuntimeArgumentCollection args, MEF mef) : base(task, args) { //All attachers must be marked as mounting stages, and therefore we can pull out the RAW Server and Name var stageArgs = args.StageSpecificArguments; if (stageArgs == null) { throw new NullReferenceException("Stage args was null"); } if (stageArgs.DbInfo == null) { throw new NullReferenceException("Stage args had no DbInfo, unable to mutilate tables without a database - mutilator is sad"); } if (string.IsNullOrWhiteSpace(task.Path)) { throw new ArgumentException("Path is blank for ProcessTask '" + task + "' - it should be a class name of type " + typeof(IMutilateDataTables).Name); } MutilateDataTables = mef.CreateA <IMutilateDataTables>(ProcessTask.Path); SetPropertiesForClass(RuntimeArguments, MutilateDataTables); MutilateDataTables.Initialize(stageArgs.DbInfo, ProcessTask.LoadStage); }