public void AllDatabaseEntitiesHaveTypedIRepository() { SetupMEF(); List <string> problems = new List <string>(); foreach (var type in MEF.GetAllTypes().Where(t => typeof(DatabaseEntity).IsAssignableFrom(t))) { foreach (var constructorInfo in type.GetConstructors()) { var parameters = constructorInfo.GetParameters(); if (parameters.Any(p => p.ParameterType == typeof(IRepository))) { problems.Add($"Constructor found on Type {type} that takes {nameof(IRepository)}, it should take either {nameof(IDataExportRepository)} or {nameof(ICatalogueRepository)}"); } } } foreach (var problem in problems) { TestContext.Out.WriteLine(problem); } Assert.IsEmpty(problems); }
private IEnumerable <string> EnforceTypeBelongsInNamespace(Type InterfaceType, params string[] legalNamespaces) { SetupMEF(); foreach (Type type in MEF.GetAllTypes().Where(InterfaceType.IsAssignableFrom)) { if (type.Namespace == null) { continue; } //don't validate classes in testing code if (type.Namespace.Contains(".Tests")) { continue; } //theese guys can be wherever they want if (_exemptNamespaces.Any(e => type.Namespace.Contains(e))) { continue; } if (!legalNamespaces.Any(ns => type.Namespace.Contains(ns))) { yield return("Expected Type '" + type.Name + "' to be in namespace(s) '" + string.Join("' or '", legalNamespaces) + "' but it was in '" + type.Namespace + "'"); } evaluatedClasses++; } Console.WriteLine("Evaluated " + evaluatedClasses + " classes for namespace compatibility"); }
public CheckEntireDataLoadProcess(ILoadMetadata loadMetadata, HICDatabaseConfiguration databaseConfiguration, HICLoadConfigurationFlags loadConfigurationFlags, MEF mef) { _databaseConfiguration = databaseConfiguration; _loadConfigurationFlags = loadConfigurationFlags; _mef = mef; LoadMetadata = loadMetadata; }
public void GetRepositoryConstructor_AllDatabaseEntities_OneWinningConstructor() { SetupMEF(); int countCompatible = 0; var badTypes = new Dictionary <Type, Exception>(); foreach (Type t in MEF.GetAllTypes().Where(typeof(DatabaseEntity).IsAssignableFrom)) { try { var oc = new ObjectConstructor(); Assert.IsNotNull(oc.GetRepositoryConstructor(typeof(Catalogue))); countCompatible++; } catch (Exception e) { badTypes.Add(t, e); } } Assert.IsEmpty(badTypes); Assert.GreaterOrEqual(countCompatible, 10); Console.WriteLine("Found compatible constructors on " + countCompatible + " objects"); }
private void InitializeControls() { try { Txt_FromDT.Text = DateHelper.ConvertToDataBase(DateHelper.ConvertToForm(SessionUserData.Company.AccountingStartDate)); Txt_ToDT.Text = DateHelper.ConvertToDataBase(DateHelper.ConvertToForm(DateTime.Now)); AVPHDR_ID.Text = "0"; VP_No.Text = MEF.GetRefNo(SessionUserData.Company.CompanyID, SessionUserData.Company.BranchID, SessionUserData.Company.YearID, "Vendor Payment", "VP", "VP", "Yes"); VP_DT.Text = DateHelper.ConvertToDataBase(DateHelper.ConvertToForm(DateTime.Now)); Fk_VendorID.SelectedIndex = 0; VP_Received_Amt.Text = "0"; VP_Adjusted_Amt.Text = "0"; VP_OnAccount_Amt.Text = "0"; VP_Payment_Mode.SelectedIndex = 0; VP_Ref_No.Text = ""; VP_Ref_DT.Text = ""; VP_Narration.Text = ""; gv_VP_Inv.DataSource = null; gv_VP_Inv.DataBind(); Msg_RCNT.Text = " No Records Found"; } catch (Exception ex) { throw new Exception(ex.Message); } }
public void PluginProcessTaskUI_InvalidParameter_Date() { MEF.AddTypeToCatalogForTesting(typeof(OmgDates)); var pt = WhenIHaveA <ProcessTask>(); pt.Path = typeof(OmgDates).FullName; var arg = pt.CreateArgumentsForClassIfNotExists <OmgDates>().Single(); //set the argument value to 2001 arg.SetValue(new DateTime(2001, 01, 01)); pt.SaveToDatabase(); AndLaunch <PluginProcessTaskUI>(pt); AssertNoErrors(ExpectedErrorType.Any); //there should be a text box with our argumetn value in it var tb = GetControl <TextBox>().Single(t => t.Text.Contains("2001")); //set the text to something nasty that won't compile tb.Text = "hahahah fff"; Publish(pt); AssertNoErrors(ExpectedErrorType.Any); AndLaunch <PluginProcessTaskUI>(pt); AssertNoErrors(ExpectedErrorType.Any); }
public void FindProblems(MEF mef) { List <string> excusables = new List <string>() { "IPlugin", "IDataAccessCredentials", "IProcessTask" //this is inherited by IRuntimeTask too which isn't an IMapsDirectlyToDatabaseTable }; List <string> problems = new List <string>(); foreach (var dbEntities in mef.GetAllTypes().Where(t => typeof(DatabaseEntity).IsAssignableFrom(t))) { var matchingInterface = typeof(Catalogue).Assembly.GetTypes().SingleOrDefault(t => t.Name.Equals("I" + dbEntities.Name)); if (matchingInterface != null) { if (excusables.Contains(matchingInterface.Name)) { continue; } if (!typeof(IMapsDirectlyToDatabaseTable).IsAssignableFrom(matchingInterface)) { problems.Add("FAIL: Interface '" + matchingInterface.Name + "' does not inherit IMapsDirectlyToDatabaseTable"); } } } foreach (string problem in problems) { Console.WriteLine(problem); } Assert.AreEqual(0, problems.Count); }
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); } } }
private void InitializeControls() { try { MItem_ID.Text = "0"; UOM_ID.SelectedIndex = 0; Item_Code.Text = MEF.GetRefNo(SessionUserData.Company.CompanyID, SessionUserData.Company.BranchID, 0, "Item", "IC", "IC", "No"); HSNCode.Text = ""; Item_Type.SelectedIndex = 0; Item_Name.Text = ""; Item_Selling_Rate.Text = "0"; Item_Purchase_Rate.Text = "0"; Item_Desc.Text = ""; Item_Tax_GST_Effective_From.Text = "01-Jul-2017"; Item_CGST_Rate.Text = "0"; Item_SGST_Rate.Text = "0"; Item_IGST_Rate.Text = "0"; Item_Tax_GST_ID.SelectedIndex = 0; Item_CESS_Rate.Text = "0"; MDBSC_RowStatus.SelectedIndex = 0; MDBSC_RowCreatedByUserName.Text = SessionUserData.UserData.UserName; MDBSC_RowCreatedOn_DT.Text = DateHelper.ConvertToDataBase(DateHelper.ConvertToForm(DateTime.Now)); } catch (Exception ex) { throw new Exception(ex.Message); } }
public SVM(ProblemSetup problem) { this.problem = problem; nParticles = problem.getNumberOfParticles(); mef = new MEF(problem); /* perms = permutations(); */ }
/// <summary> /// Call if your test needs to access classes via MEF. Loads all dlls in the test directory. /// /// <para>This must be called before you 'launch' your ui</para> /// </summary> protected void SetupMEF() { MEF = new MEF(); MEF.Setup(new SafeDirectoryCatalog(new IgnoreAllErrorsCheckNotifier(), TestContext.CurrentContext.TestDirectory)); Repository.CatalogueRepository.MEF = MEF; Validator.RefreshExtraTypes(MEF.SafeDirectoryCatalog, new ThrowImmediatelyCheckNotifier()); }
public HttpResponseMessage AppUserLogin(AppUserModel objUser) { try { HttpResponseMessage RetResponse = new HttpResponseMessage(); string var_LoginD = objUser.LoginID; string var_PasswordD = objUser.Password; string var_ErrorMsg = ""; if (CodeAssistance.F_ValidateStrLen(var_LoginD, 25)) { var_ErrorMsg = var_ErrorMsg + "invalid string length for LoginID"; } if (CodeAssistance.F_ValidateStrLen(var_PasswordD, 25)) { var_ErrorMsg = var_ErrorMsg + "invalid string length for Password"; } var_LoginD = CodeAssistance.F_ValidateString("ALL", var_LoginD, ".@"); var_PasswordD = CodeAssistance.F_ValidateString("RemoveSingleQuote", var_PasswordD, ""); var_PasswordD = CodeAssistance.F_ValidateString("RemoveNextLine", var_PasswordD, ".@"); var_PasswordD = CodeAssistance.F_ValidateString("RemoveSpace", var_PasswordD, "");; var_PasswordD = CodeAssistance.F_ValidateString("RemoveSingleQuote", var_PasswordD, ""); if (var_LoginD.Length == 0) { var_ErrorMsg = var_ErrorMsg + "LoginID cannot be blank"; } if (var_PasswordD.Length == 0) { var_ErrorMsg = var_ErrorMsg + "Password cannot be blank"; } if (var_ErrorMsg.Length == 0) { if (MEF.Security_ValidateUser("APPUSER", var_LoginD, var_PasswordD)) { //Create User Object objUser = AppData.Get_User_Data_By_LoginID(var_LoginD); RetResponse = Request.CreateResponse(HttpStatusCode.OK, (new JsonRetMessage(false, true, "Login Successfully", objUser))); } else { RetResponse = Request.CreateResponse(HttpStatusCode.OK, (new JsonRetMessage(false, true, "invalid userid or password", objUser))); } } else { RetResponse = Request.CreateResponse(HttpStatusCode.OK, (new JsonRetMessage(false, true, var_ErrorMsg, null))); } return(RetResponse); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.OK, (new JsonRetMessage(true, false, "internal server error " + Environment.NewLine + ex.Message, null)))); } }
public ValidationXMLObscureDependencyFinder(ICatalogueRepositoryServiceLocator catalogueRepositoryServiceLocator) { if (Validator.LocatorForXMLDeserialization == null) { Validator.LocatorForXMLDeserialization = catalogueRepositoryServiceLocator; } _mef = catalogueRepositoryServiceLocator.CatalogueRepository.MEF; }
private void InitializeControls_HDR() { try { Txt_FromDT.Text = DateHelper.ConvertToDataBase(DateHelper.ConvertToForm(SessionUserData.Company.AccountingStartDate)); Txt_ToDT.Text = DateHelper.ConvertToDataBase(DateHelper.ConvertToForm(DateTime.Now)); Inv_Txt_FromDT.Text = DateHelper.ConvertToDataBase(DateHelper.ConvertToForm(SessionUserData.Company.AccountingStartDate)); Inv_Txt_ToDT.Text = DateHelper.ConvertToDataBase(DateHelper.ConvertToForm(DateTime.Now)); DCNCHDR_ID.Text = "0"; Fk_INVHDR_ID.Text = "0"; Msg_ErrorMsg.Text = ""; SINV_Taxtype.Text = ""; MCust_Name.Text = ""; SINV_No.Text = ""; vSINV_DT.Text = ""; SINV_HDR_Total_Gross_Amt.Text = "0"; DCNC_Reason.SelectedIndex = 0; DCNC_Type.Text = ""; DCNC_No.Text = MEF.GetRefNo(SessionUserData.Company.CompanyID, SessionUserData.Company.BranchID, SessionUserData.Company.YearID, "DCN", "DCN", "DCN", "Yes"); DCNC_DT.Text = DateHelper.ConvertToDataBase(DateHelper.ConvertToForm(DateTime.Now)); DCNC_ShippTo_State_ID.SelectedIndex = 0; SINV_ShippedFrom_State_ID.SelectedIndex = 0; SINV_ShippedFrom_State_ID.Enabled = false; DCNC_Remark.Text = ""; MDBSC_RowStatus.Text = ""; MDBSC_RowCreatedByUserName.Text = SessionUserData.UserData.UserName; MDBSC_RowCreatedOn_DT.Text = DateHelper.ConvertToDataBase(DateHelper.ConvertToForm(DateTime.Now)); DCNC_HDR_BasicAmt.Text = "0.00"; DCNC_HDR_DiscountAmt.Text = "0.00"; DCNC_HDR_Net_Amt.Text = "0.00"; DCNC_HDR_Freight_Charges.Text = "0.00"; DCNC_HDR_CGST_Amt.Text = "0.00"; DCNC_HDR_SGST_Amt.Text = "0.00"; DCNC_HDR_IGST_Amt.Text = "0.00"; DCNC_HDR_CESS_Amt.Text = "0.00"; DCNC_HDR_Gross_Amt.Text = "0.00"; DCNC_HDR_Round_Off_Amt.Text = "0.00"; DCNC_HDR_Total_Gross_Amt.Text = "0.00"; DCNC_HDR_Total_Tax_Amt.Text = "0.00"; TaxType_Toggel(); gvdtl.DataSource = null; gvdtl.DataBind(); } catch (Exception ex) { throw new Exception(ex.Message); } }
public DilutionOperationFactory(IPreLoadDiscardedColumn targetColumn) { if (targetColumn == null) { throw new ArgumentNullException("targetColumn"); } _targetColumn = targetColumn; _mef = ((ICatalogueRepository)_targetColumn.Repository).MEF; }
public void Init() { double[] masses = { 1, 1, 1 }; int[] charges = { -1, -1, 1 }; double[] spins = { 1 / 2.0, 1 / 2.0, 1 / 2.0 }; problem = new ProblemSetup(masses, charges, spins, 0.0, 20); svm = new SVM(problem); testfunctions = svm.generateTestFunctions(3); mef = new MEF(problem); }
public void RefreshRepositoriesFromUserSettings() { //we have mef? MEF mef = null; CommentStore commentStore = null; //if we have a catalogue repository with loaded MEF then grab it if (_linkedRepositoryProvider != null && _linkedRepositoryProvider.CatalogueRepository != null) { if (_linkedRepositoryProvider.CatalogueRepository.MEF != null) { mef = _linkedRepositoryProvider.CatalogueRepository.MEF; } if (_linkedRepositoryProvider.CatalogueRepository.CommentStore != null) { commentStore = _linkedRepositoryProvider.CatalogueRepository.CommentStore; } } //user must have a Catalogue string catalogueString = UserSettings.CatalogueConnectionString; //user may have a DataExportManager string dataExportManagerConnectionString = UserSettings.DataExportConnectionString; LinkedRepositoryProvider newrepo; try { newrepo = new LinkedRepositoryProvider(catalogueString, dataExportManagerConnectionString); } catch (Exception ex) { throw new CorruptRepositoryConnectionDetailsException($"Unable to create {nameof(LinkedRepositoryProvider)}", ex); } //preserve the currently loaded MEF assemblies //if we have a new repo if (newrepo.CatalogueRepository != null) { //and the new repo doesn't have MEF loaded if (newrepo.CatalogueRepository.MEF != null && !newrepo.CatalogueRepository.MEF.HaveDownloadedAllAssemblies && mef != null && mef.HaveDownloadedAllAssemblies) { //use the old MEF newrepo.CatalogueRepository.MEF = mef; } newrepo.CatalogueRepository.CommentStore = commentStore ?? newrepo.CatalogueRepository.CommentStore; } _linkedRepositoryProvider = newrepo; }
private string GetTypeName(Type t) { try { return(MEF.GetCSharpNameForType(t)); } catch (NotSupportedException) { return(t.Name); } }
/// <summary> /// Creates a new factory which can translate <see cref="IPipeline"/> blueprints into runnable <see cref="IDataFlowPipelineEngine"/> instances. /// </summary> /// <param name="useCase">The use case which describes which <see cref="IPipeline"/> are compatible, which objects are available for hydration/preinitialization etc</param> /// <param name="mefPlugins">Class for generating Types by name, use <see cref="ICatalogueRepository.MEF"/> to get this </param> public DataFlowPipelineEngineFactory(IPipelineUseCase useCase, MEF mefPlugins) { _mefPlugins = mefPlugins; _context = useCase.GetContext(); _useCase = useCase; _flowType = _context.GetFlowType(); _constructor = new ObjectConstructor(); _engineType = typeof(DataFlowPipelineEngine <>).MakeGenericType(_flowType); }
public LoadStageNodeMenu(RDMPContextMenuStripArgs args, LoadStageNode loadStageNode) : base(args, loadStageNode) { _loadStageNode = loadStageNode; _mef = _activator.RepositoryLocator.CatalogueRepository.MEF; args.SkipCommand <ExecuteCommandCreateNewClassBasedProcessTask>(); AddMenu <IDataProvider>("Add Cached Data Provider", t => typeof(ICachedDataProvider).IsAssignableFrom(t)); AddMenu <IDataProvider>("Add Data Provider", t => !typeof(ICachedDataProvider).IsAssignableFrom(t)); AddMenu <IAttacher>("Add Attacher"); AddMenu <IMutilateDataTables>("Add Mutilator"); }
public HomeViewCommandViewModel([Import("RDEImportTool")] MEF mef, IImageManager imageManager) { DisplayName = Properties.Resources.DisplayName; DisplayInfo = new ExplorerDisplayInfo { Description = Properties.Resources.DisplayName, Image16 = "/STARS.Applications.VETS.Plugins.RDEImportTool;component/Images/color_image_16.png", ExplorerImage16 = "/STARS.Applications.VETS.Plugins.RDEImportTool;component/Images/white_image_16.png" }; ImportData importData = new ImportData(); Command = new RelayCommand(p => importData.Import()); }
public LoadStageNodeMenu(RDMPContextMenuStripArgs args, LoadStageNode loadStageNode) : base(args, loadStageNode) { _loadStageNode = loadStageNode; _mef = _activator.RepositoryLocator.CatalogueRepository.MEF; AddMenu <IDataProvider>("Add Cached Data Provider", t => typeof(ICachedDataProvider).IsAssignableFrom(t)); AddMenu <IDataProvider>("Add Data Provider", t => !typeof(ICachedDataProvider).IsAssignableFrom(t)); AddMenu <IAttacher>("Add Attacher"); AddMenu <IMutilateDataTables>("Add Mutilator"); Add(new ExecuteCommandCreateNewProcessTask(_activator, ProcessTaskType.SQLFile, loadStageNode.LoadMetadata, loadStageNode.LoadStage)); Add(new ExecuteCommandCreateNewProcessTask(_activator, ProcessTaskType.Executable, loadStageNode.LoadMetadata, loadStageNode.LoadStage)); }
private void InitializeMEF() { try { MEF.Compose(Assembly.GetExecutingAssembly(), "MediaPlayer"); MEF.Build(this); } catch (ReflectionTypeLoadException ex) { foreach (var exception in ex.LoaderExceptions) { MessageBox.Show(exception.Message, ex.GetType().ToString()); } } }
public void 测试导出IFormatterConverter() { Assert.IsNull(_Converter1); Assert.IsNull(_Converter2); MEF.Import(this); Assert.IsNotNull(_Converter1); Assert.IsNotNull(_Converter2); Assert.IsNull(_Converter3); Assert.IsNull(_Converter4); MEF.Import(this.GetType()); Assert.IsNotNull(_Converter3); Assert.IsNotNull(_Converter4); Assert.IsNotNull(ComponentServices.Converter); }
public void GenerateReport(CommentStore commentStore, ICheckNotifier notifier, IIconProvider iconProvider, MEF mef, bool showFile) { _mef = mef; _commentStore = commentStore; try { Check(notifier); using (var document = GetNewDocFile("RDMPDocumentation")) { var t = InsertTable(document, (Summaries.Count * 2) + 1, 1); //Listing Cell header SetTableCell(t, 0, 0, "Tables"); Type[] keys = Summaries.Keys.ToArray(); for (int i = 0; i < Summaries.Count; i++) { //creates the run SetTableCell(t, (i * 2) + 1, 0, ""); var bmp = iconProvider.GetImage(keys[i]); if (bmp != null) { var para = t.Rows[(i * 2) + 1].GetCell(0).Paragraphs.First(); var run = para.Runs.FirstOrDefault() ?? para.CreateRun(); GetPicture(run, bmp); } SetTableCell(t, (i * 2) + 1, 0, " " + keys[i].Name); SetTableCell(t, (i * 2) + 2, 0, Summaries[keys[i]]); } if (showFile) { ShowFile(document); } } } catch (Exception e) { notifier.OnCheckPerformed(new CheckEventArgs("Report generation failed", CheckResult.Fail, e)); } }
public static DataTable Get_ItemSubGroup_ByItemGroup(string IG_ID) { string strSqlString = ""; try { strSqlString = " Select 0 value,'--Select Sub Group--' Text,0 RSN " + " UNION ALL " + " Select ISG_ID ,Item_SubGroup,1 RSN " + " from M_AT_Mst_ItemSubGroup " + " WHERE Fk_IG_ID=" + IG_ID + " Order By RSN asc, Text asc "; return(MEF.DA_GetDataTable(strSqlString)); } catch (Exception ex) { throw new Exception(ex.Message); } }
public void TestClassNameRefactoring() { CataloguePatcher p = new CataloguePatcher(); var patch = p.GetAllPatchesInAssembly(null).Single(kvp => kvp.Key == "068_FixNamespaces.sql").Value; Regex findSubsRegex = new Regex(@"REPLACE\(.*,'(.*)','(.*)'\)"); Dictionary <string, string> substitutions = new Dictionary <string, string>(); foreach (Match match in findSubsRegex.Matches(patch.EntireScript)) { if (substitutions.ContainsKey(match.Groups[1].Value)) { continue; } substitutions.Add(match.Groups[1].Value, match.Groups[2].Value); } SetupMEF(); MEF.SafeDirectoryCatalog.AddType(typeof(FAnsi.DatabaseType)); foreach (var oldClass in ExpectedClasses) { string newClass = oldClass; foreach (KeyValuePair <string, string> kvp in substitutions) { newClass = newClass.Replace(kvp.Key, kvp.Value); } Type foundNow = MEF.GetType(newClass); Assert.IsNotNull(foundNow, "Patch did not work correctly for Type '" + oldClass + "' which after renaming became '" + newClass + "'"); } }
public void HowDoesMEFHandleTypeNames() { string expected = "Rdmp.Core.DataFlowPipeline.IDataFlowSource(System.Data.DataTable)"; Assert.AreEqual(expected, MEF.GetMEFNameForType(typeof(IDataFlowSource <DataTable>))); }
public void GetComponentsCompatibleWithBulkInsertContext() { Type[] array = MEF.GetTypes <IDataFlowComponent <DataTable> >().ToArray(); Assert.Greater(array.Count(), 0); }
public void FindProblems(List <string> csFilesList, MEF mef) { _csFilesList = csFilesList; //All node classes should have equality compare members so that tree expansion works properly foreach (Type nodeClass in mef.GetAllTypes().Where(t => typeof(Node).IsAssignableFrom(t) && !t.IsAbstract && !t.IsInterface)) { if (nodeClass.Namespace == null || nodeClass.Namespace.StartsWith("System")) { continue; } //class is excused if (excusedNodeClasses.Contains(nodeClass)) { continue; } //it's something like ProposeExecutionWhenTargetIsIDirectoryNode.cs i.e. it's not a Node! if (typeof(ICommandExecutionProposal).IsAssignableFrom(nodeClass)) { continue; } //if it's an ObjectUsedByOtherObjectNode then it will already have GetHashCode implemented if (typeof(IObjectUsedByOtherObjectNode).IsAssignableFrom(nodeClass)) { continue; } if (typeof(ExtractionArbitraryFolderNode).IsAssignableFrom(nodeClass)) { continue; } //these are all supported at base class level if (typeof(SingletonNode).IsAssignableFrom(nodeClass)) { if (!nodeClass.Name.StartsWith("All")) { problems.Add("Class '" + nodeClass.Name + "' is a SingletonNode but it's name doesn't start with All"); } continue; } ConfirmFileHasText(nodeClass, "public override int GetHashCode()"); } //All Menus should correspond to a data class foreach (Type menuClass in mef.GetAllTypes().Where(t => typeof(RDMPContextMenuStrip).IsAssignableFrom(t) && !t.IsAbstract && !t.IsInterface)) { if (menuClass == typeof(RDMPContextMenuStrip)) //the basic class from which all are inherited { continue; } //We are looking at something like AutomationServerSlotsMenu if (!menuClass.Name.EndsWith("Menu")) { problems.Add("Class '" + menuClass + "' is a RDMPContextMenuStrip but it's name doesn't end with Menu"); continue; } foreach (ConstructorInfo c in menuClass.GetConstructors()) { if (c.GetParameters().Count() != 2) { problems.Add("Constructor of class '" + menuClass + "' which is an RDMPContextMenuStrip contained " + c.GetParameters().Count() + " constructor arguments. These menus are driven by reflection (See RDMPCollectionCommonFunctionality.GetMenuWithCompatibleConstructorIfExists )"); } } var toLookFor = menuClass.Name.Substring(0, menuClass.Name.Length - "Menu".Length); var expectedClassName = GetExpectedClassOrInterface(toLookFor); if (expectedClassName == null) { problems.Add("Found menu called '" + menuClass.Name + "' but couldn't find a corresponding data class called '" + toLookFor + ".cs'"); continue; } ConfirmFileHasText(menuClass, "AddCommonMenuItems()", false); //expect something like this //public AutomationServerSlotsMenu(IActivateItems activator, AllAutomationServerSlotsNode databaseEntity) string expectedConstructorSignature = menuClass.Name + "(RDMPContextMenuStripArgs args," + expectedClassName; ConfirmFileHasText(menuClass, expectedConstructorSignature); FieldInfo[] fields = menuClass.GetFields( BindingFlags.NonPublic | BindingFlags.Instance); //find private fields declared at the object level (i.e. not in base class that are of type IActivateItem) var activatorField = fields.FirstOrDefault(f => f.DeclaringType == menuClass && f.FieldType == typeof(IActivateItems)); if (activatorField != null) { problems.Add("Menu '" + menuClass + "' contains a private field called '" + activatorField.Name + "'. You should instead use base class protected field RDMPContextMenuStrip._activator"); } } //Drag and drop / Activation - Execution Proposal system foreach (Type proposalClass in mef.GetAllTypes().Where(t => typeof(ICommandExecutionProposal).IsAssignableFrom(t) && !t.IsAbstract && !t.IsInterface)) { if (proposalClass.Namespace.Contains("Rdmp.UI.Tests.DesignPatternTests")) { continue; } //We are looking at something like AutomationServerSlotsMenu if (!proposalClass.Name.StartsWith("ProposeExecutionWhenTargetIs")) { problems.Add("Class '" + proposalClass + "' is a ICommandExecutionProposal but it's name doesn't start with ProposeExecutionWhenTargetIs"); continue; } var toLookFor = proposalClass.Name.Substring("ProposeExecutionWhenTargetIs".Length); string expectedClassName = GetExpectedClassOrInterface(toLookFor); if (expectedClassName == null) { problems.Add("Found proposal called '" + proposalClass + "' but couldn't find a corresponding data class called '" + toLookFor + ".cs'"); } } //Make sure all user interface classes have the suffix UI foreach (Type uiType in mef.GetAllTypes().Where(t => (typeof(RDMPUserControl).IsAssignableFrom(t) || (typeof(RDMPForm).IsAssignableFrom(t)) && !t.IsAbstract && !t.IsInterface))) { if (!uiType.Name.EndsWith("UI") && !uiType.Name.EndsWith("_Design")) { if (excusedUIClasses.Contains(uiType)) { continue; } //also allow Screen1, Screen2 etc if (Regex.IsMatch(uiType.Name, @"Screen\d") && uiType.IsNotPublic) { continue; } problems.Add("Class " + uiType.Name + " does not end with UI"); } } foreach (string problem in problems) { Console.WriteLine("FATAL ERROR PROBLEM:" + problem); } Assert.AreEqual(problems.Count, 0); }