foreach (var interfaceType in animal.GetType().GetInterfaces())
{
Console.WriteLine(interfaceType);
}
}
Mixin模式
复制代码 代码如下:
{
Console.WriteLine("\n*************Mixin*************\n");
var generator = new ProxyGenerator();
var options = new ProxyGenerationOptions();
options.AddMixinInstance(new RunAbility());
var animal = generator.CreateClassProxy<Animal>(options, new AnimalInterceptor());
animal.Play();
(animal as IRunable).Run();
Console.WriteLine(animal.GetType());
Console.WriteLine(animal.GetType().BaseType);
var compositeField = animal.GetType().GetField("__target");
Console.WriteLine(compositeField);
foreach (var field in animal.GetType().GetFields())
{
if (field.Name.StartsWith("__mixin"))
{
Console.WriteLine(field);
}
}
foreach (var interfaceType in animal.GetType().GetInterfaces())
{
Console.WriteLine(interfaceType);
}
}
您可能感兴趣的文章: