/// <summary> /// 确定指定的对象是否等于当前的对象。 /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { if (obj is PluginType) { PluginType pluginType = obj as PluginType; if (pluginType.Equals(this.PluginType)) { return(true); } return(false); } else if (obj is IPlugin) { return(this.m_Plugin.Equals(obj)); } else { return(base.Equals(obj)); } }
/// <summary> /// Loads the test case from the current assembly using the reflection /// Read the attributes like id, category, description. /// </summary> public bool LoadTestCases(Type type, Collection <int> selectedTests = null, PluginType plugin = PluginType.Default, Collection <PrintTestData> testDurationDetails = null) { if (!plugin.Equals(PluginType.Default)) { _pluginType = plugin; } _type = type; PrintTestData Testdata = null; selectAll_CheckBox.Checked = false; if (plugin == PluginType.Print) { // Hide and show the columns based on the plug-in type durationDataGridViewTextBoxColumn.Visible = true; connectivityDataGridViewTextBoxColumn.Visible = false; printProtocolDataGridViewTextBoxColumn.Visible = false; portNumberDataGridViewTextBoxColumn.Visible = false; testCaseDetails_DataGrid.ScrollBars = ScrollBars.Vertical; } if (plugin == PluginType.IPConfiguration) { connectivityDataGridViewTextBoxColumn.Visible = false; } if (null == type || null == productCategory_ComboBox.SelectedItem) { return(false); } ProductFamilies selectedCategory = (ProductFamilies)Enum.Parse(typeof(ProductFamilies), productCategory_ComboBox.SelectedItem.ToString()); // clear the previous rows before adding any new rows cTCTestCaseDetails.TestCaseDetails.Clear(); // walk thru all the methods inside the class and check if the method has TestDetails // then add to the data set. foreach (MethodInfo methodInfo in type.GetMethods()) { object[] attrs = methodInfo.GetCustomAttributes(new TestDetailsAttribute().GetType(), false); if (attrs.Length > 0) { // since we are having only the TestDetails type custom attributes so we can cast to this type TestDetailsAttribute details = (TestDetailsAttribute)attrs[0]; if (details.ProductCategory.HasFlag(selectedCategory)) { // create the row data CTCTestCaseDetailsDataSet.TestCaseDetailsRow row = cTCTestCaseDetails.TestCaseDetails.NewTestCaseDetailsRow(); row.IsSelected = selectedTests != null && selectedTests.Contains(details.Id); if (plugin.Equals(PluginType.Print) || _pluginType.Equals(PluginType.Print)) { bool durationAssigned = false; uint duration = 0; if (testDurationDetails != null && testDurationDetails.Count > 0) { var res = from data in testDurationDetails where data.TestId.Equals(details.Id) select new { Duration = data.Duration }; foreach (var item in res) { duration = Convert.ToUInt32(item.Duration); row.Duration = duration; durationAssigned = true; break; } } if (!durationAssigned) { row.Duration = details.PrintDuration; } if (details.PrintDuration > 0)//row.IsSelected && { Testdata = new PrintTestData(); Testdata.TestId = (int)details.Id; Testdata.Duration = (int)details.PrintDuration; _TestWithDuration.Add(Testdata); } row.PrintProtocol = details.PrintProtocol.ToString(); row.PortNumber = details.PortNumber; } row.Category = details.Category; row.ID = (uint)details.Id; row.Description = details.Description; row.Protocol = details.Protocol.ToString(); row.Connectivity = details.Connectivity.ToString(); cTCTestCaseDetails.TestCaseDetails.AddTestCaseDetailsRow(row); } } } return(true); }