///<summary>
        /// Generate an aggregate service instance that will resolve its types from <paramref name="context"/>.
        ///</summary>
        ///<param name="context">The component context from where types will be resolved</param>
        ///<param name="interfaceType">The interface type for the aggregate service</param>
        ///<returns>The aggregate service instance</returns>
        /// <exception cref="ArgumentException">Thrown if <paramref name="interfaceType"/> is not an interface</exception>
        public static object CreateInstance(Type interfaceType, IComponentContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (interfaceType == null)
            {
                throw new ArgumentNullException("interfaceType");
            }
            if (!interfaceType.IsInterface)
            {
                throw new ArgumentException("Type must be an interface", "interfaceType");
            }

            var resolverInterceptor = new ResolvingInterceptor(interfaceType, context);

            return(Generator.CreateInterfaceProxyWithoutTarget(interfaceType, resolverInterceptor));
        }
        /// <summary>
        /// Generate an aggregate service instance that will resolve its types from <paramref name="context"/>.
        /// </summary>
        /// <param name="context">The component context from where types will be resolved.</param>
        /// <param name="interfaceType">The interface type for the aggregate service.</param>
        /// <returns>The aggregate service instance.</returns>
        /// <exception cref="ArgumentException">Thrown if <paramref name="interfaceType"/> is not an interface.</exception>
        public static object CreateInstance(Type interfaceType, IComponentContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (interfaceType == null)
            {
                throw new ArgumentNullException(nameof(interfaceType));
            }

            if (!interfaceType.GetTypeInfo().IsInterface)
            {
                throw new ArgumentException(AggregateServicesResources.GetString("TypeMustBeInterface"), nameof(interfaceType));
            }

            var resolverInterceptor = new ResolvingInterceptor(interfaceType, context);

            return(Generator.CreateInterfaceProxyWithoutTarget(interfaceType, resolverInterceptor));
        }