The Labs \ Source Viewer \ SSCLI \ System.Runtime.Remoting.Services \ RemotingClientProxy

  1. // ==++==
  2. //
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. //
  14. // ==--==
  15. namespace System.Runtime.Remoting.Services
  16. {
  17.     using System;
  18.     using System.Collections;
  19.     using System.ComponentModel;
  20.     using System.IO;
  21.     using System.Reflection;
  22.     using System.Net;
  23.     using System.Runtime.Remoting;
  24.     using System.Runtime.Remoting.Channels;
  25.     using System.Runtime.Remoting.Channels.Http;
  26.     using System.Runtime.Remoting.Messaging;
  27.     using System.Runtime.InteropServices;
  28.    
  29.     [ComVisible(true)]
  30.     public abstract class RemotingClientProxy : Component
  31.     {
  32.         protected Type _type;
  33.         protected object _tp;
  34.         protected string _url;
  35.        
  36.         protected void ConfigureProxy(Type type, string url)
  37.         {
  38.             lock (this) {
  39.                 // Initial URL Address embedded during codegen i.e. SUDSGenerator
  40.                 // User use in stockQuote.Url = "http://............." which reconnects the tp
  41.                 _type = type;
  42.                 this.Url = url;
  43.             }
  44.         }
  45.        
  46.         protected void ConnectProxy()
  47.         {
  48.             lock (this) {
  49.                 _tp = null;
  50.                 _tp = Activator.GetObject(_type, _url);
  51.             }
  52.         }
  53.        
  54.         //[DefaultValue(false), Description("Enable automatic handling of server redirects.")]
  55.         public bool AllowAutoRedirect {
  56.             get { return (bool)ChannelServices.GetChannelSinkProperties(_tp)["allowautoredirect"]; }
  57.             set { ChannelServices.GetChannelSinkProperties(_tp)["allowautoredirect"] = value; }
  58.         }
  59.        
  60.         //[Browsable(false), Persistable(PersistableSupport.None), Description("The cookies received from the server that will be sent back on requests that match the cookie's path. EnableCookies must be true.")]
  61.         //public CookieCollection Cookies
  62.         public object Cookies {
  63.             get { return null; }
  64.         }
  65.        
  66.         //[DefaultValue(true), Description("Enables handling of cookies received from the server.")]
  67.         public bool EnableCookies {
  68.             get { return false; }
  69.             set {
  70.                 throw new NotSupportedException();
  71.             }
  72.         }
  73.        
  74.         //[DefaultValue(false), Description("Enables pre authentication of the request.")]
  75.         public bool PreAuthenticate {
  76.             get { return (bool)ChannelServices.GetChannelSinkProperties(_tp)["preauthenticate"]; }
  77.             set { ChannelServices.GetChannelSinkProperties(_tp)["preauthenticate"] = value; }
  78.         }
  79.        
  80.         //[DefaultValue(""), RecommendedAsConfigurable(true), Description("The base URL to the server to use for requests.")]
  81.         public string Path {
  82.             get { return Url; }
  83.             set { Url = value; }
  84.         }
  85.        
  86.         //[DefaultValue(-1), RecommendedAsConfigurable(true), Description("Sets the timeout in milliseconds to be used for synchronous calls. The default of -1 means infinite.")]
  87.         public int Timeout {
  88.             get { return (int)ChannelServices.GetChannelSinkProperties(_tp)["timeout"]; }
  89.             set { ChannelServices.GetChannelSinkProperties(_tp)["timeout"] = value; }
  90.         }
  91.        
  92.         //
  93.         //
  94.         public string Url {
  95. //return (String)ChannelServices.GetChannelSinkProperties(_tp)["Url"];
  96.             get { return _url; }
  97.             set {
  98.                 lock (this) {
  99.                     _url = value;
  100.                 }
  101.                 ConnectProxy();
  102.                 ChannelServices.GetChannelSinkProperties(_tp)["url"] = value;
  103.             }
  104.         }
  105.        
  106.         //[Description("Sets the user agent http header for the request.")]
  107.         public string UserAgent {
  108.             get { return HttpClientTransportSink.UserAgent; }
  109.             set {
  110.                 throw new NotSupportedException();
  111.             }
  112.         }
  113.        
  114.         //[DefaultValue(""), Description("The user name to be sent for basic and digest authentication.")]
  115.         public string Username {
  116.             get { return (string)ChannelServices.GetChannelSinkProperties(_tp)["username"]; }
  117.             set { ChannelServices.GetChannelSinkProperties(_tp)["username"] = value; }
  118.         }
  119.        
  120.         //[DefaultValue(""), Description("The password to be used for basic and digest authentication.")]
  121.         public string Password {
  122.             get { return (string)ChannelServices.GetChannelSinkProperties(_tp)["password"]; }
  123.             set { ChannelServices.GetChannelSinkProperties(_tp)["password"] = value; }
  124.         }
  125.        
  126.         //[DefaultValue(""), Description("The domain to be used for basic and digest authentication.")]
  127.         public string Domain {
  128.             get { return (string)ChannelServices.GetChannelSinkProperties(_tp)["domain"]; }
  129.             set { ChannelServices.GetChannelSinkProperties(_tp)["domain"] = value; }
  130.         }
  131.        
  132.         //[DefaultValue(""), Description("The name of the proxy server to use for requests.")]
  133.         public string ProxyName {
  134.             get { return (string)ChannelServices.GetChannelSinkProperties(_tp)["proxyname"]; }
  135.             set { ChannelServices.GetChannelSinkProperties(_tp)["Proxyname"] = value; }
  136.         }
  137.        
  138.         //[DefaultValue(80), Description("The port number of the proxy server to use for requests.")]
  139.         public int ProxyPort {
  140.             get { return (int)ChannelServices.GetChannelSinkProperties(_tp)["proxyport"]; }
  141.             set { ChannelServices.GetChannelSinkProperties(_tp)["proxyport"] = value; }
  142.         }
  143.     }
  144. }

Developer Fusion