Skip to content

Instantly share code, notes, and snippets.

@Devcon4
Created August 7, 2018 16:47
Show Gist options
  • Select an option

  • Save Devcon4/b53371ea60dcc859c67f8f356cd3dc72 to your computer and use it in GitHub Desktop.

Select an option

Save Devcon4/b53371ea60dcc859c67f8f356cd3dc72 to your computer and use it in GitHub Desktop.
public interface ISendEmail<in T>
{
void SendEmail(T param);
}
public interface ISendInApp<in T>
{
void SendInApp(T param);
}
abstract class NotificationBase<T> {
public virtual void Trigger() { }
internal void Trigger(T param) {
if (this is ISendEmail<T> t1)
{
t1.SendEmail(param);
}
if (this is ISendInApp<T> t2)
{
t2.SendInApp(param);
}
}
}
struct MyParams {
public string emailBody;
}
class TestNotification: NotificationBase<MyParams>, ISendEmail<MyParams>, ISendInApp<MyParams> {
public override void Trigger() {
var param = new MyParams {
emailBody = "Test"
};
base.Trigger(param);
}
public void SendEmail(MyParams param)
{
throw new NotImplementedException();
}
public void SendInApp(MyParams param)
{
throw new NotImplementedException();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment