public static MainSettings GetMainProperties(ConfigFileUse configFileUse,
                                                     MainSettings currentSettings, WriteToLogDelegate writeToLog)
        {
            var configuration = TwoFilesConfiguration.Create(configFileUse, writeToLog);

            return(GetMainSettingsUsingConfiguration(configuration, currentSettings, writeToLog));
        }
        public MainSettings GetDefault()
        {
            var defaultSettings = new MainSettings();

            defaultSettings.SetDefault();

            return(defaultSettings);
        }
        static MainSettings GetMainSettingsUsingConfiguration(TwoFilesConfiguration configuration,
                                                              MainSettings currentSettings, WriteToLogDelegate writeToLog)
        {
            var resultProperties = new MainSettings();

            resultProperties.LogFontSize = configuration.GetDecimalValue(ConfigurationParameters.LogFontSize,
                                                                         currentSettings.LogFontSize, writeToLog);

            resultProperties.TreeViewFontSize = configuration.GetDecimalValue(ConfigurationParameters.TreeViewFontSize,
                                                                              currentSettings.TreeViewFontSize, writeToLog);

            resultProperties.RetryCount = configuration.GetIntValue(ConfigurationParameters.RetryCountParameter,
                                                                    currentSettings.RetryCount, writeToLog);

            resultProperties.RetryTimeout = configuration.GetIntValue(ConfigurationParameters.RetryTimeoutParameter,
                                                                      currentSettings.RetryTimeout, writeToLog);

            resultProperties.ReceiveTimeout = configuration.GetIntValue(ConfigurationParameters.ReceiveTimeoutParameter,
                                                                        currentSettings.ReceiveTimeout, writeToLog);

            resultProperties.ServerTimeout = configuration.GetIntValue(ConfigurationParameters.ServerTimeoutParameter,
                                                                       currentSettings.ServerTimeout, writeToLog);

            resultProperties.PrefetchCount = configuration.GetIntValue(ConfigurationParameters.PrefetchCountParameter,
                                                                       currentSettings.PrefetchCount, writeToLog);

            resultProperties.TopCount = configuration.GetIntValue(ConfigurationParameters.TopParameter,
                                                                  currentSettings.TopCount, writeToLog);

            resultProperties.SenderThinkTime = configuration.GetIntValue
                                                   (ConfigurationParameters.SenderThinkTimeParameter, currentSettings.SenderThinkTime, writeToLog);

            resultProperties.ReceiverThinkTime = configuration.GetIntValue
                                                     (ConfigurationParameters.ReceiverThinkTimeParameter, currentSettings.ReceiverThinkTime, writeToLog);

            resultProperties.MonitorRefreshInterval = configuration.GetIntValue
                                                          (ConfigurationParameters.MonitorRefreshIntervalParameter,
                                                          currentSettings.MonitorRefreshInterval, writeToLog);

            resultProperties.ShowMessageCount = configuration.GetBoolValue
                                                    (ConfigurationParameters.ShowMessageCountParameter,
                                                    currentSettings.ShowMessageCount, writeToLog);

            resultProperties.UseAscii = configuration.GetBoolValue(ConfigurationParameters.UseAsciiParameter,
                                                                   currentSettings.UseAscii, writeToLog);

            resultProperties.SaveMessageToFile = configuration.GetBoolValue
                                                     (ConfigurationParameters.SaveMessageToFileParameter, currentSettings.SaveMessageToFile, writeToLog);

            resultProperties.SavePropertiesToFile = configuration.GetBoolValue
                                                        (ConfigurationParameters.SavePropertiesToFileParameter,
                                                        currentSettings.SavePropertiesToFile, writeToLog);

            resultProperties.SaveCheckpointsToFile = configuration.GetBoolValue
                                                         (ConfigurationParameters.SaveCheckpointsToFileParameter,
                                                         currentSettings.SaveCheckpointsToFile, writeToLog);

            resultProperties.Label = configuration.GetStringValue(ConfigurationParameters.LabelParameter,
                                                                  MainSettings.DefaultLabel);

            MessageAndPropertiesHelper.GetMessageTextAndFile(configuration,
                                                             out string messageText, out string messageFile);
            resultProperties.MessageText = messageText;
            resultProperties.MessageFile = messageFile;

            resultProperties.MessageContentType = configuration.GetStringValue(ConfigurationParameters.MessageContentTypeParameter,
                                                                               string.Empty);

            resultProperties.SelectedEntities      = ConfigurationHelper.GetSelectedEntities(configuration);
            resultProperties.SelectedMessageCounts = ConfigurationHelper.GetSelectedMessageCounts(configuration);

            resultProperties.MessageBodyType = configuration.GetStringValue(ConfigurationParameters.MessageBodyType,
                                                                            BodyType.Stream.ToString());

            resultProperties.ConnectivityMode = configuration.GetEnumValue
                                                    (ConfigurationParameters.ConnectivityMode, currentSettings.ConnectivityMode, writeToLog);
            resultProperties.UseAmqpWebSockets = configuration.GetBoolValue
                                                     (ConfigurationParameters.UseAmqpWebSockets, currentSettings.UseAmqpWebSockets, writeToLog);
            resultProperties.EncodingType = configuration.GetEnumValue
                                                (ConfigurationParameters.Encoding, currentSettings.EncodingType, writeToLog);

            resultProperties.DisableAccidentalDeletionPrevention = configuration.GetBoolValue
                                                                       (ConfigurationParameters.DisableAccidentalDeletionPrevention, currentSettings.DisableAccidentalDeletionPrevention, writeToLog);

            resultProperties.ProxyOverrideDefault       = configuration.GetBoolValue(ConfigurationParameters.ProxyOverrideDefault, currentSettings.ProxyOverrideDefault, writeToLog);
            resultProperties.ProxyUseDefaultCredentials = configuration.GetBoolValue(ConfigurationParameters.ProxyUseDefaultCredentials, currentSettings.ProxyUseDefaultCredentials, writeToLog);
            resultProperties.ProxyBypassOnLocal         = configuration.GetBoolValue(ConfigurationParameters.ProxyBypassOnLocal, currentSettings.ProxyBypassOnLocal, writeToLog);
            resultProperties.ProxyAddress    = configuration.GetStringValue(ConfigurationParameters.ProxyAddress, string.Empty);
            resultProperties.ProxyBypassList = configuration.GetStringValue(ConfigurationParameters.ProxyBypassList, string.Empty);
            resultProperties.ProxyUserName   = configuration.GetStringValue(ConfigurationParameters.ProxyUserName, string.Empty);
            resultProperties.ProxyPassword   = configuration.GetStringValue(ConfigurationParameters.ProxyPassword, string.Empty);
            resultProperties.NodesColors     = NodeColorInfo.ParseAll(configuration.GetStringValue(ConfigurationParameters.NodesColors, string.Empty));

            return(resultProperties);
        }