Beispiel #1
0
        private void RegisterOutputWriters()
        {
            if (_engineConfiguration.OutputConfigs == null)
            {
                throw new ResourceStaticAnalysisEngineConfigException("At least one Output configuration must be specified in config.");
            }

            foreach (OutputWriterConfig owc in this._engineConfiguration.OutputConfigs)
            {
                IOutputWriter ow = null;
                try
                {
                    ow = (IOutputWriter)Activator.CreateInstance(owc.Kind.GetTypeFromModule());
                    Trace.TraceInformation("Initializing OutputWriter: {0}.", ow.GetType().FullName);
                    ow.Initialize(owc);
                    _outputWriters.Add(ow);
                }
                catch (TypeLoadException e)
                {
                    throw new ResourceStaticAnalysisEngineInitializationException(String.Format(CultureInfo.CurrentCulture, "ERROR: Error while trying to create IOutputWriter of type {0}. This type is not a known type.",
                                                                                                owc.Kind), e);
                }
                catch (FileNotFoundException e)
                {
                    throw new ResourceStaticAnalysisEngineInitializationException(String.Format(CultureInfo.CurrentCulture, "ERROR: Error while trying to create IOutputWriter of type {0}. Failed loading assemblies.",
                                                                                                owc.Kind), e);
                }
                catch (Exception e)
                {
                    if (ow == null)
                    {
                        throw new ResourceStaticAnalysisEngineInitializationException(String.Format(CultureInfo.CurrentCulture, "ERROR: Error while trying to create IOutputWriter of type {0}. This type is not a IOutputWriter.",
                                                                                                    owc.Kind), e);
                    }
                    else
                    {
                        throw new ResourceStaticAnalysisEngineInitializationException(String.Format(CultureInfo.CurrentCulture, "ERROR: Error while trying to create IOutputWriter of type {0}.",
                                                                                                    owc.Kind), e);
                    }
                }
            }
        }