I am trying to extract out the common code pattern here in an extract method, but am having trouble finding the proper type for the type of Presenter. Any help?
public bool CanGotoHome
{
get { return !(CurrentPresenter is IHomePresenter) && IsLoggedIn; }
}
public bool CanGotoImportanceOfAimsAndObjectives
{
get { return !(CurrentPresenter is IImportanceOfAimsAndObjectivesPresenter) && IsLoggedIn; }
}
public bool CanGotoGotoAimsAndObjectives
{
get { return !(CurrentPresenter is IAimsAndObjectivesPresenter) && IsLoggedIn; }
}
Use Generics
private bool SomeFuncName<T>()
{
return !(CurrentPresenter is T) && IsLoggedIn;
}
usage:
public bool CanGotoGotoAimsAndObjectives {
get { return SomeFuncName<IAimsAndObjectivesPresenter>(); }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With