| | | 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 System.Reflection; |
| | | 6 | | using CoreWCF.Description; |
| | | 7 | | |
| | | 8 | | namespace CoreWCF |
| | | 9 | | { |
| | | 10 | | [AttributeUsage(CoreWCFAttributeTargets.OperationContract)] |
| | | 11 | | public sealed class OperationContractAttribute : Attribute |
| | | 12 | | { |
| | | 13 | | private string _name; |
| | | 14 | | private string _action; |
| | | 15 | | private string _replyAction; |
| | | 16 | | |
| | | 17 | | public string Name |
| | | 18 | | { |
| | 2686 | 19 | | get { return _name; } |
| | | 20 | | set |
| | | 21 | | { |
| | 7790 | 22 | | if (value == null) |
| | | 23 | | { |
| | 0 | 24 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value)); |
| | | 25 | | } |
| | 7790 | 26 | | if (value == "") |
| | | 27 | | { |
| | 0 | 28 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val |
| | 0 | 29 | | SR.SFxNameCannotBeEmpty)); |
| | | 30 | | } |
| | | 31 | | |
| | 7790 | 32 | | _name = value; |
| | 7790 | 33 | | } |
| | | 34 | | } |
| | | 35 | | |
| | | 36 | | internal const string ActionPropertyName = "Action"; |
| | | 37 | | public string Action |
| | | 38 | | { |
| | 5372 | 39 | | get { return _action; } |
| | | 40 | | set |
| | | 41 | | { |
| | 7581 | 42 | | _action = value ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value)); |
| | 7580 | 43 | | } |
| | | 44 | | } |
| | | 45 | | |
| | | 46 | | internal const string ReplyActionPropertyName = "ReplyAction"; |
| | | 47 | | public string ReplyAction |
| | | 48 | | { |
| | 3012 | 49 | | get { return _replyAction; } |
| | | 50 | | set |
| | | 51 | | { |
| | 7714 | 52 | | _replyAction = value ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value)); |
| | 7713 | 53 | | } |
| | | 54 | | } |
| | | 55 | | |
| | 2641 | 56 | | public bool AsyncPattern { get; set; } |
| | | 57 | | |
| | 11029 | 58 | | public bool IsOneWay { get; set; } |
| | | 59 | | |
| | 20420 | 60 | | public bool IsInitiating { get; set; } = true; |
| | | 61 | | |
| | 2961 | 62 | | public bool IsTerminating { get; set; } |
| | | 63 | | |
| | | 64 | | internal bool IsSessionOpenNotificationEnabled |
| | | 65 | | { |
| | | 66 | | get |
| | | 67 | | { |
| | 2686 | 68 | | return Action == OperationDescription.SessionOpenedAction; |
| | | 69 | | } |
| | | 70 | | } |
| | | 71 | | |
| | | 72 | | internal void EnsureInvariants(MethodInfo methodInfo, string operationName) |
| | | 73 | | { |
| | | 74 | | // This code is used for WebSockets open notification |
| | | 75 | | //if (IsSessionOpenNotificationEnabled) |
| | | 76 | | //{ |
| | | 77 | | // if (!IsOneWay |
| | | 78 | | // || !this.IsInitiating |
| | | 79 | | // || methodInfo.GetParameters().Length > 0) |
| | | 80 | | // { |
| | | 81 | | // throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException( |
| | | 82 | | // SR.Format(SR.ContractIsNotSelfConsistentWhenIsSessionOpenNotificationEnabled, operationName, " |
| | | 83 | | // } |
| | | 84 | | //} |
| | 2686 | 85 | | } |
| | | 86 | | } |
| | | 87 | | } |