Skip to content

Instantly share code, notes, and snippets.

@kyubuns
Last active December 15, 2017 09:54
Show Gist options
  • Save kyubuns/eab77c4fdfa188cc7fd5b8565b1c005f to your computer and use it in GitHub Desktop.
Save kyubuns/eab77c4fdfa188cc7fd5b8565b1c005f to your computer and use it in GitHub Desktop.
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