public override SelectionRuleNode CreateNode([NotNull] Node node, params object[] parameters) { SelectionRuleNode result = null; if (parameters != null && parameters.Length == 1 && parameters[0] is string entityTemplateName) { var entityTemplate = _model?.EntityTemplates?.Where(x => x.EntityType == EntityType.Process) .FirstOrDefault(x => string.CompareOrdinal(x.Name, entityTemplateName) == 0); if (entityTemplate != null) { result = new ProcessTemplateRuleNode(entityTemplate) { Scope = Scope }; } } return(result); }
private SelectionRuleNode GetIdComparisonRuleNode([Required] string id, Scope scope) { SelectionRuleNode result = null; var elementType = _source.ElementTypes?.FirstOrDefault(x => string.CompareOrdinal(x.TypeId, id) == 0); var entityTemplate = GetEntityTemplate(id); if (elementType?.IsGeneric ?? false) { switch (elementType.ElementType) { case ElementType.StencilRectangle: result = new EnumValueRuleNode("Object Type", null, null, new[] { "External Interactor", "Process", "Data Store" }, "External Interactor") { Scope = scope }; break; case ElementType.StencilEllipse: result = new EnumValueRuleNode("Object Type", null, null, new[] { "External Interactor", "Process", "Data Store" }, "Process") { Scope = scope }; break; case ElementType.StencilParallelLines: result = new EnumValueRuleNode("Object Type", null, null, new[] { "External Interactor", "Process", "Data Store" }, "Data Store") { Scope = scope }; break; } } else if (entityTemplate != null) { switch (entityTemplate.EntityType) { case EntityType.ExternalInteractor: result = new ExternalInteractorTemplateRuleNode(entityTemplate) { Scope = scope }; break; case EntityType.Process: result = new ProcessTemplateRuleNode(entityTemplate) { Scope = scope }; break; case EntityType.DataStore: result = new DataStoreTemplateRuleNode(entityTemplate) { Scope = scope }; break; default: throw new ArgumentOutOfRangeException(); } } else { var flowTemplate = GetFlowTemplate(id); if (flowTemplate != null) { result = new FlowTemplateRuleNode(flowTemplate); } else { result = new ComparisonRuleNode(ObjectPropertySchemaManager.ThreatModelObjectId, Resources.DefaultNamespace, Resources.TmtObjectPropertySchema, ComparisonOperator.Exact, id) { Scope = scope }; } } return(result); }