Last active
December 15, 2017 09:54
-
-
Save kyubuns/eab77c4fdfa188cc7fd5b8565b1c005f 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
using UniRx; | |
namespace Development | |
{ | |
public static class MessagePublisherExtensions | |
{ | |
public static void PublishWithBaseType<T>(this IMessagePublisher self, T message) | |
{ | |
self.Publish(message); | |
for (var baseType = typeof(T).BaseType; null != baseType; baseType = baseType.BaseType) | |
{ | |
typeof(IMessagePublisher) | |
.GetMethod(nameof(IMessagePublisher.Publish)) | |
.MakeGenericMethod(baseType) | |
.Invoke(self, new object[] {message}); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment