本文整理汇总了C#中System.ServiceModel.Description.OperationDescription类的典型用法代码示例。如果您正苦于以下问题:C# OperationDescription类的具体用法?C# OperationDescription怎么用?C# OperationDescription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OperationDescription类属于System.ServiceModel.Description命名空间,在下文中一共展示了OperationDescription类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FillOperation
static void FillOperation(IWmiInstance operation, OperationDescription operationDescription)
{
operation.SetProperty(AdministrationStrings.Name, operationDescription.Name);
operation.SetProperty(AdministrationStrings.Action, FixWildcardAction(operationDescription.Messages[0].Action));
if (operationDescription.Messages.Count > 1)
{
operation.SetProperty(AdministrationStrings.ReplyAction, FixWildcardAction(operationDescription.Messages[1].Action));
}
operation.SetProperty(AdministrationStrings.IsOneWay, operationDescription.IsOneWay);
operation.SetProperty(AdministrationStrings.IsInitiating, operationDescription.IsInitiating);
operation.SetProperty(AdministrationStrings.IsTerminating, operationDescription.IsTerminating);
operation.SetProperty(AdministrationStrings.AsyncPattern, null != operationDescription.BeginMethod);
if (null != operationDescription.SyncMethod)
{
if (null != operationDescription.SyncMethod.ReturnType)
{
operation.SetProperty(AdministrationStrings.ReturnType, operationDescription.SyncMethod.ReturnType.Name);
}
operation.SetProperty(AdministrationStrings.MethodSignature, operationDescription.SyncMethod.ToString());
ParameterInfo[] parameterInfo = operationDescription.SyncMethod.GetParameters();
string[] parameterTypes = new string[parameterInfo.Length];
for (int i = 0; i < parameterInfo.Length; i++)
{
parameterTypes[i] = parameterInfo[i].ParameterType.ToString();
}
operation.SetProperty(AdministrationStrings.ParameterTypes, parameterTypes);
}
operation.SetProperty(AdministrationStrings.IsCallback, operationDescription.Messages[0].Direction == MessageDirection.Output);
FillBehaviorsInfo(operation, operationDescription.Behaviors);
}
示例2: DefaultJsonSerializerOperationBehavior
public DefaultJsonSerializerOperationBehavior(OperationDescription operation, bool isCompress,
SerializeContentTypes contentType)
: base(operation)
{
m_IsCompress = isCompress;
m_ContentType = contentType;
}
开发者ID:JackFong,项目名称:GenericWcfServiceHostAndClient,代码行数:7,代码来源:DefaultJsonSerializerOperationBehavior.cs
示例3: XmlSerializerOperationFormatter
public XmlSerializerOperationFormatter(OperationDescription description, XmlSerializerFormatAttribute xmlSerializerFormatAttribute,
MessageInfo requestMessageInfo, MessageInfo replyMessageInfo) :
base(description, xmlSerializerFormatAttribute.Style == OperationFormatStyle.Rpc, false/*isEncoded*/)
{
_requestMessageInfo = requestMessageInfo;
_replyMessageInfo = replyMessageInfo;
}
示例4: GetRequestClientFormatter
protected override IClientMessageFormatter GetRequestClientFormatter(OperationDescription operationDescription, ServiceEndpoint endpoint)
{
if (operationDescription.Behaviors.Find<WebGetAttribute>() != null)
{
// no change for GET operations
return base.GetRequestClientFormatter(operationDescription, endpoint);
}
else
{
WebInvokeAttribute wia = operationDescription.Behaviors.Find<WebInvokeAttribute>();
if (wia != null)
{
if (wia.Method == "HEAD")
{
// essentially a GET operation
return base.GetRequestClientFormatter(operationDescription, endpoint);
}
}
}
if (operationDescription.Messages[0].Body.Parts.Count == 0)
{
// nothing in the body, still use the default
return base.GetRequestClientFormatter(operationDescription, endpoint);
}
return new NewtonsoftJsonClientFormatter(operationDescription, endpoint);
}
示例5: ApplyDispatchBehavior
public void ApplyDispatchBehavior(OperationDescription description,
System.ServiceModel.Dispatcher.DispatchOperation dispatch)
{
IOperationBehavior innerBehavior =
new ReferencePreservingDataContractSerializerOperationBehavior(description);
innerBehavior.ApplyDispatchBehavior(description, dispatch);
}
示例6: ValidateOperation
private void ValidateOperation(OperationDescription operation)
{
if (operation.Messages.Count > 1)
{
if (operation.Messages[1].Body.Parts.Count > 0)
{
throw new InvalidOperationException("Operations cannot have out/ref parameters.");
}
}
WebMessageBodyStyle bodyStyle = this.GetBodyStyle(operation);
int inputParameterCount = operation.Messages[0].Body.Parts.Count;
if (!this.IsGetOperation(operation))
{
var wrappedRequest = bodyStyle == WebMessageBodyStyle.Wrapped || bodyStyle == WebMessageBodyStyle.WrappedRequest;
if (inputParameterCount == 1 && wrappedRequest)
{
throw new InvalidOperationException("Wrapped body style for single parameters not implemented in this behavior.");
}
}
var wrappedResponse = bodyStyle == WebMessageBodyStyle.Wrapped || bodyStyle == WebMessageBodyStyle.WrappedResponse;
var isVoidReturn = operation.Messages.Count == 1 || operation.Messages[1].Body.ReturnValue.Type == typeof(void);
if (!isVoidReturn && wrappedResponse)
{
throw new InvalidOperationException("Wrapped response not implemented in this behavior.");
}
}
示例7: AddBindingParameters
public void AddBindingParameters(OperationDescription description, BindingParameterCollection parameters)
{
//see if ChunkingBindingParameter already exists
ChunkingBindingParameter param =
parameters.Find<ChunkingBindingParameter>();
if (param == null)
{
param = new ChunkingBindingParameter();
parameters.Add(param);
}
if ((appliesTo & ChunkingAppliesTo.InMessage)
== ChunkingAppliesTo.InMessage)
{
//add input message's action to ChunkingBindingParameter
param.AddAction(description.Messages[0].Action);
}
if (!description.IsOneWay &&
((appliesTo & ChunkingAppliesTo.OutMessage)
== ChunkingAppliesTo.OutMessage))
{
//add output message's action to ChunkingBindingParameter
param.AddAction(description.Messages[1].Action);
}
}
示例8: ApplyClientBehavior
public void ApplyClientBehavior(OperationDescription description, ClientOperation proxy)
{
var dataContractSerializerOperationBehavior =
description.Behaviors.Find<DataContractSerializerOperationBehavior>();
dataContractSerializerOperationBehavior.DataContractResolver =
new ProxyDataContractResolver();
}
示例9: InferMessageDescription
internal override void InferMessageDescription(OperationDescription operation, object owner, MessageDirection direction)
{
ContractInferenceHelper.CheckForDisposableParameters(operation, this.InternalDeclaredMessageType);
string overridingAction = null;
SerializerOption dataContractSerializer = SerializerOption.DataContractSerializer;
Receive receive = owner as Receive;
if (receive != null)
{
overridingAction = receive.Action;
dataContractSerializer = receive.SerializerOption;
}
else
{
ReceiveReply reply = owner as ReceiveReply;
overridingAction = reply.Action;
dataContractSerializer = reply.Request.SerializerOption;
}
if (direction == MessageDirection.Input)
{
ContractInferenceHelper.AddInputMessage(operation, overridingAction, this.InternalDeclaredMessageType, dataContractSerializer);
}
else
{
ContractInferenceHelper.AddOutputMessage(operation, overridingAction, this.InternalDeclaredMessageType, dataContractSerializer);
}
}
示例10: ApplyDispatchBehavior
public void ApplyDispatchBehavior(OperationDescription description, DispatchOperation dispatch)
{
if (description == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("description");
}
if (dispatch == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("dispatch");
}
if (dispatch.Parent == null
|| dispatch.Parent.ChannelDispatcher == null
|| dispatch.Parent.ChannelDispatcher.Host == null
|| dispatch.Parent.ChannelDispatcher.Host.Description == null
|| dispatch.Parent.ChannelDispatcher.Host.Description.Behaviors == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR2.GetString(SR2.DispatchOperationInInvalidState)));
}
WorkflowRuntimeBehavior workflowRuntimeBehavior = dispatch.Parent.ChannelDispatcher.Host.Description.Behaviors.Find<WorkflowRuntimeBehavior>();
if (workflowRuntimeBehavior == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR2.GetString(SR2.NoWorkflowRuntimeBehavior)));
}
dispatch.Invoker = new WorkflowOperationInvoker(description, this, workflowRuntimeBehavior.WorkflowRuntime, dispatch.Parent);
}
示例11: ZipCodeInspector
void IOperationBehavior.ApplyClientBehavior(OperationDescription operationDescription,
ClientOperation clientOperation)
{
ZipCodeInspector zipCodeInspector = new ZipCodeInspector();
clientOperation.ParameterInspectors.Add(zipCodeInspector);
}
示例12: Validate
public void Validate(OperationDescription operationDescription)
{
if (operationDescription.Messages.Count < 2 || operationDescription.Messages[1].Body.ReturnValue.Type != typeof(double))
{
throw new InvalidOperationException("This behavior can only be applied on operation which returns double");
}
}
示例13: TryGetSurrogateBehavior
private static void TryGetSurrogateBehavior(OperationDescription operationDescription, ref IOperationBehavior original, ref IOperationBehavior surrogate)
{
if (!IsUntypedMessage(operationDescription.Messages[0]) &&
operationDescription.Messages[0].Body.Parts.Count != 0)
{
var webGetAttribute = operationDescription.Behaviors.Find<WebGetAttribute>();
if (webGetAttribute != null)
{
original = webGetAttribute;
surrogate = new WebInvokeAttribute {
BodyStyle = webGetAttribute.BodyStyle,
Method = "NONE",
RequestFormat = webGetAttribute.RequestFormat,
ResponseFormat = webGetAttribute.ResponseFormat,
UriTemplate = webGetAttribute.UriTemplate };
}
else
{
var webInvokeAttribute = operationDescription.Behaviors.Find<WebInvokeAttribute>();
if (webInvokeAttribute != null && webInvokeAttribute.Method == "GET")
{
original = webInvokeAttribute;
surrogate = new WebInvokeAttribute {
BodyStyle = webInvokeAttribute.BodyStyle,
Method = "NONE",
RequestFormat = webInvokeAttribute.RequestFormat,
ResponseFormat = webInvokeAttribute.ResponseFormat,
UriTemplate = webInvokeAttribute.UriTemplate };
}
}
}
}
示例14: ApplyDispatchBehavior
public void ApplyDispatchBehavior(OperationDescription description, DispatchOperation runtime)
{
if (_runtime == runtime.Parent)
{
runtime.Formatter = new BinaryFormatterAdapter(description.Name, description.SyncMethod.GetParameters(), runtime.Formatter);
}
}
示例15:
void IOperationBehavior.ApplyDispatchBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.DispatchOperation dispatchOperation)
{
if (IsAuthenticationEnabled)
{
dispatchOperation.ParameterInspectors.Add(this);
}
}