예제 #1
0
        object ICreateCallback.InstanceCreated(CreateContext context, IBuildPlan buildPlan, object instance)
        {
            if (_decorators.Count == 0)
            {
                return(instance);
            }

            var ctx = new DecoratorContext(buildPlan.Services, buildPlan.Lifetime)
            {
                Instance = instance, RequestedService = context.RequestedService
            };

            foreach (var decorator in _decorators)
            {
                decorator.Decorate(ctx);
            }

            return(ctx.Instance);
        }