1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
|
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.ServiceModel.Description
{
using System;
using System.Collections.Generic;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.ServiceModel;
public class OperationContractGenerationContext
{
readonly CodeMemberMethod syncMethod;
readonly CodeMemberMethod beginMethod;
readonly ServiceContractGenerationContext contract;
readonly CodeMemberMethod endMethod;
readonly OperationDescription operation;
readonly ServiceContractGenerator serviceContractGenerator;
readonly CodeTypeDeclaration declaringType;
readonly CodeMemberMethod taskMethod;
CodeTypeReference declaringTypeReference;
OperationContractGenerationContext(ServiceContractGenerator serviceContractGenerator, ServiceContractGenerationContext contract, OperationDescription operation, CodeTypeDeclaration declaringType)
{
if (serviceContractGenerator == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("serviceContractGenerator"));
if (contract == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("contract"));
if (declaringType == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("declaringType"));
this.serviceContractGenerator = serviceContractGenerator;
this.contract = contract;
this.operation = operation;
this.declaringType = declaringType;
}
public OperationContractGenerationContext(ServiceContractGenerator serviceContractGenerator, ServiceContractGenerationContext contract, OperationDescription operation, CodeTypeDeclaration declaringType, CodeMemberMethod syncMethod, CodeMemberMethod beginMethod, CodeMemberMethod endMethod, CodeMemberMethod taskMethod)
: this(serviceContractGenerator, contract, operation, declaringType)
{
if (syncMethod == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("syncMethod"));
if (beginMethod == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("beginMethod"));
if (endMethod == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("endMethod"));
if (taskMethod == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("taskMethod"));
this.syncMethod = syncMethod;
this.beginMethod = beginMethod;
this.endMethod = endMethod;
this.taskMethod = taskMethod;
}
public OperationContractGenerationContext(ServiceContractGenerator serviceContractGenerator, ServiceContractGenerationContext contract, OperationDescription operation, CodeTypeDeclaration declaringType, CodeMemberMethod syncMethod, CodeMemberMethod beginMethod, CodeMemberMethod endMethod)
: this(serviceContractGenerator, contract, operation, declaringType)
{
if (syncMethod == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("syncMethod"));
if (beginMethod == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("beginMethod"));
if (endMethod == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("endMethod"));
this.syncMethod = syncMethod;
this.beginMethod = beginMethod;
this.endMethod = endMethod;
}
public OperationContractGenerationContext(ServiceContractGenerator serviceContractGenerator, ServiceContractGenerationContext contract, OperationDescription operation, CodeTypeDeclaration declaringType, CodeMemberMethod syncMethod, CodeMemberMethod taskMethod)
: this(serviceContractGenerator, contract, operation, declaringType)
{
if (syncMethod == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("syncMethod"));
if (taskMethod == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("taskMethod"));
this.syncMethod = syncMethod;
this.taskMethod = taskMethod;
}
public OperationContractGenerationContext(ServiceContractGenerator serviceContractGenerator, ServiceContractGenerationContext contract, OperationDescription operation, CodeTypeDeclaration declaringType, CodeMemberMethod method)
: this(serviceContractGenerator, contract, operation, declaringType)
{
if (method == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("method"));
this.syncMethod = method;
this.beginMethod = null;
this.endMethod = null;
}
public ServiceContractGenerationContext Contract
{
get { return this.contract; }
}
public CodeTypeDeclaration DeclaringType
{
get { return this.declaringType; }
}
internal CodeTypeReference DeclaringTypeReference
{
get { return this.declaringTypeReference; }
set { this.declaringTypeReference = value; }
}
public CodeMemberMethod BeginMethod
{
get { return this.beginMethod; }
}
public CodeMemberMethod EndMethod
{
get { return this.endMethod; }
}
public CodeMemberMethod TaskMethod
{
get { return this.taskMethod; }
}
public CodeMemberMethod SyncMethod
{
get { return this.syncMethod; }
}
public bool IsAsync
{
get { return this.beginMethod != null; }
}
public bool IsTask
{
get { return this.taskMethod != null; }
}
// true if this operation was declared somewhere up the hierarchy (rather than at this level)
internal bool IsInherited
{
get { return !(this.declaringType == contract.ContractType || this.declaringType == contract.DuplexCallbackType); }
}
public OperationDescription Operation
{
get { return this.operation; }
}
public ServiceContractGenerator ServiceContractGenerator
{
get { return this.serviceContractGenerator; }
}
}
}
|