ProtoBehaviorAttribute.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. #if FEAT_SERVICEMODEL && PLAT_XMLSERIALIZER
  2. using System;
  3. using System.ServiceModel.Description;
  4. using System.ServiceModel.Dispatcher;
  5. namespace ProtoBuf.ServiceModel
  6. {
  7. /// <summary>
  8. /// Uses protocol buffer serialization on the specified operation; note that this
  9. /// must be enabled on both the client and server.
  10. /// </summary>
  11. [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
  12. public sealed class ProtoBehaviorAttribute : Attribute, IOperationBehavior
  13. {
  14. void IOperationBehavior.AddBindingParameters(OperationDescription operationDescription, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
  15. { }
  16. void IOperationBehavior.ApplyClientBehavior(OperationDescription operationDescription, ClientOperation clientOperation)
  17. {
  18. IOperationBehavior innerBehavior = new ProtoOperationBehavior(operationDescription);
  19. innerBehavior.ApplyClientBehavior(operationDescription, clientOperation);
  20. }
  21. void IOperationBehavior.ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
  22. {
  23. IOperationBehavior innerBehavior = new ProtoOperationBehavior(operationDescription);
  24. innerBehavior.ApplyDispatchBehavior(operationDescription, dispatchOperation);
  25. }
  26. void IOperationBehavior.Validate(OperationDescription operationDescription)
  27. { }
  28. }
  29. }
  30. #endif