| | | 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; |
| | | 5 | | using CoreWCF.Channels; |
| | | 6 | | |
| | | 7 | | namespace CoreWCF.Description |
| | | 8 | | { |
| | | 9 | | public class MessageDescription |
| | | 10 | | { |
| | | 11 | | private static Type s_typeOfUntypedMessage; |
| | | 12 | | private MessageDescriptionItems _items; |
| | | 13 | | |
| | | 14 | | //XmlQualifiedName xsdType; |
| | | 15 | | |
| | 10086 | 16 | | public MessageDescription(string action, MessageDirection direction) : this(action, direction, null) { } |
| | | 17 | | |
| | 5209 | 18 | | internal MessageDescription(string action, MessageDirection direction, MessageDescriptionItems items) |
| | | 19 | | { |
| | 5209 | 20 | | if (!MessageDirectionHelper.IsDefined(direction)) |
| | | 21 | | { |
| | 0 | 22 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(directi |
| | | 23 | | } |
| | | 24 | | |
| | 5209 | 25 | | Action = action; |
| | 5209 | 26 | | Direction = direction; |
| | 5209 | 27 | | _items = items; |
| | 5209 | 28 | | } |
| | | 29 | | |
| | 80 | 30 | | internal MessageDescription(MessageDescription other) |
| | | 31 | | { |
| | 80 | 32 | | Action = other.Action; |
| | 80 | 33 | | Direction = other.Direction; |
| | 80 | 34 | | Items.Body = other.Items.Body.Clone(); |
| | 160 | 35 | | foreach (MessageHeaderDescription mhd in other.Items.Headers) |
| | | 36 | | { |
| | 0 | 37 | | Items.Headers.Add(mhd.Clone() as MessageHeaderDescription); |
| | | 38 | | } |
| | 160 | 39 | | foreach (MessagePropertyDescription mpd in other.Items.Properties) |
| | | 40 | | { |
| | 0 | 41 | | Items.Properties.Add(mpd.Clone() as MessagePropertyDescription); |
| | | 42 | | } |
| | 80 | 43 | | MessageName = other.MessageName; |
| | 80 | 44 | | MessageType = other.MessageType; |
| | 80 | 45 | | } |
| | | 46 | | |
| | | 47 | | public MessageDescription Clone() |
| | | 48 | | { |
| | 80 | 49 | | return new MessageDescription(this); |
| | | 50 | | } |
| | | 51 | | |
| | 19459 | 52 | | public string Action { get; internal set; } |
| | | 53 | | |
| | | 54 | | public MessageBodyDescription Body |
| | | 55 | | { |
| | 172827 | 56 | | get { return Items.Body; } |
| | | 57 | | } |
| | | 58 | | |
| | 15198 | 59 | | public MessageDirection Direction { get; } |
| | | 60 | | |
| | | 61 | | public MessageHeaderDescriptionCollection Headers |
| | | 62 | | { |
| | 15750 | 63 | | get { return Items.Headers; } |
| | | 64 | | } |
| | | 65 | | |
| | | 66 | | public MessagePropertyDescriptionCollection Properties |
| | | 67 | | { |
| | 5489 | 68 | | get { return Items.Properties; } |
| | | 69 | | } |
| | | 70 | | |
| | | 71 | | internal MessageDescriptionItems Items |
| | | 72 | | { |
| | | 73 | | get |
| | | 74 | | { |
| | 194484 | 75 | | if (_items == null) |
| | | 76 | | { |
| | 5098 | 77 | | _items = new MessageDescriptionItems(); |
| | | 78 | | } |
| | | 79 | | |
| | 194484 | 80 | | return _items; |
| | | 81 | | } |
| | | 82 | | } |
| | | 83 | | |
| | 502 | 84 | | internal bool HasProtectionLevel => false; |
| | | 85 | | |
| | | 86 | | internal static Type TypeOfUntypedMessage |
| | | 87 | | { |
| | | 88 | | get |
| | | 89 | | { |
| | 15310 | 90 | | if (s_typeOfUntypedMessage == null) |
| | | 91 | | { |
| | 10 | 92 | | s_typeOfUntypedMessage = typeof(Message); |
| | | 93 | | } |
| | 15310 | 94 | | return s_typeOfUntypedMessage; |
| | | 95 | | } |
| | | 96 | | } |
| | | 97 | | |
| | 732 | 98 | | internal XmlName MessageName { get; set; } |
| | | 99 | | |
| | 25646 | 100 | | public Type MessageType { get; set; } |
| | | 101 | | |
| | | 102 | | internal bool IsTypedMessage |
| | | 103 | | { |
| | | 104 | | get |
| | | 105 | | { |
| | 22616 | 106 | | return MessageType != null; |
| | | 107 | | } |
| | | 108 | | } |
| | | 109 | | |
| | | 110 | | internal bool IsUntypedMessage |
| | | 111 | | { |
| | | 112 | | get |
| | | 113 | | { |
| | 18695 | 114 | | return (Body.ReturnValue != null && Body.Parts.Count == 0 && Body.ReturnValue.Type == TypeOfUntypedMessa |
| | 18695 | 115 | | (Body.ReturnValue == null && Body.Parts.Count == 1 && Body.Parts[0].Type == TypeOfUntypedMessage); |
| | | 116 | | } |
| | | 117 | | } |
| | | 118 | | |
| | | 119 | | internal bool IsVoid |
| | | 120 | | { |
| | | 121 | | get |
| | | 122 | | { |
| | 10224 | 123 | | return !IsTypedMessage && Body.Parts.Count == 0 && (Body.ReturnValue == null || Body.ReturnValue.Type == |
| | | 124 | | } |
| | | 125 | | } |
| | | 126 | | } |
| | | 127 | | |
| | | 128 | | internal class MessageDescriptionItems |
| | | 129 | | { |
| | | 130 | | private MessageHeaderDescriptionCollection _headers; |
| | | 131 | | private MessageBodyDescription _body; |
| | | 132 | | private MessagePropertyDescriptionCollection _properties; |
| | | 133 | | |
| | | 134 | | internal MessageBodyDescription Body |
| | | 135 | | { |
| | | 136 | | get |
| | | 137 | | { |
| | | 138 | | if (_body == null) |
| | | 139 | | { |
| | | 140 | | _body = new MessageBodyDescription(); |
| | | 141 | | } |
| | | 142 | | |
| | | 143 | | return _body; |
| | | 144 | | } |
| | | 145 | | set |
| | | 146 | | { |
| | | 147 | | _body = value; |
| | | 148 | | } |
| | | 149 | | } |
| | | 150 | | |
| | | 151 | | internal MessageHeaderDescriptionCollection Headers |
| | | 152 | | { |
| | | 153 | | get |
| | | 154 | | { |
| | | 155 | | if (_headers == null) |
| | | 156 | | { |
| | | 157 | | _headers = new MessageHeaderDescriptionCollection(); |
| | | 158 | | } |
| | | 159 | | |
| | | 160 | | return _headers; |
| | | 161 | | } |
| | | 162 | | } |
| | | 163 | | |
| | | 164 | | internal MessagePropertyDescriptionCollection Properties |
| | | 165 | | { |
| | | 166 | | get |
| | | 167 | | { |
| | | 168 | | if (_properties == null) |
| | | 169 | | { |
| | | 170 | | _properties = new MessagePropertyDescriptionCollection(); |
| | | 171 | | } |
| | | 172 | | |
| | | 173 | | return _properties; |
| | | 174 | | } |
| | | 175 | | } |
| | | 176 | | } |
| | | 177 | | } |