예제 #1
0
        public TOutput Convert <TInput, TOutput>(TInput input, string processorName, OpaqueDataDictionary processorParameters)
        {
            var processor = ContentProcessors.FirstOrDefault(p => p.GetType().Name == processorName);

            if (processor == null)
            {
                throw new InvalidOperationException(string.Format("Cannot find processor {0}", processorName));
            }

            ApplyParameters(processor, processorParameters);
            return((TOutput)processor.Process(input, ProcessorContext));
        }
예제 #2
0
        public TOutput Convert <TInput, TOutput>(TInput input, string processorName, OpaqueDataDictionary processorParameters)
        {
            try
            {
                var processor = ContentProcessors.FirstOrDefault(p => p.GetType().Name == processorName);
                if (processor == null)
                {
                    throw new InvalidOperationException(string.Format("Cannot find processor {0}", processorName));
                }

                ApplyParameters(processor, processorParameters);
                processorContext = processorContext ?? new PipelineProcessorContext(this);
                return((TOutput)processor.Process(input, processorContext));
            }
            catch (Exception e)
            {
                Trace.TraceError("Error converting {0} with processor {1}", input.GetType().Name, processorName);
                Trace.WriteLine(e);
                throw new InvalidContentException("", e);
            }
        }