public static void CovariantGeneric() { ICovariantGeneric <MiddleClass> genericMiddle = new CovariantGeneric <MiddleClass>(); MiddleClass result = genericMiddle.Method(); ICovariantGeneric <BaseClass> genericMiddle1 = new CovariantGeneric <MiddleClass>(); ICovariantGeneric <BaseClass> genericMiddle2 = new CovariantGeneric <LastClass>(); var a = genericMiddle1.Method(); var b = genericMiddle2.Method(); ICovariantGeneric <MiddleClass> genericMiddle3 = new CovariantGeneric <LastClass>(); ICovariantGeneric <LastClass> genericMiddle4 = new CovariantGeneric <LastClass>(); // This is OK here: ICovariantGeneric <BaseClass> genericBase = genericMiddle; BaseClass baseResult = genericBase.Method(); // This will produce compile-time error: // Cannot implicitly convert type 'ICovariantGeneric<MiddleClass>' to 'ICovariantGeneric<LastClass>'. // An explicit conversion exists (are you missing a cast?) //// ICovariantGeneric<LastClass> genericLast = genericMiddle; }
public void TextFixtureSetUp() { _kernel = new StandardKernel(new ServiceModule()); _mockBottomClass = new Mock <IBottomClass>(); _middleClass = new MiddleClass(_mockBottomClass.Object); }
public static void CovariantGeneric() { IGenericCovariance <MiddleClass> genericMiddle = new GenericCovariance <MiddleClass>(); MiddleClass result = genericMiddle.Method(); // This is OK here: IGenericCovariance <BaseClass> genericBase = genericMiddle; BaseClass baseResult = genericBase.Method(); }
//################################# protected void btnStudentPanel_Click(object sender, EventArgs e) { if (lblShowErrorMessage.Visible == true) { lblShowErrorMessage.Visible = false; } if (this.btnStudentPanel.Text == MiddleClass.EditText)//"ویــــرایش") { this.pnl_First.Enabled = true; this.btnStudentPanel.Text = MiddleClass.InsertText;//"ثبـــــت"; return; } else//دکمه ثبت زده شد { var fromDate = this.pcal1.Text; var toDate = this.pcal2.Text; var startTime = RadTimePicker1.SelectedTime?.ToString().Substring(0, 5); var endTime = RadTimePicker2.SelectedTime?.ToString().Substring(0, 5); if (!MiddleClass.AreAllFieldsEmpty(fromDate, toDate, startTime, endTime)) { if ((string.Compare(fromDate, toDate) == 1) || (string.Compare(startTime, endTime) == 1)) { //EnableShowResultMessage(MiddleClass.msgError); radWindowManager.RadAlert(MiddleClass.msgError, 400, 100, "پیام سیستم", ""); return; } var item1 = ExamBusiness.GetSystemAvailability(MiddleClass.appID, MiddleClass.userKind_Student, MiddleClass.userStatus); if (item1 != null) { var check = ExamBusiness.UpdateSystemAvailabilityByParams(MiddleClass.appID, MiddleClass.userKind_Student, MiddleClass.userStatus, fromDate, startTime, toDate, endTime); if (check) { radWindowManager.RadAlert(MiddleClass.msgSuccuss, 400, 100, "پیام سیستم", ""); } //EnableShowResultMessage(MiddleClass.msgSuccuss); else { radWindowManager.RadAlert(MiddleClass.msgwarrning, 400, 100, "پیام سیستم", ""); } //EnableShowResultMessage(MiddleClass.msgwarrning); } } this.btnStudentPanel.Text = MiddleClass.EditText;//"ویــــرایش"; this.pnl_First.Enabled = false; } }
public static void InvariantGeneric() { IInvariantGeneric <MiddleClass> genericMiddle = new InvariantGeneric <MiddleClass>(); MiddleClass result = genericMiddle.Method(new MiddleClass()); // This will produce compile-time error: // Cannot implicitly convert type 'IInvariantGeneric<MiddleClass>' to 'IInvariantGeneric<BaseClass>'. // An explicit conversion exists (are you missing a cast?) //// IInvariantGeneric<BaseClass> genericBase = genericMiddle; // This will produce compile-time error: // Cannot implicitly convert type 'IInvariantGeneric<MiddleClass>' to 'IInvariantGeneric<LastClass>'. // An explicit conversion exists (are you missing a cast?) //// IInvariantGeneric<LastClass> genericLast = genericMiddle; }