在使用反射对消息进行分发的时候,会用到判断 Type 是否继承了 Google.Protobuf.IMessage
视频(p62)中使用的方法是 type.IsAssignableTo(typeof(IMessage))
这个方法又调用了IsAssignableFrom方法
如果有实例的话可以直接用as
即 TypeInstance as IMessage != null;
参考文章: https://stackoverflow.com/questions/4963160/how-to-determine-if-a-type-implements-an-interface-with-c-sharp-reflection