/// <summary> /// Creates a placeholder from a specified full qualifier. /// </summary> /// <param name="fullQualifier">Full qualifier. /// <para>It is in the format of [ThreatsManagerPlatform:ModelTest:parameter1#parameter2], where /// <list type="bullet"> /// <item><description>ThreatsManagerPlatform is fixed.</description></item> /// <item><description>ModelTest represents the Qualifier which identifies the specific Placeholder.</description></item> /// <item><description>parameter1#parameter2 represent the parameters for the Placeholder, separated by #.</description></item> /// </list> /// </para></param> /// <param name="priority">[out] Integer representing the priority of the placeholder.</param> /// <returns>Generated Placeholder. It may be null, if no suitable placeholder has been found.</returns> public static IPlaceholder Create([Required] string fullQualifier, out int priority) { IPlaceholder result = null; priority = 100; var factories = ExtensionUtils.GetExtensions <IPlaceholderFactory>()?.ToArray(); if (factories?.Any() ?? false) { var regex = new Regex( @"\[ThreatsManagerPlatform:(?<qualifier>[\w]+):?(?<params>[\S ]*)?\]"); var match = regex.Match(fullQualifier); if (match.Success) { var factory = factories.FirstOrDefault(x => string.CompareOrdinal(x.Qualifier, match.Groups["qualifier"]?.Value) == 0); if (factory != null) { priority = factory.GetExtensionPriority(); result = factory.Create(match.Groups["params"]?.Value); } } } return(result); }
public ResidualRiskEstimatorConfigurationDialog() { InitializeComponent(); var estimators = ExtensionUtils.GetExtensions <IResidualRiskEstimator>()?.ToArray(); if (estimators?.Any() ?? false) { _estimators.Items.AddRange(estimators); } }
public DevOpsConnectionDialog() { InitializeComponent(); var factories = ExtensionUtils.GetExtensions <IDevOpsConnectorFactory>()?.ToArray(); if (factories?.Any() ?? false) { _factories.Items.AddRange(factories); } }
public RoadmapFilter([NotNull] IThreatModel model) { var providers = ExtensionUtils.GetExtensions <IRoadmapFilterProvider>()?.ToArray(); if (providers?.Any() ?? false) { foreach (var provider in providers) { var filters = provider.GetFilters(model)?.ToArray(); if (filters?.Any() ?? false) { _filters.AddRange(filters); } } } }
private void RegisterPostLoadProcessorsEventHandlers() { var processors = ExtensionUtils.GetExtensions <IPostLoadProcessor>()?.ToArray(); if (processors?.Any() ?? false) { foreach (var processor in processors) { if (processor is IDesktopAlertAwareExtension desktopAlertAware) { desktopAlertAware.ShowMessage += s => _showMessage?.Invoke(s); desktopAlertAware.ShowWarning += s => _showWarning?.Invoke(s); } } } }
private void HandleExtensionInitializers() { var initializers = ExtensionUtils.GetExtensions <IExtensionInitializer>()?.ToArray(); if (initializers?.Any() ?? false) { foreach (var initializer in initializers) { initializer.Initialize(); if (initializer is IDesktopAlertAwareExtension alertAwareExtension) { alertAwareExtension.ShowMessage += DesktopAlertAwareExtensionOnShowMessage; alertAwareExtension.ShowWarning += DesktopAlertAwareExtensionOnShowWarning; } } } }
public void Refresh() { if (_mitigation != null) { var schemaManager = new EffortPropertySchemaManager(_mitigation.Model); if (schemaManager.IsEffortSupported) { SetInfo("Estimated Effort", CalculateMaxEffort(schemaManager).ToString()); } var properties = ExtensionUtils.GetExtensions <IRoadmapPropertyProvider>()?.ToArray(); if (properties?.Any() ?? false) { foreach (var property in properties) { var propertyValue = property.GetValue(_mitigation); if (propertyValue != null) { SetInfo(property.Name, propertyValue); } } } } }
public RoadmapItem([NotNull] IMitigation mitigation, Effectiveness effectiveness) { _mitigation = mitigation; PortBorderMargin = SizeF.Empty; Label.Text = mitigation.Name; ToolTipText = mitigation.Name; switch (effectiveness) { case Effectiveness.Unknown: Label.TextColor = Color.White; Header.BrushColor = ThreatModelManager.StandardColor; break; case Effectiveness.Minor: Label.TextColor = Color.Black; Header.BrushColor = Color.White; Header.BorderPenColor = Color.DarkGreen; break; case Effectiveness.Average: Label.TextColor = Color.Black; Header.BrushColor = Color.LimeGreen; Header.BorderPenColor = Color.LimeGreen; break; case Effectiveness.Major: Label.TextColor = Color.White; Header.BrushColor = Color.DarkGreen; Header.BorderPenColor = Color.DarkGreen; break; default: throw new ArgumentOutOfRangeException(nameof(effectiveness), effectiveness, null); } if (effectiveness != Effectiveness.Unknown) { AddItem("Effectiveness", effectiveness.ToString()); } var schemaManager = new EffortPropertySchemaManager(mitigation.Model); if (schemaManager.IsEffortSupported) { AddItem("Estimated Effort", CalculateMaxEffort(schemaManager).ToString()); } var properties = ExtensionUtils.GetExtensions <IRoadmapPropertyProvider>()?.ToArray(); if (properties?.Any() ?? false) { foreach (var property in properties) { var propertyValue = property?.GetValue(mitigation); if (propertyValue != null) { AddItem(property.Name, propertyValue); } } } }
static PropertySchemaListPanel() { _updaters = ExtensionUtils.GetExtensions <IPropertySchemasUpdater>()?.ToArray(); }
static ImportTemplateDialog() { _extractors = ExtensionUtils.GetExtensions <IPropertySchemasExtractor>(); }
static QualityAnalyzersManager() { _analyzers = ExtensionUtils.GetExtensions <IQualityAnalyzer>(); }