Guest User

www.whatibroke.com

a guest
Oct 22nd, 2014
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.01 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Net;
  6.  
  7. namespace System.ServiceModel.Web
  8. {
  9. #if NetFx
  10.     public interface IIncomingWebRequestContext
  11. #else
  12.     internal interface IIncomingWebRequestContext
  13. #endif
  14.     {
  15.         string Accept { get; }
  16.         long ContentLength { get; }
  17.         string ContentType { get; }
  18.         WebHeaderCollection Headers { get; }
  19.         string Method { get; }
  20.         UriTemplateMatch UriTemplateMatch { get; set; }
  21.         string UserAgent { get; }
  22.     }
  23.  
  24. #if NetFx
  25.     public class IncomingWebRequestContextWrapper : IIncomingWebRequestContext
  26. #else
  27.     internal class IncomingWebRequestContextWrapper : IIncomingWebRequestContext
  28. #endif
  29.     {
  30.         private IncomingWebRequestContext context;
  31.  
  32.         public IncomingWebRequestContextWrapper(IncomingWebRequestContext context)
  33.         {
  34.             this.context = context;
  35.         }
  36.  
  37.         #region IIncomingWebRequestContext Members
  38.  
  39.         public string Accept
  40.         {
  41.             get { return context.Accept; }
  42.         }
  43.  
  44.         public long ContentLength
  45.         {
  46.             get { return context.ContentLength; }
  47.         }
  48.  
  49.         public string ContentType
  50.         {
  51.             get { return context.ContentType; }
  52.         }
  53.  
  54.         public System.Net.WebHeaderCollection Headers
  55.         {
  56.             get { return context.Headers; }
  57.         }
  58.  
  59.         public string Method
  60.         {
  61.             get { return context.Method; }
  62.         }
  63.  
  64.         public UriTemplateMatch UriTemplateMatch
  65.         {
  66.             get
  67.             {
  68.                 return context.UriTemplateMatch;
  69.             }
  70.             set
  71.             {
  72.                 context.UriTemplateMatch = value;
  73.             }
  74.         }
  75.  
  76.         public string UserAgent
  77.         {
  78.             get { return context.UserAgent; }
  79.         }
  80.  
  81.         #endregion
  82.     }
  83.  
  84. #if NetFx
  85.     public interface IOutgoingWebResponseContext
  86. #else
  87.     internal interface IOutgoingWebResponseContext
  88. #endif
  89.     {
  90.         void SetStatusAsCreated(Uri locationUri);
  91.         void SetStatusAsNotFound();
  92.         void SetStatusAsNotFound(string description);
  93.  
  94.         long ContentLength { get; set; }
  95.         string ContentType { get; set; }
  96.         string ETag { get; set; }
  97.         WebHeaderCollection Headers { get; }
  98.         DateTime LastModified { get; set; }
  99.         string Location { get; set; }
  100.         HttpStatusCode StatusCode { get; set; }
  101.         string StatusDescription { get; set; }
  102.         bool SuppressEntityBody { get; set; }
  103.     }
  104.  
  105. #if NetFx
  106.     public interface IWebOperationContext
  107. #else
  108.     internal interface IWebOperationContext
  109. #endif
  110.     {
  111.         IIncomingWebRequestContext IncomingRequest { get; }
  112.         IOutgoingWebResponseContext OutgoingResponse { get; }
  113.     }
  114.  
  115. #if NetFx
  116.     public class OutgoingWebResponseContextWrapper : IOutgoingWebResponseContext
  117. #else
  118.     internal class OutgoingWebResponseContextWrapper : IOutgoingWebResponseContext
  119. #endif
  120.     {
  121.         private OutgoingWebResponseContext context;
  122.  
  123.         public OutgoingWebResponseContextWrapper(OutgoingWebResponseContext context)
  124.         {
  125.             this.context = context;
  126.         }
  127.  
  128.         #region IOutgoingWebResponseContext Members
  129.  
  130.         public void SetStatusAsCreated(Uri locationUri)
  131.         {
  132.             context.SetStatusAsCreated(locationUri);
  133.         }
  134.  
  135.         public void SetStatusAsNotFound()
  136.         {
  137.             context.SetStatusAsNotFound();
  138.         }
  139.  
  140.         public void SetStatusAsNotFound(string description)
  141.         {
  142.             context.SetStatusAsNotFound(description);
  143.         }
  144.  
  145.         public long ContentLength
  146.         {
  147.             get
  148.             {
  149.                 return context.ContentLength;
  150.             }
  151.             set
  152.             {
  153.                 context.ContentLength = value;
  154.             }
  155.         }
  156.  
  157.         public string ContentType
  158.         {
  159.             get
  160.             {
  161.                 return context.ContentType;
  162.             }
  163.             set
  164.             {
  165.                 context.ContentType = value;
  166.             }
  167.         }
  168.  
  169.         public string ETag
  170.         {
  171.             get
  172.             {
  173.                 return context.ETag;
  174.             }
  175.             set
  176.             {
  177.                 context.ETag = value;
  178.             }
  179.         }
  180.  
  181.         public System.Net.WebHeaderCollection Headers
  182.         {
  183.             get { return context.Headers; }
  184.         }
  185.  
  186.         public DateTime LastModified
  187.         {
  188.             get
  189.             {
  190.                 return context.LastModified;
  191.             }
  192.             set
  193.             {
  194.                 context.LastModified = value;
  195.             }
  196.         }
  197.  
  198.         public string Location
  199.         {
  200.             get
  201.             {
  202.                 return context.Location;
  203.             }
  204.             set
  205.             {
  206.                 context.Location = value;
  207.             }
  208.         }
  209.  
  210.         public System.Net.HttpStatusCode StatusCode
  211.         {
  212.             get
  213.             {
  214.                 return context.StatusCode;
  215.             }
  216.             set
  217.             {
  218.                 context.StatusCode = value;
  219.             }
  220.         }
  221.  
  222.         public string StatusDescription
  223.         {
  224.             get
  225.             {
  226.                 return context.StatusDescription;
  227.             }
  228.             set
  229.             {
  230.                 context.StatusDescription = value;
  231.             }
  232.         }
  233.  
  234.         public bool SuppressEntityBody
  235.         {
  236.             get
  237.             {
  238.                 return context.SuppressEntityBody;
  239.             }
  240.             set
  241.             {
  242.                 context.SuppressEntityBody = value;
  243.             }
  244.         }
  245.  
  246.         #endregion
  247.     }
  248.  
  249. #if NetFx
  250.     public class WebOperationContextWrapper : IWebOperationContext
  251. #else
  252.     internal class WebOperationContextWrapper : IWebOperationContext
  253. #endif
  254.     {
  255.         private WebOperationContext context;
  256.  
  257.         public WebOperationContextWrapper(WebOperationContext context)
  258.         {
  259.             this.context = context;
  260.         }
  261.  
  262.         #region IWebOperationContext Members
  263.  
  264.         public IIncomingWebRequestContext IncomingRequest
  265.         {
  266.             get { return new IncomingWebRequestContextWrapper(context.IncomingRequest); }
  267.         }
  268.  
  269.         public IOutgoingWebResponseContext OutgoingResponse
  270.         {
  271.             get { return new OutgoingWebResponseContextWrapper(context.OutgoingResponse); }
  272.         }
  273.  
  274.         #endregion
  275.     }
  276. }
Add Comment
Please, Sign In to add comment