Ejemplo n.º 1
0
 private static void ImplementInterfaces(
     IEnumerable<TypeDefinition> interfacesToImplement,
     InterfaceImplementationWeaver interfaceImplementationWeaver)
 {
     foreach (TypeDefinition interfaceToProxy in interfacesToImplement)
     {
         interfaceImplementationWeaver.CreateImplementationOf(interfaceToProxy);
     }
 }
Ejemplo n.º 2
0
        public static void Execute()
        {
            IEnumerable<TypeDefinition> typesToProxy = WeavingInformation.ModuleDefinition.Types
                .Where(HasStaticProxyAttribute)
                .ToList();

            var constructorWeaver = new ConstructorWeaver();
            var methodWeaver = new MethodWeaver();

            var interfaceImplementationWeaver = new InterfaceImplementationWeaver(constructorWeaver, methodWeaver);
            var classDecorationWeaver = new ClassDecorationWeaver(constructorWeaver, methodWeaver);

            ImplementInterfaces(
                typesToProxy.Where(x => x.IsInterface),
                interfaceImplementationWeaver);

            DecorateClasses(classDecorationWeaver, typesToProxy.Where(x => x.IsClass).ToList());
        }