Example #1
0
        private MutableMethodInfo ImplementIntroducedMethod(
            Expression implementer, MethodInfo interfaceMethod, MethodDefinition implementingMethod, MemberVisibility visibility)
        {
            var method = visibility == MemberVisibility.Public
                       ? _concreteTarget.GetOrAddImplementation(interfaceMethod)
                       : _concreteTarget.AddExplicitOverride(interfaceMethod, ctx => Expression.Default(ctx.ReturnType));

            method.SetBody(ctx => _expressionBuilder.CreateInitializingDelegation(ctx, _initializationMethod, implementer, interfaceMethod));

            _attributeGenerator.AddIntroducedMemberAttribute(method, interfaceMethod, implementingMethod);
            _attributeGenerator.ReplicateAttributes(implementingMethod, method);

            return(method);
        }