public override void Init(SimFeedbackExtensionFacade facade, ExtensionConfig config) { base.Init(facade, config); // call this first Log("Initialize Web Controler Extension"); extControl = new WebExtControl(this, facade); }
public void Disable([Required] string id) { if ((_extensions?.Contains(id) ?? false) && !_disabledExtensions.Contains(id)) { _disabledExtensions.Add(id); var configSection = GetConfigurationSection(); if (configSection?.Extensions != null) { var extensionConfigs = configSection.Extensions.OfType <ExtensionConfig>(); if (extensionConfigs?.Any(x => string.CompareOrdinal(x.Id, id) == 0) ?? false) { var extensionConfig = extensionConfigs.FirstOrDefault(x => string.CompareOrdinal(x.Id, id) == 0); if (extensionConfig != null) { extensionConfig.Enabled = false; } } else { var extensionConfig = new ExtensionConfig() { Id = id, Enabled = false }; configSection.Extensions.Add(extensionConfig); } configSection.CurrentConfiguration.Save(); } } }
private void LoadExtensions([NotNull] IEnumerable <string> extensions) { SuspendLayout(); try { if (extensions != null) { var groups = new Dictionary <string, List <ExtensionConfig> >(); foreach (var id in extensions) { ExtensionConfig item = new ExtensionConfig(); item.ConfigureExtension(id); if (!groups.TryGetValue(item.AssemblyTitle, out var list)) { list = new List <ExtensionConfig>(); groups.Add(item.AssemblyTitle, list); } list.Add(item); } var sorted = groups.Select(x => x.Key).OrderBy(x => x).ToArray(); if (sorted.Any()) { foreach (var item in sorted) { if (groups.TryGetValue(item, out var group)) { if (group?.Any() ?? false) { var layout = AddSide(item, group.Count); var sortedGroup = group.OrderBy(x => x.ExtensionType) .ThenBy(x => x.ExtensionName).ToArray(); foreach (var curr in sortedGroup) { AddItem(layout, curr); } } } } if (_side.Items[0] is SideNavItem sideNavItem) { sideNavItem.Checked = true; } } _total = extensions.Count(); this.Text = $"{this.Text} ({extensions.Count()})"; } } finally { ResumeLayout(); Refresh(); } }
public RedisUserStore( ILdapService <TUser> authenticationService, ExtensionConfig ldapConfigurations, ILogger <RedisUserStore <TUser> > logger) { _authenticationService = authenticationService; _logger = logger; InitializeRedis(ldapConfigurations); }
private void AddItem([NotNull] LayoutControl layout, [NotNull] ExtensionConfig item) { var visible = true; var combo = layout.Controls.OfType <ComboBox>().FirstOrDefault(); if (combo != null) { if (!combo.Items.Contains(item.ExtensionType)) { combo.Items.Add(item.ExtensionType); if (combo.Items.Count == 1) { combo.SelectedIndex = 0; } } var extensionType = combo.SelectedItem as string; if (!string.IsNullOrWhiteSpace(extensionType) && (string.CompareOrdinal("<All>", extensionType) != 0 && string.CompareOrdinal(item.ExtensionType, extensionType) != 0)) { visible = false; } } layout.Controls.Add(item); layout.RootGroup.Items.Add(new LayoutControlItem() { Control = item, Padding = new System.Windows.Forms.Padding(8, 8, 8, 8), TextVisible = false, Height = item.Height, HeightType = eLayoutSizeType.Absolute, Width = 100, WidthType = DevComponents.DotNetBar.Layout.eLayoutSizeType.Percent, Visible = visible }); if (layout.RootGroup.Items[1] is LayoutControlItem layoutControlItem && layoutControlItem.Control is Label label) { var count = layout.RootGroup.Items.OfType <LayoutControlItem>() .Count(x => x.Control is ExtensionConfig && x.Visible); label.Text = $"Count: {count}"; } }
public void SetParameterValue([Required] string id, [Required] string name, string value) { var parameters = GetParameterNames(id); if (parameters?.Contains(name) ?? false) { var key = $"{id}_{name}"; if (!_values.ContainsKey(key) || string.CompareOrdinal(_values[key], value) != 0) { _values[key] = value; var configSection = GetConfigurationSection(); if (configSection?.Extensions != null) { var extensionConfigs = configSection.Extensions.OfType <ExtensionConfig>(); var encryptedValue = Encrypt(value); if (extensionConfigs?.Any(x => string.CompareOrdinal(x.Id, id) == 0) ?? false) { var extensionConfig = extensionConfigs.FirstOrDefault(x => string.CompareOrdinal(x.Id, id) == 0); if (extensionConfig?.Parameters.IndexOf(name) >= 0) { var parameter = extensionConfig.Parameters[name]; parameter.Value = encryptedValue; } else { extensionConfig?.Parameters.Add(new PropertyConfigElement(name, encryptedValue)); } } else { var extensionConfig = new ExtensionConfig() { Id = id, Enabled = true, }; extensionConfig.Parameters.Add(new PropertyConfigElement(name, encryptedValue)); configSection.Extensions.Add(extensionConfig); } configSection.CurrentConfiguration.Save(); } } } }
public static void Compose(Action <ExtensionConfig> configure) { var config = new ExtensionConfig(); if (configure != null) { configure(config); } var imports = new List <Lazy <IExtension, IExtensionMeta> >(); foreach (var extension in config.Extensions) { var ext = extension; Func <IExtension> func = () => { return(ext); }; var info = new ExtensionMeta(); foreach (var attr in ext.GetType().GetCustomAttributes <ExportMetadataAttribute>()) { if (attr.Name == "InternalId") { info.InternalId = (string)attr.Value; } else if (attr.Name == "Name") { info.Name = (string)attr.Value; } else if (attr.Name == "ResourceType") { info.ResourceType = (Type)attr.Value; } else if (attr.Name == "Type") { info.Type = (ExtensionType)attr.Value; } } imports.Add(new Lazy <IExtension, IExtensionMeta>(func, info)); } Current.Extensions = imports; Current.PageTypes = config.PageTypes; Current.PostTypes = config.PostTypes; Current.OnImportsSatisfied(); }
public async Task LaunchAsync(BrowserConfig browserConfig, ExtensionConfig extensionConfig) { ClosePreviousBrowsers(browserConfig); var extensionFullPath = Path.GetFullPath(extensionConfig.EXTENSION_EXTRACT_PATH); this.browser = await Puppeteer.LaunchAsync(new LaunchOptions { Timeout = 60000, ExecutablePath = browserConfig.CHROME_EXECUTABLE_PATH, Headless = false, Args = new[] { $"--load-extension={extensionFullPath}", $"--disable-extensions-except={extensionFullPath}" } .Union(browserConfig.CHROME_FLAGS.Split( new[] { ",", "~" }, System.StringSplitOptions.RemoveEmptyEntries)) .ToArray() }); }
private void InitializeRedis(ExtensionConfig config) { if (string.IsNullOrEmpty(config.Redis)) { throw new RedisConnectionException(ConnectionFailureType.UnableToConnect, "LDAP configuration is configured to use Redis, but there's no configuration. Please fix your injection in Startup.cs"); } _redis = ConnectionMultiplexer.Connect(config.Redis); if (_redis.IsConnected) { _logger.LogDebug($"LDAP {GetType().Name}: Connected to redis \\o/"); } else { _logger.LogError($"LDAP {GetType().Name}: Not able to connect to redis :("); } _dataExpireIn = TimeSpan.FromSeconds(config.RefreshClaimsInSeconds ?? (double)-1); }
public override void Init(SimFeedbackExtensionFacade facade, ExtensionConfig config) { base.Init(facade, config); // call this first Log("Initialize Fanatec Extension"); LogDebug("FanatecExtension: Reading Config"); extConfig = (FanatecExtConfig)config.CustomConfig; if (extConfig == null) { LogDebug("FanatecExtension: No Config found, creating new config"); extConfig = new FanatecExtConfig() { Test = 100, }; config.CustomConfig = extConfig; } extConfig.Test = 97; extControl = new FanatecExtControl(this, facade); }
public static ThreatsManagerConfigurationSection GetConfigurationSection() { Configuration config = ConfigurationManager.OpenExeConfiguration(_configurationUserLevel); ThreatsManagerConfigurationSection configSection = (ThreatsManagerConfigurationSection)config?.Sections["threatsManager"]; if (configSection == null) { configSection = new ThreatsManagerConfigurationSection(); configSection.SectionInformation.AllowExeDefinition = ConfigurationAllowExeDefinition.MachineToLocalUser; config.Sections.Add("threatsManager", configSection); config.Save(); } if (!configSection.Updated) { configSection.Updated = true; var oldConfigFile = GetOldConfigFile(config.FilePath); if (!string.IsNullOrWhiteSpace(oldConfigFile) && File.Exists(oldConfigFile)) { using (var stream = File.OpenRead(oldConfigFile)) { var serializer = new XmlSerializer(typeof(OldUserConfig)); var oldConfig = serializer.Deserialize(stream) as OldUserConfig; configSection.Setup = oldConfig?.ThreatsManagerConfig?.Setup ?? false; configSection.Mode = oldConfig?.ThreatsManagerConfig?.Mode ?? ExecutionMode.Expert; configSection.SmartSave = oldConfig?.ThreatsManagerConfig?.SmartSave ?? false; configSection.SmartSaveCount = oldConfig?.ThreatsManagerConfig?.SmartSaveCount ?? 0; configSection.SmartSaveInterval = oldConfig?.ThreatsManagerConfig?.SmartSaveInterval ?? 0; configSection.UserDictionary = oldConfig?.ThreatsManagerConfig?.UserDictionary; configSection.StatusBarItems = oldConfig?.ThreatsManagerConfig?.StatusBar?.TagSplit(); var docs = oldConfig?.ThreatsManagerConfig?.KnownDocuments; if (docs != null) { foreach (var doc in docs) { configSection.KnownDocuments.Add(new KnownDocumentConfig() { Path = doc.Path, LocationType = doc.LocationType, PackageManager = doc.PackageManager }); } } var extensions = oldConfig?.ThreatsManagerConfig?.Extensions; if (extensions != null) { foreach (var extension in extensions) { var newExtension = new ExtensionConfig() { Id = extension.Id, Enabled = extension.Enabled }; var parameters = extension.Parameters?.ToArray(); if (parameters?.Any() ?? false) { foreach (var param in parameters) { newExtension.Parameters.Add(new PropertyConfigElement(param.Name, param.Value)); } } configSection.Extensions.Add(newExtension); } } var folders = oldConfig?.ThreatsManagerConfig?.Folders; if (folders != null) { foreach (var folder in folders) { configSection.Folders.Add(new FolderConfig() { Name = folder.Name }); } } var prefixes = oldConfig?.ThreatsManagerConfig?.Prefixes; if (prefixes != null) { foreach (var prefix in prefixes) { configSection.Prefixes.Add(new PrefixConfig() { Name = prefix.Name }); } } var certificates = oldConfig?.ThreatsManagerConfig?.Certificates; if (certificates != null) { foreach (var certificate in certificates) { configSection.Certificates.Add(new CertificateConfig() { Subject = certificate.Subject, Issuer = certificate.Issuer, Thumbprint = certificate.Thumbprint, ExpirationDate = certificate.ExpirationDate }); } } } config.Save(); } } return(configSection); }
public static void Compose(Action<ExtensionConfig> configure) { var config = new ExtensionConfig(); if (configure != null) configure(config); var imports = new List<Lazy<IExtension, IExtensionMeta>>(); foreach (var extension in config.Extensions) { var ext = extension; Func<IExtension> func = () => { return ext; }; var info = new ExtensionMeta(); foreach (var attr in ext.GetType().GetCustomAttributes<ExportMetadataAttribute>()) { if (attr.Name == "InternalId") { info.InternalId = (string)attr.Value; } else if (attr.Name == "Name") { info.Name = (string)attr.Value; } else if (attr.Name == "ResourceType") { info.ResourceType = (Type)attr.Value; } else if (attr.Name == "Type") { info.Type = (ExtensionType)attr.Value; } } imports.Add(new Lazy<IExtension, IExtensionMeta>(func, info)); } Current.Extensions = imports; Current.PageTypes = config.PageTypes; Current.PostTypes = config.PostTypes; Current.OnImportsSatisfied(); }
public override void Init(SimFeedbackExtensionFacade facade, ExtensionConfig config) { base.Init(facade, config); // call this first Log("Initialize Fanatec Extension"); LogDebug("Button Box: Reading Config"); if (!(config.CustomConfig is TestConfig)) { extConfig = new TestConfig() { OverallIntesity = 50, #if FANATEC_OLD_WAY Test = 100, #endif ToggleStartStopButton = -1, ToggleDecreaseIntensity1Button = -1, ToggleIncreaseIntensity1Button = -1, ToggleDecreaseIntensity5Button = -1, ToggleIncreaseIntensity5Button = -1, ToggleDecreaseIntensity10Button = -1, ToggleIncreaseIntensity10Button = -1, ToggleDecreaseIntensity20Button = -1, ToggleIncreaseIntensity20Button = -1, StartStopDelay = 5000 }; config.CustomConfig = extConfig; } extConfig = (TestConfig)config.CustomConfig; if (extConfig == null) { LogDebug("Button Box: No Config found, creating new config"); extConfig = new TestConfig() { OverallIntesity = 50, #if FANATEC_OLD_WAY Test = 100, #endif ToggleStartStopButton = -1, ToggleDecreaseIntensity1Button = -1, ToggleIncreaseIntensity1Button = -1, ToggleDecreaseIntensity5Button = -1, ToggleIncreaseIntensity5Button = -1, ToggleDecreaseIntensity10Button = -1, ToggleIncreaseIntensity10Button = -1, ToggleDecreaseIntensity20Button = -1, ToggleIncreaseIntensity20Button = -1, StartStopDelay = 5000 }; config.CustomConfig = extConfig; } this.conf = config; this.facade = facade; extControl = new TestControl(facade, this, extConfig.ToggleStartStopButton, extConfig.ToggleDecreaseIntensity1Button, extConfig.ToggleIncreaseIntensity1Button, extConfig.ToggleDecreaseIntensity5Button, extConfig.ToggleIncreaseIntensity5Button, extConfig.ToggleDecreaseIntensity10Button, extConfig.ToggleIncreaseIntensity10Button, extConfig.ToggleDecreaseIntensity20Button, extConfig.ToggleIncreaseIntensity20Button); new Thread(new ThreadStart(() => { Thread.Sleep(waitTimeBeforeSimFBInitialized); simFeedbackLoaded = true; Thread.CurrentThread.Join(); })).Start(); //extConfig.OverallIntesity = 50; //extControl = new FanatecExtControl(this, facade); }
public override void Init(SimFeedbackExtensionFacade facade, ExtensionConfig config) { base.Init(facade, config); Log("Initialize Streamdeck Extension"); _extCtrl = new StreamdeckExtensionControl(this, facade); }