/// <summary> /// Initializes a new instance of the <see cref="GetChocolatey"/> class. /// </summary> public GetChocolatey() { Log4NetAppenderConfiguration.configure(null, excludeLoggerNames: ChocolateyLoggers.Trace.to_string()); Bootstrap.initialize(); _license = License.validate_license(); _container = SimpleInjectorContainer.Container; }
private static void add_or_remove_licensed_source(ChocolateyLicense license, Container container) { var addOrUpdate = license.IsValid; var config = new ChocolateyConfiguration { RegularOutput = false, QuietOutput = true, }; var sourceService = container.GetInstance<IChocolateyConfigSettingsService>(); var sources = sourceService.source_list(config); config.SourceCommand.Name = ApplicationParameters.ChocolateyLicensedFeedSourceName; config.Sources = ApplicationParameters.ChocolateyLicensedFeedSource; config.SourceCommand.Username = "******"; config.SourceCommand.Password = license.Id; config.SourceCommand.Priority = 10; if (addOrUpdate && !sources.Any(s => s.Id.is_equal_to(ApplicationParameters.ChocolateyLicensedFeedSourceName) && s.Authenticated) ) { sourceService.source_add(config); } if (!addOrUpdate) { sourceService.source_remove(config); } }
private static void add_or_remove_licensed_source(ChocolateyLicense license, ConfigFileSettings configFileSettings) { // do not enable or disable the source, in case the user has disabled it var addOrUpdate = license.IsValid; var sources = configFileSettings.Sources.or_empty_list_if_null().ToList(); var configSource = new ConfigFileSourceSetting { Id = ApplicationParameters.ChocolateyLicensedFeedSourceName, Value = ApplicationParameters.ChocolateyLicensedFeedSource, UserName = "******", Password = NugetEncryptionUtility.EncryptString(license.Id), Priority = 10, BypassProxy = false, AllowSelfService = false, VisibleToAdminsOnly = false, }; if (addOrUpdate && !sources.Any(s => s.Id.is_equal_to(ApplicationParameters.ChocolateyLicensedFeedSourceName) && NugetEncryptionUtility.DecryptString(s.Password).is_equal_to(license.Id) ) ) { configFileSettings.Sources.Add(configSource); } if (!addOrUpdate) { configFileSettings.Sources.RemoveWhere(s => s.Id.is_equal_to(configSource.Id)); } // ensure only one licensed source - helpful when moving between licenses configFileSettings.Sources.RemoveWhere(s => s.Id.is_equal_to(configSource.Id) && !NugetEncryptionUtility.DecryptString(s.Password).is_equal_to(license.Id)); }
private static void add_or_remove_licensed_source(ChocolateyLicense license, Container container) { var addOrUpdate = license.IsValid; var config = new ChocolateyConfiguration { RegularOutput = false, QuietOutput = true, }; var sourceService = container.GetInstance <IChocolateyConfigSettingsService>(); var sources = sourceService.source_list(config); config.SourceCommand.Name = ApplicationParameters.ChocolateyLicensedFeedSourceName; config.Sources = ApplicationParameters.ChocolateyLicensedFeedSource; config.SourceCommand.Username = "******"; config.SourceCommand.Password = license.Id; config.SourceCommand.Priority = 10; if (addOrUpdate && !sources.Any(s => s.Id.is_equal_to(ApplicationParameters.ChocolateyLicensedFeedSourceName) && s.Authenticated) ) { sourceService.source_add(config); } if (!addOrUpdate) { sourceService.source_remove(config); } }
private static void add_or_remove_licensed_source(ChocolateyLicense license, ConfigFileSettings configFileSettings) { // do not enable or disable the source, in case the user has disabled it var addOrUpdate = license.IsValid; var sources = configFileSettings.Sources.Where(s => !s.Disabled).or_empty_list_if_null().ToList(); var configSource = new ConfigFileSourceSetting { Id = ApplicationParameters.ChocolateyLicensedFeedSourceName, Value = ApplicationParameters.ChocolateyLicensedFeedSource, UserName = "******", Password = NugetEncryptionUtility.EncryptString(license.Id), Priority = 10 }; if (addOrUpdate && !sources.Any(s => s.Id.is_equal_to(ApplicationParameters.ChocolateyLicensedFeedSourceName) && NugetEncryptionUtility.DecryptString(s.Password).is_equal_to(license.Id) ) ) { configFileSettings.Sources.Add(configSource); } if (!addOrUpdate) { configFileSettings.Sources.RemoveWhere(s => s.Id.is_equal_to(configSource.Id)); } }
/// <summary> /// Initializes a new instance of the <see cref="GetChocolatey"/> class. /// </summary> public GetChocolatey() { Log4NetAppenderConfiguration.configure(); Bootstrap.initialize(); _license = License.validate_license(); _container = SimpleInjectorContainer.Container; }
private static void set_licensed_options(ChocolateyConfiguration config, ChocolateyLicense license, ConfigFileSettings configFileSettings) { config.Information.IsLicensedVersion = license.is_licensed_version(); config.Information.LicenseType = license.LicenseType.get_description_or_value(); if (license.AssemblyLoaded) { Type licensedConfigBuilder = license.Assembly.GetType(ApplicationParameters.LicensedConfigurationBuilder, throwOnError: false, ignoreCase: true); if (licensedConfigBuilder == null) { if (config.RegularOutput) { "chocolatey".Log().Warn(ChocolateyLoggers.Important, @"Unable to set licensed configuration. Please upgrade to a newer licensed version (choco upgrade chocolatey.extension)."); } return; } try { object componentClass = Activator.CreateInstance(licensedConfigBuilder); licensedConfigBuilder.InvokeMember( SET_CONFIGURATION_METHOD, BindingFlags.InvokeMethod, null, componentClass, new Object[] { config, configFileSettings } ); } catch (Exception ex) { var isDebug = ApplicationParameters.is_debug_mode_cli_primitive(); if (config.Debug) { isDebug = true; } var message = isDebug ? ex.ToString() : ex.Message; if (isDebug && ex.InnerException != null) { message += "{0}{1}".format_with(Environment.NewLine, ex.ToString()); } "chocolatey".Log().Error( ChocolateyLoggers.Important, @"Error when setting configuration for '{0}':{1} {2}".format_with( licensedConfigBuilder.FullName, Environment.NewLine, message )); } } }
/// <summary> /// Initializes a new instance of the <see cref="GetChocolatey"/> class. /// </summary> public GetChocolatey() { Log4NetAppenderConfiguration.configure(null, excludeLoggerNames: ChocolateyLoggers.Trace.to_string()); Bootstrap.initialize(); Log.InitializeWith(new AggregateLog(new List <ILog>() { new Log4NetLog(), _logSinkLogger })); _license = License.validate_license(); _container = SimpleInjectorContainer.Container; }
/// <summary> /// Sets up the configuration based on arguments passed in, config file, and environment /// </summary> /// <param name="args">The arguments.</param> /// <param name="config">The configuration.</param> /// <param name="container">The container.</param> /// <param name="license">The license.</param> /// <param name="notifyWarnLoggingAction">Notify warn logging action</param> public static void set_up_configuration(IList<string> args, ChocolateyConfiguration config, Container container, ChocolateyLicense license, Action<string> notifyWarnLoggingAction) { var fileSystem = container.GetInstance<IFileSystem>(); var xmlService = container.GetInstance<IXmlService>(); set_file_configuration(config, fileSystem, xmlService, notifyWarnLoggingAction); ConfigurationOptions.reset_options(); set_global_options(args, config, container); set_environment_options(config); set_license_options(config, license); set_environment_variables(config); }
private static void set_license_options(ChocolateyConfiguration config, ChocolateyLicense license) { config.Information.LicenseExpirationDate = license.ExpirationDate; config.Information.LicenseIsValid = license.IsValid; config.Information.LicenseVersion = license.Version ?? string.Empty; config.Information.LicenseType = license.is_licensed_version() ? license.LicenseType.get_description_or_value() : string.Empty; var licenseName = license.Name.to_string(); if (licenseName.Contains("@")) { licenseName = licenseName.Remove(licenseName.IndexOf("@", StringComparison.InvariantCulture)) + "[at REDACTED])"; } config.Information.LicenseUserName = licenseName; }
/// <summary> /// Sets up the configuration based on arguments passed in, config file, and environment /// </summary> /// <param name="args">The arguments.</param> /// <param name="config">The configuration.</param> /// <param name="container">The container.</param> /// <param name="license">The license.</param> /// <param name="notifyWarnLoggingAction">Notify warn logging action</param> public static void set_up_configuration(IList<string> args, ChocolateyConfiguration config, Container container, ChocolateyLicense license, Action<string> notifyWarnLoggingAction) { var fileSystem = container.GetInstance<IFileSystem>(); var xmlService = container.GetInstance<IXmlService>(); var configFileSettings = get_config_file_settings(fileSystem, xmlService); // must be done prior to setting the file configuration add_or_remove_licensed_source(license, configFileSettings); set_file_configuration(config, configFileSettings, fileSystem, notifyWarnLoggingAction); ConfigurationOptions.reset_options(); set_global_options(args, config, container); set_environment_options(config); set_environment_variables(config); // must be done last for overrides set_licensed_options(config, license, configFileSettings); // save all changes if there are any set_config_file_settings(configFileSettings, xmlService); }
public GetChocolatey(bool initializeLogging) { _container = SimpleInjectorContainer.Container; if (initializeLogging) { string loggingLocation = ApplicationParameters.LoggingLocation; var fileSystem = _container.GetInstance <IFileSystem>(); fileSystem.create_directory_if_not_exists(loggingLocation); Log4NetAppenderConfiguration.configure(loggingLocation, excludeLoggerNames: ChocolateyLoggers.Trace.to_string()); Log.InitializeWith(new AggregateLog(new List <ILog>() { new Log4NetLog(), _logSinkLogger })); "chocolatey".Log().Debug("XmlConfiguration is now operational"); } _license = License.validate_license(); }
private static void set_licensed_options(ChocolateyConfiguration config, ChocolateyLicense license, ConfigFileSettings configFileSettings) { config.Information.IsLicensedVersion = license.is_licensed_version(); if (license.AssemblyLoaded) { Type licensedConfigBuilder = license.Assembly.GetType(ApplicationParameters.LicensedConfigurationBuilder, throwOnError: false, ignoreCase: true); if (licensedConfigBuilder == null) { if (config.RegularOutput) { "chocolatey".Log().Warn(ChocolateyLoggers.Important, @"Unable to set licensed configuration. Please upgrade to a newer licensed version."); } return; } try { object componentClass = Activator.CreateInstance(licensedConfigBuilder); licensedConfigBuilder.InvokeMember( SET_CONFIGURATION_METHOD, BindingFlags.InvokeMethod, null, componentClass, new Object[] { config, configFileSettings } ); } catch (Exception ex) { "chocolatey".Log().Error( ChocolateyLoggers.Important, @"Error when setting configuration for '{0}':{1} {2}".format_with( licensedConfigBuilder.FullName, Environment.NewLine, ex.Message )); } } }
private static void set_licensed_options(ChocolateyConfiguration config, ChocolateyLicense license, ConfigFileSettings configFileSettings) { if (license.AssemblyLoaded) { Type licensedConfigBuilder = license.Assembly.GetType(ApplicationParameters.LicensedConfigurationBuilder, throwOnError: true, ignoreCase: true); if (licensedConfigBuilder == null) { "chocolatey".Log().Error( @"Type expected for registering components was null. Unable to provide name due to it being null."); return; } try { object componentClass = Activator.CreateInstance(licensedConfigBuilder); licensedConfigBuilder.InvokeMember( SET_CONFIGURATION_METHOD, BindingFlags.InvokeMethod, null, componentClass, new Object[] { config, configFileSettings } ); } catch (Exception ex) { "chocolatey".Log().Error( ChocolateyLoggers.Important, @"Error when setting configuration for '{0}':{1} {2}".format_with( licensedConfigBuilder.FullName, Environment.NewLine, ex.Message )); } } }
private static void set_license_options(ChocolateyConfiguration config, ChocolateyLicense license) { config.Information.LicenseExpirationDate = license.ExpirationDate; config.Information.LicenseIsValid = license.IsValid; config.Information.LicenseVersion = license.Version ?? string.Empty; config.Information.LicenseType = license.is_licensed_version() ? license.LicenseType.get_description_or_value() : string.Empty; var licenseName = license.Name.to_string(); if (licenseName.Contains("@")) { licenseName = licenseName.Remove(licenseName.IndexOf("@", StringComparison.InvariantCulture)) + "[at REDACTED])"; } config.Information.LicenseUserName = licenseName; }
/// <summary> /// Sets up the configuration based on arguments passed in, config file, and environment /// </summary> /// <param name="args">The arguments.</param> /// <param name="config">The configuration.</param> /// <param name="container">The container.</param> /// <param name="license">The license.</param> /// <param name="notifyWarnLoggingAction">Notify warn logging action</param> public static void set_up_configuration(IList <string> args, ChocolateyConfiguration config, Container container, ChocolateyLicense license, Action <string> notifyWarnLoggingAction) { var fileSystem = container.GetInstance <IFileSystem>(); var xmlService = container.GetInstance <IXmlService>(); var configFileSettings = get_config_file_settings(fileSystem, xmlService); // must be done prior to setting the file configuration add_or_remove_licensed_source(license, configFileSettings); set_file_configuration(config, configFileSettings, fileSystem, notifyWarnLoggingAction); ConfigurationOptions.reset_options(); set_global_options(args, config, container); set_environment_options(config); set_environment_variables(config); // must be done last for overrides set_licensed_options(config, license, configFileSettings); // save all changes if there are any set_config_file_settings(configFileSettings, xmlService); }
private static void set_licensed_options(ChocolateyConfiguration config, ChocolateyLicense license, ConfigFileSettings configFileSettings) { config.Information.IsLicensedVersion = license.is_licensed_version(); config.Information.LicenseType = license.LicenseType.get_description_or_value(); if (license.AssemblyLoaded) { Type licensedConfigBuilder = license.Assembly.GetType(ApplicationParameters.LicensedConfigurationBuilder, throwOnError: false, ignoreCase: true); if (licensedConfigBuilder == null) { if (config.RegularOutput) "chocolatey".Log().Warn(ChocolateyLoggers.Important, @"Unable to set licensed configuration. Please upgrade to a newer licensed version."); return; } try { object componentClass = Activator.CreateInstance(licensedConfigBuilder); licensedConfigBuilder.InvokeMember( SET_CONFIGURATION_METHOD, BindingFlags.InvokeMethod, null, componentClass, new Object[] { config, configFileSettings } ); } catch (Exception ex) { "chocolatey".Log().Error( ChocolateyLoggers.Important, @"Error when setting configuration for '{0}':{1} {2}".format_with( licensedConfigBuilder.FullName, Environment.NewLine, ex.Message )); } } }
private static void add_or_remove_licensed_source(ChocolateyLicense license, ConfigFileSettings configFileSettings) { // do not enable or disable the source, in case the user has disabled it var addOrUpdate = license.IsValid; var sources = configFileSettings.Sources.or_empty_list_if_null().ToList(); var configSource = new ConfigFileSourceSetting { Id = ApplicationParameters.ChocolateyLicensedFeedSourceName, Value = ApplicationParameters.ChocolateyLicensedFeedSource, UserName = "******", Password = NugetEncryptionUtility.EncryptString(license.Id), Priority = 10 }; if (addOrUpdate && !sources.Any(s => s.Id.is_equal_to(ApplicationParameters.ChocolateyLicensedFeedSourceName) && NugetEncryptionUtility.DecryptString(s.Password).is_equal_to(license.Id) ) ) { configFileSettings.Sources.Add(configSource); } if (!addOrUpdate) { configFileSettings.Sources.RemoveWhere(s => s.Id.is_equal_to(configSource.Id)); } }
// ReSharper disable InconsistentNaming private static void Main(string[] args) // ReSharper restore InconsistentNaming { ChocolateyConfiguration config = null; ChocolateyLicense license = null; try { add_assembly_resolver(); string loggingLocation = ApplicationParameters.LoggingLocation; //no file system at this point if (!Directory.Exists(loggingLocation)) { Directory.CreateDirectory(loggingLocation); } Log4NetAppenderConfiguration.configure(loggingLocation, excludeLoggerNames: ChocolateyLoggers.Trace.to_string()); Bootstrap.initialize(); Bootstrap.startup(); license = License.validate_license(); var container = SimpleInjectorContainer.Container; "LogFileOnly".Log().Info(() => "".PadRight(60, '=')); config = Config.get_configuration_settings(); var fileSystem = container.GetInstance <IFileSystem>(); var warnings = new List <string>(); ConfigurationBuilder.set_up_configuration( args, config, container, license, warning => { warnings.Add(warning); } ); if (license.is_licensed_version() && !license.IsCompatible && !config.DisableCompatibilityChecks) { write_warning_for_incompatible_versions(); } if (config.Features.LogWithoutColor) { ApplicationParameters.Log4NetConfigurationResource = @"chocolatey.infrastructure.logging.log4net.nocolor.config.xml"; Log4NetAppenderConfiguration.configure(loggingLocation, excludeLoggerNames: ChocolateyLoggers.Trace.to_string()); } if (!string.IsNullOrWhiteSpace(config.AdditionalLogFileLocation)) { Log4NetAppenderConfiguration.configure_additional_log_file(fileSystem.get_full_path(config.AdditionalLogFileLocation)); } report_version_and_exit_if_requested(args, config); trap_exit_scenarios(config); warn_on_nuspec_or_nupkg_usage(args, config); if (config.RegularOutput) { #if DEBUG "chocolatey".Log().Info(ChocolateyLoggers.Important, () => "{0} v{1}{2} (DEBUG BUILD)".format_with(ApplicationParameters.Name, config.Information.ChocolateyProductVersion, license.is_licensed_version() ? " {0}".format_with(license.LicenseType) : string.Empty)); #else "chocolatey".Log().Info(ChocolateyLoggers.Important, () => "{0} v{1}{2}".format_with(ApplicationParameters.Name, config.Information.ChocolateyProductVersion, license.is_licensed_version() ? " {0}".format_with(license.LicenseType) : string.Empty)); #endif if (args.Length == 0) { "chocolatey".Log().Info(ChocolateyLoggers.Important, () => "Please run 'choco -?' or 'choco <command> -?' for help menu."); } } if (warnings.Count != 0 && config.RegularOutput) { foreach (var warning in warnings.or_empty_list_if_null()) { "chocolatey".Log().Warn(ChocolateyLoggers.Important, warning); } } if (config.HelpRequested || config.UnsuccessfulParsing) { pause_execution_if_debug(); Environment.Exit(config.UnsuccessfulParsing ? 1 : 0); } var verboseAppenderName = "{0}LoggingColoredConsoleAppender".format_with(ChocolateyLoggers.Verbose.to_string()); var traceAppenderName = "{0}LoggingColoredConsoleAppender".format_with(ChocolateyLoggers.Trace.to_string()); Log4NetAppenderConfiguration.set_logging_level_debug_when_debug(config.Debug, verboseAppenderName, traceAppenderName); Log4NetAppenderConfiguration.set_verbose_logger_when_verbose(config.Verbose, config.Debug, verboseAppenderName); Log4NetAppenderConfiguration.set_trace_logger_when_trace(config.Trace, traceAppenderName); "chocolatey".Log().Debug(() => "{0} is running on {1} v {2}".format_with(ApplicationParameters.Name, config.Information.PlatformType, config.Information.PlatformVersion.to_string())); //"chocolatey".Log().Debug(() => "Command Line: {0}".format_with(Environment.CommandLine)); remove_old_chocolatey_exe(fileSystem); AssemblyFileExtractor.extract_all_resources_to_relative_directory(fileSystem, Assembly.GetAssembly(typeof(Program)), ApplicationParameters.InstallLocation, new List <string>(), "chocolatey.console", throwError: false); //refactor - thank goodness this is temporary, cuz manifest resource streams are dumb IList <string> folders = new List <string> { "helpers", "functions", "redirects", "tools" }; #if !NoResources AssemblyFileExtractor.extract_all_resources_to_relative_directory(fileSystem, Assembly.GetAssembly(typeof(ChocolateyResourcesAssembly)), ApplicationParameters.InstallLocation, folders, ApplicationParameters.ChocolateyFileResources, throwError: false); #endif var application = new ConsoleApplication(); application.run(args, config, container); } catch (Exception ex) { if (ApplicationParameters.is_debug_mode_cli_primitive()) { "chocolatey".Log().Error(() => "{0} had an error occur:{1}{2}".format_with( ApplicationParameters.Name, Environment.NewLine, ex.ToString())); } else { "chocolatey".Log().Error(ChocolateyLoggers.Important, () => "{0}".format_with(ex.Message)); "chocolatey".Log().Error(ChocolateyLoggers.LogFileOnly, () => "More Details: {0}".format_with(ex.ToString())); } if (Environment.ExitCode == 0) { Environment.ExitCode = 1; } } finally { if (license != null && license.is_licensed_version() && !license.IsCompatible && config != null && !config.DisableCompatibilityChecks) { write_warning_for_incompatible_versions(); } "chocolatey".Log().Debug(() => "Exiting with {0}".format_with(Environment.ExitCode)); #if DEBUG "chocolatey".Log().Info(() => "Exiting with {0}".format_with(Environment.ExitCode)); #endif pause_execution_if_debug(); Bootstrap.shutdown(); Environment.Exit(Environment.ExitCode); } }
/// <summary> /// Sets up the configuration based on arguments passed in, config file, and environment /// </summary> /// <param name="args">The arguments.</param> /// <param name="config">The configuration.</param> /// <param name="container">The container.</param> /// <param name="license">The license.</param> /// <param name="notifyWarnLoggingAction">Notify warn logging action</param> public static void set_up_configuration(IList <string> args, ChocolateyConfiguration config, Container container, ChocolateyLicense license, Action <string> notifyWarnLoggingAction) { var fileSystem = container.GetInstance <IFileSystem>(); var xmlService = container.GetInstance <IXmlService>(); set_file_configuration(config, fileSystem, xmlService, notifyWarnLoggingAction); ConfigurationOptions.reset_options(); set_global_options(args, config, container); set_environment_options(config); set_license_options(config, license); set_environment_variables(config); }
/// <summary> /// Sets up the configuration based on arguments passed in, config file, and environment /// </summary> /// <param name="args">The arguments.</param> /// <param name="config">The configuration.</param> /// <param name="container">The container.</param> /// <param name="license">The license.</param> /// <param name="notifyWarnLoggingAction">Notify warn logging action</param> public static void set_up_configuration(IList <string> args, ChocolateyConfiguration config, Container container, ChocolateyLicense license, Action <string> notifyWarnLoggingAction) { var fileSystem = container.GetInstance <IFileSystem>(); var xmlService = container.GetInstance <IXmlService>(); var configFileSettings = get_config_file_settings(fileSystem, xmlService); // must be done prior to setting the file configuration add_or_remove_licensed_source(license, configFileSettings); set_file_configuration(config, configFileSettings, fileSystem, notifyWarnLoggingAction); ConfigurationOptions.reset_options(); set_global_options(args, config, container); set_environment_options(config); set_environment_variables(config); // must be done last for overrides set_licensed_options(config, license, configFileSettings); // save all changes if there are any set_config_file_settings(configFileSettings, xmlService); if (!config.Features.UseFipsCompliantChecksums) { var hashprovider = container.GetInstance <IHashProvider>(); try { hashprovider.set_hash_algorithm(CryptoHashProviderType.Md5); } catch (Exception ex) { if (!config.CommandName.is_equal_to("feature")) { if (ex.InnerException != null && ex.InnerException.Message.contains("FIPS")) { "chocolatey".Log().Warn(ChocolateyLoggers.Important, @" FIPS Mode detected - run 'choco feature enable -n {0}' to use Chocolatey.".format_with(ApplicationParameters.Features.UseFipsCompliantChecksums)); throw new ApplicationException("When FIPS Mode is enabled, Chocolatey requires {0} feature also be enabled.".format_with(ApplicationParameters.Features.UseFipsCompliantChecksums)); } throw; } } } }
private static void set_licensed_options(ChocolateyConfiguration config, ChocolateyLicense license, ConfigFileSettings configFileSettings) { if (license.AssemblyLoaded) { Type licensedConfigBuilder = license.Assembly.GetType(ApplicationParameters.LicensedConfigurationBuilder, throwOnError: false, ignoreCase: true); if (licensedConfigBuilder == null) { "chocolatey".Log().Warn(ChocolateyLoggers.Important, @"Unable to set licensed configuration. This is likely related to a missing or outdated licensed DLL."); return; } try { object componentClass = Activator.CreateInstance(licensedConfigBuilder); licensedConfigBuilder.InvokeMember( SET_CONFIGURATION_METHOD, BindingFlags.InvokeMethod, null, componentClass, new Object[] { config, configFileSettings } ); } catch (Exception ex) { "chocolatey".Log().Error( ChocolateyLoggers.Important, @"Error when setting configuration for '{0}':{1} {2}".format_with( licensedConfigBuilder.FullName, Environment.NewLine, ex.Message )); } } }
private static void set_licensed_options(ChocolateyConfiguration config, ChocolateyLicense license, ConfigFileSettings configFileSettings) { if (license.AssemblyLoaded) { Type licensedConfigBuilder = license.Assembly.GetType(ApplicationParameters.LicensedConfigurationBuilder, throwOnError: true, ignoreCase: true); if (licensedConfigBuilder == null) { "chocolatey".Log().Error( @"Type expected for registering components was null. Unable to provide name due to it being null."); return; } try { object componentClass = Activator.CreateInstance(licensedConfigBuilder); licensedConfigBuilder.InvokeMember( SET_CONFIGURATION_METHOD, BindingFlags.InvokeMethod, null, componentClass, new Object[] { config, configFileSettings } ); } catch (Exception ex) { "chocolatey".Log().Error( ChocolateyLoggers.Important, @"Error when setting configuration for '{0}':{1} {2}".format_with( licensedConfigBuilder.FullName, Environment.NewLine, ex.Message )); } } }