public void Add([NotNull] IMitigation mitigation)
        {
            if (_mitigations == null)
            {
                _mitigations = new List <IMitigation>();
            }

            _mitigations.Add(mitigation);

            SetDirty();
            ChildCreated?.Invoke(mitigation);
        }
Пример #2
0
        public void Add([NotNull] IThreatActor actor)
        {
            if (_actors == null)
            {
                _actors = new List <IThreatActor>();
            }

            _actors.Add(actor);

            SetDirty();
            ChildCreated?.Invoke(actor);
        }
        public void Add([NotNull] IThreatType threatType)
        {
            if (_threatTypes == null)
            {
                _threatTypes = new List <IThreatType>();
            }

            _threatTypes.Add(threatType);

            SetDirty();
            ChildCreated?.Invoke(threatType);
        }
Пример #4
0
        public void Add([NotNull] IWeakness weakness)
        {
            if (_weaknesses == null)
            {
                _weaknesses = new List <IWeakness>();
            }

            _weaknesses.Add(weakness);

            SetDirty();
            ChildCreated?.Invoke(weakness);
        }
Пример #5
0
        public void Add([NotNull] IMitigation mitigation)
        {
            if (_mitigations == null)
            {
                _mitigations = new List <IMitigation>();
            }

            _mitigations.Add(mitigation);

            if (this == ThreatModelManager.Model)
            {
                Dirty.IsDirty = true;
                ChildCreated?.Invoke(mitigation);
            }
        }
Пример #6
0
        public void Add([NotNull] IThreatActor actor)
        {
            if (_actors == null)
            {
                _actors = new List <IThreatActor>();
            }

            _actors.Add(actor);

            if (this == ThreatModelManager.Model)
            {
                Dirty.IsDirty = true;
                ChildCreated?.Invoke(actor);
            }
        }
Пример #7
0
        public void Add([NotNull] IThreatType threatType)
        {
            if (_threatTypes == null)
            {
                _threatTypes = new List <IThreatType>();
            }

            _threatTypes.Add(threatType);

            if (this == ThreatModelManager.Model)
            {
                Dirty.IsDirty = true;
                ChildCreated?.Invoke(threatType);
            }
        }
        public void AddGroup([NotNull] IGroup group)
        {
            if (group.Model != this)
            {
                throw new ArgumentException();
            }

            if (_groups == null)
            {
                _groups = new List <IGroup>();
            }
            _groups.Add(group);
            SetDirty();
            RegisterEvents(group);
            ChildCreated?.Invoke(group);
        }
Пример #9
0
        public void Add([NotNull] IFlowTemplate flowTemplate)
        {
            if (flowTemplate is IThreatModelChild child && child.Model != this)
            {
                throw new ArgumentException();
            }

            if (_flowTemplates == null)
            {
                _flowTemplates = new List <IFlowTemplate>();
            }

            _flowTemplates.Add(flowTemplate);

            SetDirty();
            ChildCreated?.Invoke(flowTemplate);
        }
Пример #10
0
        public void Add([NotNull] ITrustBoundaryTemplate trustBoundaryTemplate)
        {
            if (trustBoundaryTemplate is IThreatModelChild child && child.Model != this)
            {
                throw new ArgumentException();
            }

            if (_trustBoundaryTemplates == null)
            {
                _trustBoundaryTemplates = new List <ITrustBoundaryTemplate>();
            }

            _trustBoundaryTemplates.Add(trustBoundaryTemplate);

            SetDirty();
            ChildCreated?.Invoke(trustBoundaryTemplate);
        }
Пример #11
0
        public IDataFlow AddDataFlow([Required] string name, Guid sourceId, Guid targetId, IFlowTemplate template)
        {
            IDataFlow result = new DataFlow(this, name, sourceId, targetId)
            {
                _templateId = template?.Id ?? Guid.Empty
            };

            if (_dataFlows == null)
            {
                _dataFlows = new List <IDataFlow>();
            }
            _dataFlows.Add(result);
            RegisterEvents(result);
            SetDirty();
            ChildCreated?.Invoke(result);

            return(result);
        }
Пример #12
0
        public ITrustBoundary AddTrustBoundary([Required] string name, ITrustBoundaryTemplate template)
        {
            ITrustBoundary result = new TrustBoundary(this, name)
            {
                _templateId = template?.Id ?? Guid.Empty
            };

            if (_groups == null)
            {
                _groups = new List <IGroup>();
            }
            _groups.Add(result);
            RegisterEvents(result);
            SetDirty();
            ChildCreated?.Invoke(result);

            return(result);
        }
Пример #13
0
        public IPropertySchema AddSchema([Required] string name, [Required] string nspace)
        {
            IPropertySchema result = null;

            if (GetSchema(name, nspace) == null)
            {
                if (_schemas == null)
                {
                    _schemas = new List <IPropertySchema>();
                }
                result = new PropertySchema(this, name, nspace);
                _schemas.Add(result);
                SetDirty();
                RegisterEvents(result);
                ChildCreated?.Invoke(result);
            }

            return(result);
        }
Пример #14
0
        public IGroup AddGroup <T>([Required] string name) where T : IGroup
        {
            IGroup result = null;

            if (typeof(T) == typeof(ITrustBoundary))
            {
                result = new TrustBoundary(this, name);
                if (_groups == null)
                {
                    _groups = new List <IGroup>();
                }
                _groups.Add(result);
                Dirty.IsDirty = true;
                RegisterEvents(result);
                ChildCreated?.Invoke(result);
            }

            return(result);
        }
Пример #15
0
        public T AddGroup <T>([Required] string name) where T : class, IGroup
        {
            T result = default(T);

            if (typeof(T) == typeof(ITrustBoundary))
            {
                result = new TrustBoundary(this, name) as T;
                if (_groups == null)
                {
                    _groups = new List <IGroup>();
                }
                _groups.Add(result);
                SetDirty();
                RegisterEvents(result);
                ChildCreated?.Invoke(result);
            }

            return(result);
        }
Пример #16
0
        public IEntity AddEntity <T>([Required] string name, IEntityTemplate template) where T : IEntity
        {
            IEntity result = null;

            if (typeof(T) == typeof(IProcess))
            {
                result = new Process(this, name)
                {
                    _templateId = template?.Id ?? Guid.Empty
                }
            }
            ;
            if (typeof(T) == typeof(IExternalInteractor))
            {
                result = new ExternalInteractor(this, name)
                {
                    _templateId = template?.Id ?? Guid.Empty
                }
            }
            ;
            if (typeof(T) == typeof(IDataStore))
            {
                result = new DataStore(this, name)
                {
                    _templateId = template?.Id ?? Guid.Empty
                }
            }
            ;

            if (result != null)
            {
                if (_entities == null)
                {
                    _entities = new List <IEntity>();
                }
                _entities.Add(result);
                RegisterEvents(result);
                Dirty.IsDirty = true;
                ChildCreated?.Invoke(result);
            }

            return(result);
        }
Пример #17
0
        public IDataFlow AddDataFlow([Required] string name, Guid sourceId, Guid targetId)
        {
            IDataFlow result = null;

            if (!(_dataFlows?.Any(x => (x.SourceId == sourceId) && (x.TargetId == targetId)) ?? false))
            {
                if (_dataFlows == null)
                {
                    _dataFlows = new List <IDataFlow>();
                }

                result = new DataFlow(this, name, sourceId, targetId);
                _dataFlows.Add(result);
                Dirty.IsDirty = true;
                RegisterEvents(result);
                ChildCreated?.Invoke(result);
            }

            return(result);
        }
Пример #18
0
        public void Add([NotNull] IEntityTemplate entityTemplate)
        {
            if (entityTemplate is IThreatModelChild child && child.Model != this)
            {
                throw new ArgumentException();
            }

            if (_entityTemplates == null)
            {
                _entityTemplates = new List <IEntityTemplate>();
            }

            _entityTemplates.Add(entityTemplate);

            if (this == ThreatModelManager.Model)
            {
                Dirty.IsDirty = true;
                ChildCreated?.Invoke(entityTemplate);
            }
        }
        public IDiagram AddDiagram([Required] string name)
        {
            IDiagram result = null;

            var diagrams = GetDiagrams(name);

            if (!(diagrams?.Any() ?? false))
            {
                if (_diagrams == null)
                {
                    _diagrams = new List <IDiagram>();
                }
                result = new Diagram(this, name)
                {
                    Order = _diagrams.Any() ? _diagrams.Max(x => x.Order) + 1 : 1
                };
                _diagrams.Add(result);
                SetDirty();
                RegisterEvents(result);
                ChildCreated?.Invoke(result);
            }

            return(result);
        }