| | | 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 | | |
| | | 6 | | namespace CoreWCF |
| | | 7 | | { |
| | | 8 | | [AttributeUsage(CoreWCFAttributeTargets.ServiceContract | CoreWCFAttributeTargets.OperationContract, Inherited = fal |
| | | 9 | | public sealed class XmlSerializerFormatAttribute : Attribute |
| | | 10 | | { |
| | | 11 | | private OperationFormatStyle _style; |
| | | 12 | | private bool _isStyleSet; |
| | | 13 | | private OperationFormatUse _use; |
| | | 14 | | |
| | 274 | 15 | | public bool SupportFaults { get; set; } = false; |
| | | 16 | | |
| | | 17 | | public OperationFormatStyle Style |
| | | 18 | | { |
| | 218 | 19 | | get { return _style; } |
| | | 20 | | set |
| | | 21 | | { |
| | 183 | 22 | | ValidateOperationFormatStyle(value); |
| | 183 | 23 | | _style = value; |
| | 183 | 24 | | _isStyleSet = true; |
| | 183 | 25 | | } |
| | | 26 | | } |
| | | 27 | | |
| | | 28 | | public OperationFormatUse Use |
| | | 29 | | { |
| | 0 | 30 | | get { return _use; } |
| | | 31 | | set |
| | | 32 | | { |
| | 169 | 33 | | ValidateOperationFormatUse(value); |
| | 169 | 34 | | _use = value; |
| | 169 | 35 | | if (!_isStyleSet && IsEncoded) |
| | | 36 | | { |
| | 0 | 37 | | Style = OperationFormatStyle.Rpc; |
| | | 38 | | } |
| | 169 | 39 | | } |
| | | 40 | | } |
| | | 41 | | |
| | | 42 | | internal bool IsEncoded |
| | | 43 | | { |
| | 306 | 44 | | get { return _use == OperationFormatUse.Encoded; } |
| | 0 | 45 | | set { _use = value ? OperationFormatUse.Encoded : OperationFormatUse.Literal; } |
| | | 46 | | } |
| | | 47 | | |
| | | 48 | | internal static void ValidateOperationFormatStyle(OperationFormatStyle value) |
| | | 49 | | { |
| | 183 | 50 | | if (!OperationFormatStyleHelper.IsDefined(value)) |
| | | 51 | | { |
| | 0 | 52 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(value)) |
| | | 53 | | } |
| | 183 | 54 | | } |
| | | 55 | | |
| | | 56 | | internal static void ValidateOperationFormatUse(OperationFormatUse value) |
| | | 57 | | { |
| | 169 | 58 | | if (!OperationFormatUseHelper.IsDefined(value)) |
| | | 59 | | { |
| | 0 | 60 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(value)) |
| | | 61 | | } |
| | 169 | 62 | | } |
| | | 63 | | } |
| | | 64 | | } |