public IEnumerable <ListItem> GetList([NotNull] IThreatModel model)
        {
            IEnumerable <ListItem> result = null;

            var diagrams = model.Diagrams?.ToArray();

            if (diagrams?.Any() ?? false)
            {
                var list = new List <ListItem>();

                var currentMarkerStatus = MarkerStatusTrigger.CurrentStatus;
                MarkerStatusTrigger.RaiseMarkerStatusUpdated(MarkerStatus.Hidden);

                try
                {
                    foreach (var diagram in diagrams)
                    {
                        var panel = new ModelPanel();
                        panel.SetDiagram(diagram);
                        var imageRow = new ImageRow("Diagram", panel.GetMetafile(), $"The '{diagram.Name}' scenario.");
                        var textRow  = new TextRow("Description", diagram.Description);

                        list.Add(new ListItem(diagram.Name, diagram.Id, new ItemRow[] { imageRow, textRow }));
                    }
                }
                finally
                {
                    MarkerStatusTrigger.RaiseMarkerStatusUpdated(currentMarkerStatus);
                }

                result = list;
            }

            return(result);
        }
Пример #2
0
        /// <summary>
        /// Creates a new ItemRow for a given Property.
        /// </summary>
        /// <param name="container">Container of the Property.</param>
        /// <param name="property">Property to be analyzed.</param>
        /// <returns>The created ItemRow.</returns>
        public static ItemRow Create([NotNull] IPropertiesContainer container, [NotNull] IProperty property)
        {
            ItemRow result = null;

            var propertyType = property.PropertyType;

            if (property is IPropertyArray propertyArray)
            {
                result = new ListRow(propertyType.Name, propertyArray.Value?.Select(x => new Line(x?.TrimEnd(' ', '\r', '\n'))));
            }
            else if (property is IPropertyIdentityReference propertyIdentityReference)
            {
                if (propertyIdentityReference.Value is IIdentity identity && identity is IThreatModelChild child)
                {
                    result = new TextRow(propertyType.Name,
                                         $"{identity.Name}",
                                         $"[{child.Model.GetIdentityTypeInitial(identity)}] ", null, new[] { identity.Id });
                }
                else
                {
                    result = new EmptyRow(propertyType.Name);
                }
            }