Created
August 7, 2018 16:47
-
-
Save Devcon4/b53371ea60dcc859c67f8f356cd3dc72 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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