コード例 #1
0
ファイル: PatcherManager.cs プロジェクト: HicServices/RDMP
        public IEnumerable <PluginPatcher> GetTier3Patchers(MEF mef, PluginPatcherFoundHandler events)
        {
            ObjectConstructor constructor = new ObjectConstructor();

            foreach (Type patcherType in mef.GetTypes <PluginPatcher>().Where(type => type.IsPublic))
            {
                PluginPatcher instance = null;

                try
                {
                    instance = (PluginPatcher)constructor.Construct(patcherType);

                    events?.Invoke(this, new PluginPatcherFoundEventArgs(patcherType, instance, PluginPatcherStatus.Healthy));
                }
                catch (Exception e)
                {
                    events?.Invoke(this, new PluginPatcherFoundEventArgs(patcherType, null, PluginPatcherStatus.CouldNotConstruct, e));
                }

                if (instance != null)
                {
                    yield return(instance);
                }
            }
        }
コード例 #2
0
ファイル: LoadStageNodeMenu.cs プロジェクト: lulzzz/RDMP
        private void AddMenu <T>(string menuName, Func <Type, bool> filterTypes)
        {
            var types = _mef.GetTypes <T>().Where(filterTypes).ToArray();
            var menu  = new ToolStripMenuItem(menuName);

            ProcessTaskType taskType;

            if (typeof(T) == typeof(IDataProvider))
            {
                taskType = ProcessTaskType.DataProvider;
            }
            else
            if (typeof(T) == typeof(IAttacher))
            {
                taskType = ProcessTaskType.Attacher;
            }
            else if (typeof(T) == typeof(IMutilateDataTables))
            {
                taskType = ProcessTaskType.MutilateDataTable;
            }
            else
            {
                throw new ArgumentException("Type '" + typeof(T) + "' was not expected", "T");
            }

            foreach (Type type in types)
            {
                Type toAdd = type;
                menu.DropDownItems.Add(type.Name, null, (s, e) => AddTypeIntoStage(toAdd, taskType));
            }

            menu.Enabled = ProcessTask.IsCompatibleStage(taskType, _loadStageNode.LoadStage) && types.Any();

            Items.Add(menu);
        }
コード例 #3
0
 internal IReadOnlyCollection <IPluginCohortCompiler> CreateAll()
 {
     return(_mef
            .GetTypes <IPluginCohortCompiler>()
            .Select(Activator.CreateInstance)
            .Cast <IPluginCohortCompiler>().ToList().AsReadOnly());
 }
コード例 #4
0
        public void GetComponentsCompatibleWithBulkInsertContext()
        {
            Type[] array = MEF.GetTypes <IDataFlowComponent <DataTable> >().ToArray();

            Assert.Greater(array.Count(), 0);
        }