| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System.Xml; |
| | | 5 | | |
| | | 6 | | namespace CoreWCF |
| | | 7 | | { |
| | | 8 | | public sealed class EnvelopeVersion |
| | | 9 | | { |
| | | 10 | | private readonly string _actor; |
| | | 11 | | private readonly string _toStringFormat; |
| | | 12 | | |
| | 36 | 13 | | private EnvelopeVersion(string ultimateReceiverActor, string nextDestinationActorValue, |
| | 36 | 14 | | string ns, XmlDictionaryString dictionaryNs, string actor, XmlDictionaryString dictionaryActor, |
| | 36 | 15 | | string toStringFormat, string senderFaultName, string receiverFaultName) |
| | | 16 | | { |
| | 36 | 17 | | _toStringFormat = toStringFormat; |
| | 36 | 18 | | UltimateDestinationActor = ultimateReceiverActor; |
| | 36 | 19 | | NextDestinationActorValue = nextDestinationActorValue; |
| | 36 | 20 | | Namespace = ns; |
| | 36 | 21 | | DictionaryNamespace = dictionaryNs; |
| | 36 | 22 | | _actor = actor; |
| | 36 | 23 | | DictionaryActor = dictionaryActor; |
| | 36 | 24 | | SenderFaultName = senderFaultName; |
| | 36 | 25 | | ReceiverFaultName = receiverFaultName; |
| | | 26 | | |
| | 36 | 27 | | if (ultimateReceiverActor != null) |
| | | 28 | | { |
| | 24 | 29 | | if (ultimateReceiverActor.Length == 0) |
| | | 30 | | { |
| | 12 | 31 | | MustUnderstandActorValues = new string[] { "", nextDestinationActorValue }; |
| | 12 | 32 | | UltimateDestinationActorValues = new string[] { "", nextDestinationActorValue }; |
| | | 33 | | } |
| | | 34 | | else |
| | | 35 | | { |
| | 12 | 36 | | MustUnderstandActorValues = new string[] { "", ultimateReceiverActor, nextDestinationActorValue }; |
| | 12 | 37 | | UltimateDestinationActorValues = new string[] { "", ultimateReceiverActor, nextDestinationActorValue |
| | | 38 | | } |
| | | 39 | | } |
| | 24 | 40 | | } |
| | | 41 | | |
| | 14543 | 42 | | internal XmlDictionaryString DictionaryActor { get; } |
| | | 43 | | |
| | 4041 | 44 | | public string Namespace { get; } |
| | | 45 | | |
| | 72479 | 46 | | public XmlDictionaryString DictionaryNamespace { get; } |
| | | 47 | | |
| | 26 | 48 | | public string NextDestinationActorValue { get; } |
| | | 49 | | |
| | 121426 | 50 | | public static EnvelopeVersion None { get; } = new EnvelopeVersion( |
| | 12 | 51 | | null, |
| | 12 | 52 | | null, |
| | 12 | 53 | | MessageStrings.Namespace, |
| | 12 | 54 | | XD.MessageDictionary.Namespace, |
| | 12 | 55 | | null, |
| | 12 | 56 | | null, |
| | 12 | 57 | | SR.EnvelopeNoneToStringFormat, |
| | 12 | 58 | | "Sender", |
| | 12 | 59 | | "Receiver"); |
| | | 60 | | |
| | 2853 | 61 | | public static EnvelopeVersion Soap11 { get; } = new EnvelopeVersion( |
| | 12 | 62 | | "", |
| | 12 | 63 | | "http://schemas.xmlsoap.org/soap/actor/next", |
| | 12 | 64 | | Message11Strings.Namespace, |
| | 12 | 65 | | XD.Message11Dictionary.Namespace, |
| | 12 | 66 | | Message11Strings.Actor, |
| | 12 | 67 | | XD.Message11Dictionary.Actor, |
| | 12 | 68 | | SR.Soap11ToStringFormat, |
| | 12 | 69 | | "Client", |
| | 12 | 70 | | "Server"); |
| | | 71 | | |
| | 23264 | 72 | | public static EnvelopeVersion Soap12 { get; } = new EnvelopeVersion( |
| | 12 | 73 | | "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver", |
| | 12 | 74 | | "http://www.w3.org/2003/05/soap-envelope/role/next", |
| | 12 | 75 | | Message12Strings.Namespace, |
| | 12 | 76 | | XD.Message12Dictionary.Namespace, |
| | 12 | 77 | | Message12Strings.Role, |
| | 12 | 78 | | XD.Message12Dictionary.Role, |
| | 12 | 79 | | SR.Soap12ToStringFormat, |
| | 12 | 80 | | "Sender", |
| | 12 | 81 | | "Receiver"); |
| | | 82 | | |
| | 187 | 83 | | internal string ReceiverFaultName { get; } |
| | | 84 | | |
| | 0 | 85 | | internal string[] MustUnderstandActorValues { get; } |
| | | 86 | | |
| | 13 | 87 | | internal string UltimateDestinationActor { get; } |
| | | 88 | | |
| | 0 | 89 | | public string[] GetUltimateDestinationActorValues() => (string[])UltimateDestinationActorValues.Clone(); |
| | | 90 | | |
| | 48 | 91 | | internal string[] UltimateDestinationActorValues { get; } |
| | | 92 | | |
| | | 93 | | internal bool IsUltimateDestinationActor(string actor) |
| | | 94 | | { |
| | 4837 | 95 | | return actor.Length == 0 || actor == UltimateDestinationActor || actor == NextDestinationActorValue; |
| | | 96 | | } |
| | | 97 | | |
| | | 98 | | public override string ToString() |
| | | 99 | | { |
| | 34 | 100 | | return SR.Format(_toStringFormat, Namespace); |
| | | 101 | | } |
| | | 102 | | |
| | 339 | 103 | | internal string SenderFaultName { get; } |
| | | 104 | | } |
| | | 105 | | } |