Ejemplo n.º 1
0
        public void LoadConfiguration()
        {
            if (HandleConfigurationNotFounded())
            {
                return;
            }

            using (var fs = new FileStream(_configurationPath, FileMode.Open, FileAccess.Read))
            {
                using (var sr = new StreamReader(fs))
                {
                    var file = sr.ReadToEnd();

                    if (string.IsNullOrEmpty(file))
                    {
                        ConfigurationReadFailed();

                        return;
                    }

                    var configuration = file.DeserializeJsonString <ConfigurationDto>();

                    ConfigurationLoaded?.Invoke(this, new ConfigurationLoadedEventArgs
                    {
                        Configuration = configuration
                    });
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Loads the syntax and refreshes scintilla settings.
 /// </summary>
 public static void LoadConfiguration()
 {
     sciConfigUtil = new ConfigurationUtility(Assembly.GetExecutingAssembly());
     String[] configFiles = Directory.GetFiles(Path.Combine(PathHelper.SettingDir, "Languages"), "*.xml");
     sciConfig = (Scintilla)sciConfigUtil.LoadConfiguration(configFiles);
     ScintillaControl.Configuration = sciConfig;
     ConfigurationLoaded?.Invoke();
 }
Ejemplo n.º 3
0
        public static void LoadDefaults()
        {
            Configuration = new Configuration
            {
                MaxThreads = 50,
                Theme      = "BaseLight",
                Accent     = "Blue"
            };

            LoadDefaultQuerySet();
            LoadDefaultScanningOptions();
            LoadDefaultIpAddressRanges();
            LoadDefaultHostCommandsMenuTree();

            ConfigurationLoaded?.Invoke();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Loads configuration from file
        /// </summary>
        /// <param name="requireNotification">Specifies if ConfigurationLoaded event should be invoked</param>
        public static void LoadConfiguration(bool requireNotification)
        {
            try
            {
                Configuration = JsonConvert.DeserializeObject <Configuration>(File.ReadAllText("cfg"),
                                                                              GetJsonSerializerSettings());

                if (requireNotification)
                {
                    ConfigurationLoaded?.Invoke();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(
                    $"Fail to load configuration file. Reason: {e.Message} \n\n Default configuration will be loaded.");
                LoadDefaults();
            }
        }
Ejemplo n.º 5
0
 protected virtual void OnConfigurationReloaded(ConfigurationLoadedEventHandlerArgs <T> args)
 {
     ConfigurationLoaded?.Invoke(this, args);
 }
Ejemplo n.º 6
0
        public void OnConfigurationLoaded()
        {
            ConfigurationLoaded?.Invoke(this, EventArgs.Empty);

            _logger.LogInformation("Configuration loaded.");
        }