|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel.Description;
using System.ServiceModel.Channels;
using System.ServiceModel.Dispatcher;
using System.ComponentModel;
namespace CachingExtension
{
public class CacheOperationBehavior : Attribute, IOperationBehavior
{
double _minutesToCache;
[Description("The number of minutes the response object will stay in the Cache")]
public double MinutesToCache
{
get { return this._minutesToCache; }
set { this._minutesToCache = value; }
}
//string _cacheName = string.Empty;
#region IOperationBehavior Members
public void AddBindingParameters(OperationDescription operationDescription,
BindingParameterCollection bindingParameters)
{
}
public void ApplyClientBehavior(OperationDescription operationDescription,
ClientOperation clientOperation)
{
}
public void ApplyDispatchBehavior(OperationDescription operationDescription,
DispatchOperation dispatchOperation)
{
// TracingLibrary.TraceEvents.AddEvent("Inside Apply Dispatch Behavior");
//Build the operation string using the namespace,
//service name and operation name
//ie: http://WCFService.com/myservice/myoperation
string operationFullName = operationDescription.DeclaringContract.Namespace +
"/" + operationDescription.DeclaringContract.Name + "/" +
operationDescription.Name;
// Replace the invoker with our own invoker
dispatchOperation.Invoker = new CachingOperationInvoker(dispatchOperation.Invoker, this._minutesToCache, operationFullName);
}
public void Validate(OperationDescription operationDescription)
{
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.