Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ArrayExtensions.cs
2
4{
8 public static class ArrayExtensions
9 {
15 public static IEnumerable<Attachment> GetImageAttachments(this Attachment[] attachments)
16 {
17 if (attachments is null)
18 {
19 return Enumerable.Empty<Attachment>();
20 }
21 return attachments.Where(x => x.ContentType.StartsWith("image/", StringComparison.OrdinalIgnoreCase));
22 }
23
29 public static Attachment? GetFirstImageAttachment(this Attachment[] attachments)
30 {
31 return attachments?.FirstOrDefault(x => x.ContentType.StartsWith("image/", StringComparison.OrdinalIgnoreCase));
32 }
33
41 public static T[] Join<T>(this T[] Array1, T[] Array2)
42 {
43 if (Array1 is null)
44 return Array2;
45 else if (Array2 is null)
46 return Array1;
47 else
48 {
49 int c = Array1.Length;
50 int d = Array2.Length;
51 T[] Result = new T[c + d];
52
53 Array1.CopyTo(Result, 0);
54 Array2.CopyTo(Result, c);
55
56 return Result;
57 }
58 }
59 }
60}
Extensions for generic Arrays.
static ? Attachment GetFirstImageAttachment(this Attachment[] attachments)
Returns the first image attachment of the array, if there is one.
static IEnumerable< Attachment > GetImageAttachments(this Attachment[] attachments)
Returns all the attachments whose content type starts with "image".
static T[] Join< T >(this T[] Array1, T[] Array2)
Joins two arrays.
Contains a reference to an attachment assigned to a legal object.
Definition: Attachment.cs:9