Example #1
0
        public IEnumerable <IInterceptor> DetermineInterceptors(Type pluginType, Instance instance)
        {
            if (!_filter(instance))
            {
                yield break;
            }

            if (pluginType == _pluginType)
            {
                yield return(new DecoratorInterceptor(pluginType, _instance));
            }
            else if (_pluginType.IsOpenGeneric() && pluginType.GetTypeInfo().IsGenericType&&
                     pluginType.GetTypeInfo().GetGenericTypeDefinition() == _pluginType)
            {
                var parameters     = pluginType.GetGenericArguments();
                var closedInstance = _instance.CloseType(parameters) as IConfiguredInstance;

                yield return(new DecoratorInterceptor(pluginType, closedInstance));
            }
        }