private void EnsureType(IMethodInvocation input) { if (!typeof(T).IsCompatiableWith <IAutoNotify>()) { throw InvalidTypeException.Create <T>(); } }
public void SetChanged(object changedQuoteId) { if (!(changedQuoteId is int)) { InvalidTypeException.CreateExpectedActualException(typeof(int), changedQuoteId?.GetType()); } SetChangedQuote((int)changedQuoteId); }
public static dynamic GetTSObject(InvalidTypeException dynObject) { if (dynObject is null) { return(null); } return(dynObject.teklaObject); }
private NavigationPage GetMainPage() { var mainPage = Application.Current.MainPage as NavigationPage; if (!(Application.Current.MainPage is NavigationPage)) { throw InvalidTypeException.CreateExpectedActualException(typeof(NavigationPage), Application.Current.MainPage.GetType()); } return(mainPage); }
private async Task GoToQuoteAsync(object quote) { if (quote == null) { return; } if (!(quote is Quote)) { throw InvalidTypeException.CreateExpectedActualException(typeof(Quote), quote?.GetType()); } await navigationService.NavigateToAsync <QuoteView, QuoteViewModel>((quote as Quote).Id); }
public Task RemoveCurrentFromBackStackAsync(object data) { var mainPage = GetMainPage(); var previousPage = mainPage.Navigation.NavigationStack[mainPage.Navigation.NavigationStack.Count - 2]; var previousPageViewModel = previousPage.BindingContext as IEditableItemViewModel; if (previousPageViewModel == null) { throw InvalidTypeException.CreateExpectedActualException(typeof(IEditableItemViewModel), previousPageViewModel?.GetType()); } previousPageViewModel.SetChanged(data); return(mainPage.Navigation.PopAsync()); }
public static void getLists() { string currentCode = null; // Display names of contestants based on the inputted code by looping through ContestantList and printing each contestants' ToString method do { WriteLine("Enter a talent code: "); currentCode = ReadLine(); if (currentCode == "M") { WriteLine("Contestants with talent Musical instrument are:"); foreach (Contestant oConst in ContestantList) { if (oConst.TalentCode == 'M') { WriteLine(oConst.ToString()); } } } else if (currentCode == "S") { WriteLine("Contestants with talent Singing are:"); foreach (Contestant oConst in ContestantList) { if (oConst.TalentCode == 'S') { WriteLine(oConst.ToString()); } } } else if (currentCode == "D") { WriteLine("Contestants with talent Dancing are:"); foreach (Contestant oConst in ContestantList) { if (oConst.TalentCode == 'D') { WriteLine(oConst.ToString()); } } } else if (currentCode == "O") { WriteLine("Contestants with talent Other are:"); foreach (Contestant oConst in ContestantList) { if (oConst.TalentCode == 'O') { WriteLine(oConst.ToString()); } } } else { //If the entry wasn't any S D O or M, and it isn't Z, throw an exception. try { if (currentCode != "Z") { InvalidTypeException nbe = new InvalidTypeException(currentCode); throw(nbe); } } catch (InvalidTypeException e) { WriteLine(e.Message); } } //If Z is entered, get out of loop and end the program }while(!(currentCode == "Z")); }