本文整理汇总了C#中IncomingMessage.GetPayload方法的典型用法代码示例。如果您正苦于以下问题:C# IncomingMessage.GetPayload方法的具体用法?C# IncomingMessage.GetPayload怎么用?C# IncomingMessage.GetPayload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IncomingMessage
的用法示例。
在下文中一共展示了IncomingMessage.GetPayload方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Subscribe
private OutgoingMessage Subscribe(IncomingMessage requestMessage)
{
var toHeader = requestMessage.GetHeader<ToHeader>();
var subscriptionManagerReference = new EndpointReference(toHeader.Uri);
var request = requestMessage.GetPayload<SubscribeRequest>();
var responseMessage = new OutgoingMessage()
.AddHeader(new ActionHeader(Constants.SubscribeResponseAction), false);
var expiration = CalculateExpiration(request.Expires);
var filterInstance = GetFilterInstance(request);
var identifier = GenerateUniqueSubscriptionIdentifier();
var subscription = new Subscription(expiration, _requestHandler, filterInstance, subscriptionManagerReference, requestMessage);
_activeSubscriptions.Add(identifier, subscription);
OnSubscribed(identifier, subscription);
//R7.2.4-1
var body = new SubscribeResponse
{
SubscriptionManager = subscriptionManagerReference,
EnumerationContext = request.Delivery.Mode == Delivery.DeliveryModePull
? new EnumerationContextKey(
identifier)
: null,
Expires = expiration
};
responseMessage.SetBody(new SerializerBodyWriter(body));
return responseMessage;
}
示例2: Pull
private OutgoingMessage Pull(IncomingMessage requestMessage)
{
var response = CreatePullResponse();
var request = requestMessage.GetPayload<PullRequest>();
IPullHandler handler;
var context = request.EnumerationContext.Text;
lock (_handlers)
{
if (!_handlers.TryGetValue(context, out handler))
{
throw new InvalidEnumerationContextFaultException();
}
}
var maxElements = GetMaxElements(request);
var maxTime = GetMaxTime(request);
var pullResult = handler.Pull(maxElements, maxTime, context);
var items = new EnumerationItemList(pullResult.Items, pullResult.EnumerationMode);
if (pullResult.EndOfSequence)
{
handler.Dispose();
lock (_handlers)
{
_handlers.Remove(context);
}
}
response.SetBody(
new SerializerBodyWriter(new PullResponse
{
Items = items,
EndOfSequence = pullResult.EndOfSequence ? new EndOfSequence() : null,
EnumerationContext = pullResult.EndOfSequence ? null : request.EnumerationContext
}));
return response;
}
示例3: Create
private OutgoingMessage Create(IncomingMessage createRequest)
{
Log.InfoFormat("Handling Create request");
var response = _factory.CreateCreateResponse();
var incomingHeaders = new IncomingHeaders(createRequest);
var outgoingHeaders = new OutgoingHeaders(response);
var reference = _handler.HandleCreate(incomingHeaders, outgoingHeaders, x => createRequest.GetPayload(x));
response.SetBody(new CreateResponseBodyWriter(reference));
Log.InfoFormat("Create request handled successfully");
return response;
}
示例4: Put
private OutgoingMessage Put(IncomingMessage putRequest)
{
Log.InfoFormat("Handling Put request");
var response = _factory.CreatePutResponse();
var incomingHeaders = new IncomingHeaders(putRequest);
var outgoingHeaders = new OutgoingHeaders(response);
var payload = _handler.HandlePut(incomingHeaders, outgoingHeaders, x => putRequest.GetPayload(x));
response.SetBody(new SerializerBodyWriter(payload));
Log.InfoFormat("Put request handled successfully");
return response;
}
示例5: IsInstanceOf
public OutgoingMessage IsInstanceOf(IncomingMessage requestMessage)
{
CheckResourceUri(requestMessage, Schema.DynamicMBeanResourceUri);
var request = requestMessage.GetPayload<IsInstanceOfMessage>();
var selectorSet = requestMessage.GetHeader<SelectorSetHeader>();
var objectName = selectorSet.ExtractObjectName();
//TODO: Java-to-Net class mapping (i.e. javax.management.NotificationBroadcaster)
var result = _server.IsInstanceOf(objectName, request.Value);
var response = new IsInstanceOfResponseMessage(result);
return new OutgoingMessage()
.AddHeader(new ActionHeader(Schema.InstanceOfResponseAction), true)
.SetBody(new SerializerBodyWriter(response));
}
示例6: Invoke
public OutgoingMessage Invoke(IncomingMessage requestMessage)
{
CheckResourceUri(requestMessage, Schema.DynamicMBeanResourceUri);
var request = requestMessage.GetPayload<InvokeMessage>();
var selectorSet = requestMessage.GetHeader<SelectorSetHeader>();
var objectName = selectorSet.ExtractObjectName();
var arguments = request.ManagedResourceOperation.Input.Select(x => x.Deserialize()).ToArray();
var result = _server.Invoke(objectName, request.ManagedResourceOperation.name, arguments);
var response = new InvokeResponseMessage(new GenericValueType(result));
return new OutgoingMessage()
.AddHeader(new ActionHeader(Schema.InvokeResponseAction), true)
.SetBody(new SerializerBodyWriter(response));
}
示例7: Enumerate
private OutgoingMessage Enumerate(IncomingMessage requestMessage)
{
var request = requestMessage.GetPayload<EnumerateRequest>();
var contextKey = EnumerationContextKey.Unique();
var filter = CreateFilterInstance(request.Filter);
var context = new EnumerationContext(contextKey.Text, filter);
if (IsCountRequest(requestMessage))
{
return HandleCountEnumerate(requestMessage, contextKey, request, context);
}
if (request.OptimizeEnumeration != null)
{
return HandleOptimizedEnumerate(requestMessage, contextKey, request, context);
}
return HandleNormalEnumerate(requestMessage, contextKey, request, context);
}
示例8: Renew
public OutgoingMessage Renew(IncomingMessage requestMessage)
{
var request = requestMessage.GetPayload<RenewRequest>();
var identifierHeader = requestMessage.GetHeader<IdentifierHeader>();
var existing = _activeSubscriptions.Get(identifierHeader.Identifier);
existing.Renew(CalculateExpiration(request.Expires));
var responseMessage = new OutgoingMessage()
.AddHeader(new ActionHeader(Constants.RenewResponseAction), false);
responseMessage.SetBody(new SerializerBodyWriter(
new RenewResponse
{
Expires = request.Expires
}));
return responseMessage;
}