Beispiel #1
0
        public const int REGEX = 1;  // regex replaces

        public static string PostProcess(string text, string langCode)
        {
            try
            {
                IPostProcessor processor = ProcessorFactory.createProcessor((ISO639)Enum.Parse(typeof(ISO639), langCode.Substring(0, 3)));
                return(processor.PostProcess(text));
            }
            catch
            {
                return(text);
            }
        }
Beispiel #2
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);
        }
Beispiel #3
0
        public static string PostProcess(string text, string langCode)
        {
            IPostProcessor processor = ProcessorFactory.createProcessor((ISO639)Enum.Parse(typeof(ISO639), langCode));

            return(processor.PostProcess(text));
        }