public bool Execute(IEnumerable <IShape> shapes, IEnumerable <ILink> links) { var shapesArray = shapes?.ToArray(); var linksArray = links?.ToArray(); ShapesInfo shapesInfo = new ShapesInfo { Shapes = shapesArray != null ? new List <IShape>(shapesArray) : null, Links = linksArray != null ? new List <ILink>(linksArray) : null }; var serialized = JsonConvert.SerializeObject(shapesInfo, Formatting.Indented, new JsonSerializerSettings() { #pragma warning disable SCS0028 // Type information used to serialize and deserialize objects #pragma warning disable SEC0030 // Insecure Deserialization - Newtonsoft JSON TypeNameHandling = TypeNameHandling.All #pragma warning restore SEC0030 // Insecure Deserialization - Newtonsoft JSON #pragma warning restore SCS0028 // Type information used to serialize and deserialize objects }); DataObject dataObject = new DataObject(); dataObject.SetData("ShapesInfo", serialized); Clipboard.SetDataObject(dataObject); if (linksArray?.Any() ?? false) { foreach (var link in linksArray) { DataFlowRemovingRequired?.Invoke(link); } } if (shapesArray?.Any() ?? false) { foreach (var shape in shapesArray) { EntityGroupRemovingRequired?.Invoke(shape); } } return(true); }
public bool Execute(IEnumerable <IShape> shapes, IEnumerable <ILink> links) { ShapesInfo shapesInfo = new ShapesInfo { Shapes = shapes != null ? new List <IShape>(shapes.ToArray()) : null, Links = links != null ? new List <ILink>(links.ToArray()) : null }; var serialized = JsonConvert.SerializeObject(shapesInfo, Formatting.Indented, new JsonSerializerSettings() { #pragma warning disable SCS0028 // Type information used to serialize and deserialize objects #pragma warning disable SEC0030 // Insecure Deserialization - Newtonsoft JSON TypeNameHandling = TypeNameHandling.All #pragma warning restore SEC0030 // Insecure Deserialization - Newtonsoft JSON #pragma warning restore SCS0028 // Type information used to serialize and deserialize objects }); DataObject dataObject = new DataObject(); dataObject.SetData("ShapesInfo", serialized); Clipboard.SetDataObject(dataObject); return(true); }