Example #1
0
        public IThreatEventScenario AddScenario(IThreatActor threatActor, ISeverity severity,
                                                string name = null)
        {
            if (!(IsInitialized?.Get() ?? false))
            {
                return(null);
            }
            if (threatActor == null)
            {
                throw new ArgumentNullException(nameof(threatActor));
            }
            if (severity == null)
            {
                throw new ArgumentNullException(nameof(severity));
            }

            IThreatEventScenario result = new ThreatEventScenario(MySelf?.Get(), threatActor, name)
            {
                Severity = severity
            };

            if (_scenarios == null)
            {
                _scenarios = new List <IThreatEventScenario>();
            }

            _scenarios.Add(result);
            Dirty.IsDirty = true;
            _threatEventScenarioAdded?.Invoke(ScenariosContainer?.Get(), result);

            return(result);
        }
        public IThreatEventScenario AddScenario(IThreatActor threatActor, ISeverity severity, string name = null)
        {
            if (threatActor == null)
            {
                throw new ArgumentNullException(nameof(threatActor));
            }
            if (severity == null)
            {
                throw new ArgumentNullException(nameof(severity));
            }

            IThreatEventScenario result = null;

            if (Instance is IThreatEvent threatEvent)
            {
                result = new ThreatEventScenario(threatEvent, threatActor, name)
                {
                    Severity = severity
                };

                if (_scenarios == null)
                {
                    _scenarios = new List <IThreatEventScenario>();
                }

                _scenarios.Add(result);
                if (Instance is IDirty dirtyObject)
                {
                    dirtyObject.SetDirty();
                }
                if (Instance is IThreatEventScenariosContainer container)
                {
                    _threatEventScenarioAdded?.Invoke(container, result);
                }
            }

            return(result);
        }