microsoft/teams.net
Publicmirrored fromhttps://github.com/microsoft/teams.netAvailable
Libraries/Microsoft.Teams.Api/Entities/CitationEntity.cs
195lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | using System.Text.Json.Serialization; |
| 5 | |
| 6 | using Microsoft.Teams.Common; |
| 7 | |
| 8 | namespace Microsoft.Teams.Api.Entities; |
| 9 | |
| 10 | public class CitationEntity : OMessageEntity, IMessageEntity |
| 11 | { |
| 12 | [JsonPropertyName("citation")] |
| 13 | [JsonPropertyOrder(20)] |
| 14 | public IList<Claim>? Citation { get; set; } |
| 15 | |
| 16 | public CitationEntity() : base() |
| 17 | { |
| 18 | } |
| 19 | |
| 20 | public CitationEntity(IMessageEntity entity) |
| 21 | : base() |
| 22 | { |
| 23 | OType = entity.OType; |
| 24 | OContext = entity.OContext; |
| 25 | Type = entity.Type; |
| 26 | AdditionalType = entity.AdditionalType != null |
| 27 | ? new List<string>(entity.AdditionalType) |
| 28 | : null; |
| 29 | if (entity is CitationEntity citationEntity) |
| 30 | { |
| 31 | Citation = citationEntity.Citation != null |
| 32 | ? new List<CitationEntity.Claim>(citationEntity.Citation) |
| 33 | : null; |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | public class Claim |
| 38 | { |
| 39 | [JsonPropertyName("@type")] |
| 40 | [JsonPropertyOrder(0)] |
| 41 | public string Type { get; set; } = "Claim"; |
| 42 | |
| 43 | [JsonPropertyName("position")] |
| 44 | [JsonPropertyOrder(1)] |
| 45 | public required int Position { get; set; } |
| 46 | |
| 47 | [JsonPropertyName("appearance")] |
| 48 | [JsonPropertyOrder(2)] |
| 49 | public required AppearanceDocument Appearance { get; set; } |
| 50 | } |
| 51 | |
| 52 | public class AppearanceDocument |
| 53 | { |
| 54 | [JsonPropertyName("@type")] |
| 55 | [JsonPropertyOrder(0)] |
| 56 | public string Type { get; set; } = "DigitalDocument"; |
| 57 | |
| 58 | [JsonPropertyName("name")] |
| 59 | [JsonPropertyOrder(1)] |
| 60 | public required string Name { get; set; } |
| 61 | |
| 62 | [JsonPropertyName("text")] |
| 63 | [JsonPropertyOrder(2)] |
| 64 | public string? Text { get; set; } |
| 65 | |
| 66 | [JsonPropertyName("url")] |
| 67 | [JsonPropertyOrder(3)] |
| 68 | public string? Url { get; set; } |
| 69 | |
| 70 | [JsonPropertyName("abstract")] |
| 71 | [JsonPropertyOrder(4)] |
| 72 | public required string Abstract { get; set; } |
| 73 | |
| 74 | [JsonPropertyName("encodingFormat")] |
| 75 | [JsonPropertyOrder(5)] |
| 76 | public ContentType? EncodingFormat { get; set; } |
| 77 | |
| 78 | [JsonPropertyName("image")] |
| 79 | [JsonPropertyOrder(6)] |
| 80 | public ImageObject? Image { get; set; } |
| 81 | |
| 82 | [JsonPropertyName("keywords")] |
| 83 | [JsonPropertyOrder(7)] |
| 84 | public List<string>? Keywords { get; set; } |
| 85 | |
| 86 | [JsonPropertyName("usageInfo")] |
| 87 | [JsonPropertyOrder(8)] |
| 88 | public SensitiveUsageEntity? UsageInfo { get; set; } |
| 89 | |
| 90 | public class ImageObject |
| 91 | { |
| 92 | [JsonPropertyName("@type")] |
| 93 | [JsonPropertyOrder(0)] |
| 94 | public string Type { get; set; } = "ImageObject"; |
| 95 | |
| 96 | [JsonPropertyName("name")] |
| 97 | [JsonPropertyOrder(1)] |
| 98 | public required CitationIcon Name { get; set; } |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | [JsonConverter(typeof(JsonConverter<CitationIcon>))] |
| 104 | public class CitationIcon(string value) : StringEnum(value) |
| 105 | { |
| 106 | public static readonly CitationIcon MicrosoftWord = new("Microsoft Word"); |
| 107 | public bool IsMicrosoftWord => MicrosoftWord.Equals(Value); |
| 108 | |
| 109 | public static readonly CitationIcon MicrosoftExcel = new("Microsoft Excel"); |
| 110 | public bool IsMicrosoftExcel => MicrosoftExcel.Equals(Value); |
| 111 | |
| 112 | public static readonly CitationIcon MicrosoftPowerPoint = new("Microsoft PowerPoint"); |
| 113 | public bool IsMicrosoftPowerPoint => MicrosoftPowerPoint.Equals(Value); |
| 114 | |
| 115 | public static readonly CitationIcon MicrosoftOneNote = new("Microsoft OneNote"); |
| 116 | public bool IsMicrosoftOneNote => MicrosoftOneNote.Equals(Value); |
| 117 | |
| 118 | public static readonly CitationIcon MicrosoftSharePoint = new("Microsoft SharePoint"); |
| 119 | public bool IsMicrosoftSharePoint => MicrosoftSharePoint.Equals(Value); |
| 120 | |
| 121 | public static readonly CitationIcon MicrosoftVisio = new("Microsoft Visio"); |
| 122 | public bool IsMicrosoftVisio => MicrosoftVisio.Equals(Value); |
| 123 | |
| 124 | public static readonly CitationIcon MicrosoftLoop = new("Microsoft Loop"); |
| 125 | public bool IsMicrosoftLoop => MicrosoftLoop.Equals(Value); |
| 126 | |
| 127 | public static readonly CitationIcon MicrosoftWhiteboard = new("Microsoft Whiteboard"); |
| 128 | public bool IsMicrosoftWhiteboard => MicrosoftWhiteboard.Equals(Value); |
| 129 | |
| 130 | public static readonly CitationIcon AdobeIllustrator = new("Adobe Illustrator"); |
| 131 | public bool IsAdobeIllustrator => AdobeIllustrator.Equals(Value); |
| 132 | |
| 133 | public static readonly CitationIcon AdobePhotoshop = new("Adobe Photoshop"); |
| 134 | public bool IsAdobePhotoshop => AdobePhotoshop.Equals(Value); |
| 135 | |
| 136 | public static readonly CitationIcon AdobeInDesign = new("Adobe InDesign"); |
| 137 | public bool IsAdobeInDesign => AdobeInDesign.Equals(Value); |
| 138 | |
| 139 | public static readonly CitationIcon AdobeFlash = new("Adobe Flash"); |
| 140 | public bool IsAdobeFlash => AdobeFlash.Equals(Value); |
| 141 | |
| 142 | public static readonly CitationIcon Sketch = new("Sketch"); |
| 143 | public bool IsSketch => Sketch.Equals(Value); |
| 144 | |
| 145 | public static readonly CitationIcon SourceCode = new("Source Code"); |
| 146 | public bool IsSourceCode => SourceCode.Equals(Value); |
| 147 | |
| 148 | public static readonly CitationIcon Image = new("Image"); |
| 149 | public bool IsImage => Image.Equals(Value); |
| 150 | |
| 151 | public static readonly CitationIcon Gif = new("GIF"); |
| 152 | public bool IsGif => Gif.Equals(Value); |
| 153 | |
| 154 | public static readonly CitationIcon Video = new("Video"); |
| 155 | public bool IsVideo => Video.Equals(Value); |
| 156 | |
| 157 | public static readonly CitationIcon Sound = new("Sound"); |
| 158 | public bool IsSound => Sound.Equals(Value); |
| 159 | |
| 160 | public static readonly CitationIcon Zip = new("ZIP"); |
| 161 | public bool IsZip => Zip.Equals(Value); |
| 162 | |
| 163 | public static readonly CitationIcon Text = new("Text"); |
| 164 | public bool IsText => Text.Equals(Value); |
| 165 | |
| 166 | public static readonly CitationIcon Pdf = new("PDF"); |
| 167 | public bool IsPdf => Pdf.Equals(Value); |
| 168 | } |
| 169 | |
| 170 | public class CitationAppearance |
| 171 | { |
| 172 | public required string Name { get; set; } |
| 173 | public string? Text { get; set; } |
| 174 | public string? Url { get; set; } |
| 175 | public required string Abstract { get; set; } |
| 176 | public ContentType? EncodingFormat { get; set; } |
| 177 | public CitationIcon? Icon { get; set; } |
| 178 | public List<string>? Keywords { get; set; } |
| 179 | public SensitiveUsageEntity? UsageInfo { get; set; } |
| 180 | |
| 181 | public CitationEntity.AppearanceDocument ToDocument() |
| 182 | { |
| 183 | return new() |
| 184 | { |
| 185 | Name = Name, |
| 186 | Text = Text, |
| 187 | Url = Url, |
| 188 | Abstract = Abstract, |
| 189 | EncodingFormat = EncodingFormat, |
| 190 | Image = Icon is null ? null : new CitationEntity.AppearanceDocument.ImageObject() { Name = Icon }, |
| 191 | Keywords = Keywords, |
| 192 | UsageInfo = UsageInfo |
| 193 | }; |
| 194 | } |
| 195 | } |