Files
dotnet-bot adf899c629 Adding System.Data..., System.ServiceModel..., and System.Web...
Adding reference source for
System.Data
System.Data.DataSetExtensions
System.Data.Entity
System.Data.Entity.Design
System.Data.Linq
System.Data.SqlXml
System.ServiceModel
System.ServiceModel.Activation
System.ServiceModel.Activities
System.ServiceModel.Channels
System.ServiceModel.Discovery
System.ServiceModel.Internals
System.ServiceModel.Routing
System.ServiceModel.WasHosting
System.ServiceModel.Web
System.Web
System.Web.ApplicationServices
System.Web.DynamicData
System.Web.Entity
System.Web.Entity.Design
System.Web.Extensions
System.Web.Mobile
System.Web.Routing
System.Web.Services
System.Xml
System.Xml.Linq
2016-05-03 00:07:37 +02:00

142 lines
4.3 KiB
C#

//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.ServiceModel
{
using System.Net.Security;
using System.Reflection;
using System.ServiceModel.Description;
using System.ServiceModel.Security;
[AttributeUsage(ServiceModelAttributeTargets.OperationContract)]
public sealed class OperationContractAttribute : Attribute
{
string name = null;
string action = null;
string replyAction = null;
bool asyncPattern = false;
bool isInitiating = true;
bool isTerminating = false;
bool isOneWay = false;
ProtectionLevel protectionLevel = ProtectionLevel.None;
bool hasProtectionLevel = false;
public string Name
{
get { return this.name; }
set
{
if (value == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
}
if (value == "")
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value",
SR.GetString(SR.SFxNameCannotBeEmpty)));
}
this.name = value;
}
}
internal const string ActionPropertyName = "Action";
public string Action
{
get { return this.action; }
set
{
if (value == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
}
this.action = value;
}
}
internal const string ProtectionLevelPropertyName = "ProtectionLevel";
public ProtectionLevel ProtectionLevel
{
get
{
return this.protectionLevel;
}
set
{
if (!ProtectionLevelHelper.IsDefined(value))
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value"));
this.protectionLevel = value;
this.hasProtectionLevel = true;
}
}
public bool HasProtectionLevel
{
get { return this.hasProtectionLevel; }
}
internal const string ReplyActionPropertyName = "ReplyAction";
public string ReplyAction
{
get { return this.replyAction; }
set
{
if (value == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
}
this.replyAction = value;
}
}
public bool AsyncPattern
{
get { return this.asyncPattern; }
set { this.asyncPattern = value; }
}
public bool IsOneWay
{
get { return this.isOneWay; }
set { this.isOneWay = value; }
}
public bool IsInitiating
{
get { return this.isInitiating; }
set { this.isInitiating = value; }
}
public bool IsTerminating
{
get { return this.isTerminating; }
set { this.isTerminating = value; }
}
internal bool IsSessionOpenNotificationEnabled
{
get
{
return this.Action == OperationDescription.SessionOpenedAction;
}
}
internal void EnsureInvariants(MethodInfo methodInfo, string operationName)
{
if (this.IsSessionOpenNotificationEnabled)
{
if (!this.IsOneWay
|| !this.IsInitiating
|| methodInfo.GetParameters().Length > 0)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
SR.GetString(SR.ContractIsNotSelfConsistentWhenIsSessionOpenNotificationEnabled, operationName, "Action", OperationDescription.SessionOpenedAction, "IsOneWay", "IsInitiating")));
}
}
}
}
}