Exemplo n.º 1
0
        private SpecFlowGeneratorConfiguration GenSpecFlowGeneratorConfig()
        {
            try
            {
                var specflowGeneratorConfig = new SpecFlowGeneratorConfiguration();

                var configurationHolder = _configurationReader.ReadConfiguration();
                switch (configurationHolder.ConfigSource)
                {
                case ConfigSource.AppConfig:
                    var appConfigFormat    = configurationHolder.TransformConfigurationToOldHolder();
                    var oldGeneratorConfig = new GeneratorConfigurationProvider().LoadConfiguration(appConfigFormat).GeneratorConfiguration;

                    specflowGeneratorConfig.GeneratorPath = oldGeneratorConfig.GeneratorPath;
                    specflowGeneratorConfig.UsesPlugins   = oldGeneratorConfig.UsesPlugins;
                    break;

                case ConfigSource.Json:
                    var defaultSpecFlowConfiguration = ConfigurationLoader.GetDefault();
                    var specflowLoader = new ConfigurationLoader();
                    var jsonConfig     = specflowLoader.Load(defaultSpecFlowConfiguration, configurationHolder);

                    specflowGeneratorConfig.GeneratorPath = jsonConfig.GeneratorPath;
                    specflowGeneratorConfig.UsesPlugins   = jsonConfig.UsesPlugins;
                    break;
                }

                return(specflowGeneratorConfig);
            }
            catch (Exception exception)
            {
                _tracer.Trace("Config load error: " + exception, "VsGeneratorInfoProvider");
                return(new SpecFlowGeneratorConfiguration());
            }
        }
Exemplo n.º 2
0
        private bool DetectFromConfig(GeneratorInfo generatorInfo, SpecFlowGeneratorConfiguration generatorConfiguration)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(generatorConfiguration.GeneratorPath))
                {
                    return(false);
                }

                string generatorFolder = Path.GetFullPath(
                    Path.Combine(VsxHelper.GetProjectFolder(_project), generatorConfiguration.GeneratorPath));

                _tracer.Trace("Generator is configured to be at " + generatorFolder, "VsGeneratorInfoProvider");
                return(DetectFromFolder(generatorInfo, generatorFolder));
            }
            catch (Exception exception)
            {
                _tracer.Trace(exception.ToString(), "VsGeneratorInfoProvider");
                return(false);
            }
        }