Example #1
0
 /// <summary>Puts a collection of given items through the preprocessor.</summary>
 /// <typeparam name="T">The type of object to process.</typeparam>
 /// <param name="Processor">The processor to use.</param>
 /// <param name="Items">The items to process.</param>
 /// <returns>Puts a collection of given items through the processor.</returns>
 public static void Preprocess <T>(this IPreProcessor <T> Processor, IEnumerable <T> Items)
 {
     foreach (T Item in Items)
     {
         Processor.Preprocess(Item);
     }
 }
Example #2
0
 /// <summary>Puts a collection of given items through the preprocessor.</summary>
 /// <typeparam name="T">The type of object to process.</typeparam>
 /// <typeparam name="TypeContext">The type of the context.</typeparam>
 /// <param name="Processor">The processor to use.</param>
 /// <param name="Items">The items to process.</param>
 /// <param name="Context">The context needed to process.</param>
 public static void Preprocess <T, TypeContext>(this IPreProcessor <T, TypeContext> Processor, IEnumerable <T> Items, TypeContext Context)
 {
     foreach (T Item in Items)
     {
         Processor.Preprocess(Item, Context);
     }
 }
Example #3
0
        /// <summary>Puts a collection of given items through the preprocessor.</summary>
        /// <typeparam name="T">The type of object to process.</typeparam>
        /// <param name="Processor">The processor to use.</param>
        /// <param name="Items">The items to process.</param>
        /// <returns>Puts a collection of given items through the processor.</returns>
        public static void Preprocess <T>(this IPreProcessor <T> Processor, IList <T> Items)
        {
            Int32 Count = Items.Count;

            for (Int32 I = 0; I < Count; I++)
            {
                Processor.Preprocess(Items[I]);
            }
        }
Example #4
0
        /// <summary>Puts a collection of given items through the preprocessor.</summary>
        /// <typeparam name="T">The type of object to process.</typeparam>
        /// <param name="Processor">The processor to use.</param>
        /// <param name="Items">The items to process.</param>
        /// <returns>Puts a collection of given items through the processor.</returns>
        public static void Preprocess <T>(this IPreProcessor <T> Processor, T[] Items)
        {
            Int32 Count = Items.Length;

            for (Int32 I = 0; I < Count; I++)
            {
                Processor.Preprocess(Items[I]);
            }
        }
Example #5
0
        /// <summary>Puts a collection of given items through the preprocessor.</summary>
        /// <typeparam name="T">The type of object to process.</typeparam>
        /// <typeparam name="TypeContext">The type of the context.</typeparam>
        /// <param name="Processor">The processor to use.</param>
        /// <param name="Items">The items to process.</param>
        /// <param name="Context">The context needed to process.</param>
        public static void Preprocess <T, TypeContext>(this IPreProcessor <T, TypeContext> Processor, IList <T> Items, TypeContext Context)
        {
            Int32 Count = Items.Count;

            for (Int32 I = 0; I < Count; I++)
            {
                Processor.Preprocess(Items[I], Context);
            }
        }
Example #6
0
        /// <summary>
        /// Instantiates the service described by the <paramref name="serviceRequest"/>.
        /// </summary>
        /// <param name="serviceRequest">The <see cref="IServiceRequest"/> that describes the service that needs to be instantiated.</param>
        /// <returns>A valid object reference if the service can be found; otherwise, it will return <c>null</c>.</returns>
        public virtual object GetService(IServiceRequest serviceRequest)
        {
            // Allow users to intercept the instantiation process
            if (_preProcessor != null)
            {
                _preProcessor.Preprocess(serviceRequest);
            }

            var factoryRequest = new FactoryRequest
            {
                ServiceType = serviceRequest.ServiceType,
                ServiceName = serviceRequest.ServiceName,
                Arguments   = serviceRequest.ActualArguments,
                Container   = _container
            };

            var instance = _creator.CreateFrom(factoryRequest, serviceRequest.ActualFactory);

            // Postprocess the results
            var result = new ServiceRequestResult
            {
                ServiceName         = serviceRequest.ServiceName,
                ActualResult        = instance,
                Container           = _container,
                OriginalResult      = instance,
                ServiceType         = serviceRequest.ServiceType,
                AdditionalArguments = serviceRequest.ActualArguments
            };

            if (_postProcessor != null)
            {
                _postProcessor.PostProcess(result);
            }

            return(result.ActualResult ?? result.OriginalResult);
        }