|
1 | | -//todo: fix this - import Xml = require("System.Xml"); |
2 | | - |
3 | | -import {EwsXmlReader} from "../Core/EwsXmlReader"; |
4 | | -import {XmlElementNames} from "../Core/XmlElementNames"; |
5 | | -import {XmlNamespace} from "../Enumerations/XmlNamespace"; |
| 1 | +import { XmlElementNames } from "../Core/XmlElementNames"; |
6 | 2 |
|
| 3 | +/** |
| 4 | + * Represents an alternate mailbox. |
| 5 | + * @sealed |
| 6 | + */ |
7 | 7 | export class AlternateMailbox { |
8 | | - Type: string; |
9 | | - DisplayName: string; |
10 | | - LegacyDN: string; |
11 | | - Server: string; |
12 | | - SmtpAddress: string; |
13 | | - OwnerSmtpAddress: string; |
14 | | - //private type: string; |
15 | | - //private displayName: string; |
16 | | - //private legacyDN: string; |
17 | | - //private server: string; |
18 | | - //private smtpAddress: string; |
19 | | - //private ownerSmtpAddress: string; |
20 | | - /**@internal */ |
21 | | - LoadFromXml(reader: EwsXmlReader): AlternateMailbox { |
22 | | - var altMailbox: AlternateMailbox = new AlternateMailbox(); |
23 | | - |
24 | | - do { |
25 | | - reader.Read(); |
26 | | - if (reader.NodeType == 1){//todo: 1 = System.Xml.XmlNodeType.Element) { |
27 | | - switch (reader.LocalName) { |
28 | | - case XmlElementNames.Type: |
29 | | - altMailbox.Type = reader.ReadElementValue();// reader.ReadElementValue<string>(); |
30 | | - break; |
31 | | - case XmlElementNames.DisplayName: |
32 | | - altMailbox.DisplayName = reader.ReadElementValue();//reader.ReadElementValue<string>(); |
33 | | - break; |
34 | | - case XmlElementNames.LegacyDN: |
35 | | - altMailbox.LegacyDN = reader.ReadElementValue();//reader.ReadElementValue<string>(); |
36 | | - break; |
37 | | - case XmlElementNames.Server: |
38 | | - altMailbox.Server = reader.ReadElementValue();//reader.ReadElementValue<string>(); |
39 | | - break; |
40 | | - case XmlElementNames.SmtpAddress: |
41 | | - altMailbox.SmtpAddress = reader.ReadElementValue();//reader.ReadElementValue<string>(); |
42 | | - break; |
43 | | - case XmlElementNames.OwnerSmtpAddress: |
44 | | - altMailbox.OwnerSmtpAddress = reader.ReadElementValue();//reader.ReadElementValue<string>(); |
45 | | - break; |
46 | | - default: |
47 | | - break; |
48 | | - } |
49 | | - } |
50 | | - } |
51 | | - while (!reader.IsElement(XmlNamespace.Autodiscover, XmlElementNames.AlternateMailbox)); |
52 | | - reader.SeekLast(); // to go back to last one, fix for xmlnode based reader. |
53 | | - return altMailbox; |
54 | | - } |
55 | | - static LoadFromJson(obj: any): AlternateMailbox { throw new Error("this was skipped as not needed at dev time, fix this"); } |
| 8 | + private type: string; |
| 9 | + private displayName: string; |
| 10 | + private legacyDN: string; |
| 11 | + private server: string; |
| 12 | + private smtpAddress: string; |
| 13 | + private ownerSmtpAddress: string; |
56 | 14 |
|
57 | | -} |
| 15 | + /** |
| 16 | + * Gets the alternate mailbox type. |
| 17 | + */ |
| 18 | + get Type(): string { |
| 19 | + return this.type; |
| 20 | + } |
| 21 | + /** @internal set */ |
| 22 | + set Type(value: string) { |
| 23 | + this.type = value; |
| 24 | + } |
| 25 | + |
| 26 | + /** |
| 27 | + * Gets the alternate mailbox display name. |
| 28 | + */ |
| 29 | + get DisplayName(): string { |
| 30 | + return this.displayName; |
| 31 | + } |
| 32 | + /** @internal set */ |
| 33 | + set DisplayName(value: string) { |
| 34 | + this.displayName = value; |
| 35 | + } |
| 36 | + |
| 37 | + /** |
| 38 | + * Gets the alternate mailbox legacy DN. |
| 39 | + */ |
| 40 | + get LegacyDN(): string { |
| 41 | + return this.legacyDN; |
| 42 | + } |
| 43 | + /** @internal set */ |
| 44 | + set LegacyDN(value: string) { |
| 45 | + this.legacyDN = value; |
| 46 | + } |
| 47 | + |
| 48 | + /** |
| 49 | + * Gets the alernate mailbox server. |
| 50 | + */ |
| 51 | + get Server(): string { |
| 52 | + return this.server; |
| 53 | + } |
| 54 | + /** @internal set */ |
| 55 | + set Server(value: string) { |
| 56 | + this.server = value; |
| 57 | + } |
58 | 58 |
|
| 59 | + /** |
| 60 | + * Gets the alternate mailbox address. |
| 61 | + * It has value only when Server and LegacyDN is empty. |
| 62 | + */ |
| 63 | + get SmtpAddress(): string { |
| 64 | + return this.smtpAddress; |
| 65 | + } |
| 66 | + /** @internal set */ |
| 67 | + set SmtpAddress(value: string) { |
| 68 | + this.smtpAddress = value; |
| 69 | + } |
59 | 70 |
|
| 71 | + /** |
| 72 | + * Gets the alternate mailbox owner SmtpAddress. |
| 73 | + */ |
| 74 | + get OwnerSmtpAddress(): string { |
| 75 | + return this.ownerSmtpAddress; |
| 76 | + } |
| 77 | + /** @internal set */ |
| 78 | + set OwnerSmtpAddress(value: string) { |
| 79 | + this.ownerSmtpAddress = value; |
| 80 | + } |
| 81 | + |
| 82 | + /** |
| 83 | + * Initializes a new instance of the **AlternateMailbox** class. |
| 84 | + */ |
| 85 | + private constructor() { |
| 86 | + } |
| 87 | + |
| 88 | + /** |
| 89 | + * @internal Loads AlternateMailbox instance. |
| 90 | + * |
| 91 | + * @param {any} jsObject Json Object converted from XML. |
| 92 | + * @returns {AlternateMailbox} AlternateMailbox. |
| 93 | + */ |
| 94 | + static LoadFromXmlJsObject(jsObject: any): AlternateMailbox { |
| 95 | + const altMailbox = new AlternateMailbox(); |
| 96 | + |
| 97 | + altMailbox.Type = jsObject[XmlElementNames.Type] || null; |
| 98 | + altMailbox.DisplayName = jsObject[XmlElementNames.DisplayName] || null; |
| 99 | + altMailbox.LegacyDN = jsObject[XmlElementNames.DisplayName] || null; |
| 100 | + altMailbox.Server = jsObject[XmlElementNames.DisplayName] || null; |
| 101 | + altMailbox.SmtpAddress = jsObject[XmlElementNames.DisplayName] || null; |
| 102 | + altMailbox.OwnerSmtpAddress = jsObject[XmlElementNames.DisplayName] || null; |
| 103 | + |
| 104 | + return altMailbox; |
| 105 | + } |
| 106 | +} |
0 commit comments