RemotingClientProxy

来源:互联网 发布:数据库存中文乱码 编辑:程序博客网 时间:2024/06/06 07:41
 
  1. // ==++==
  2. // 
  3. //   
  4. //    Copyright (c) 2002 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.     /// <include file='doc/RemotingClientProxy.uex' path='docs/doc[@for="RemotingClientProxy"]/*' />
  28.     public abstract class RemotingClientProxy : Component
  29.     {
  30.         /// <include file='doc/RemotingClientProxy.uex' path='docs/doc[@for="RemotingClientProxy._type"]/*' />
  31.         protected Type _type;
  32.         /// <include file='doc/RemotingClientProxy.uex' path='docs/doc[@for="RemotingClientProxy._tp"]/*' />
  33.         protected Object _tp;
  34.         /// <include file='doc/RemotingClientProxy.uex' path='docs/doc[@for="RemotingClientProxy._url"]/*' />
  35.         protected String _url;
  36.         /// <include file='doc/RemotingClientProxy.uex' path='docs/doc[@for="RemotingClientProxy.ConfigureProxy"]/*' />
  37.         protected void ConfigureProxy(Type type, String url)
  38.         {
  39.             lock(this)
  40.             {               
  41.                 // Initial URL Address embedded during codegen i.e. SUDSGenerator
  42.                 // User use in stockQuote.Url = "http://............." which reconnects the tp
  43.                 _type = type;
  44.                 this.Url = url;
  45.             }
  46.         }
  47.         /// <include file='doc/RemotingClientProxy.uex' path='docs/doc[@for="RemotingClientProxy.ConnectProxy"]/*' />
  48.         protected void ConnectProxy()
  49.         {
  50.             lock(this)
  51.             {
  52.                 _tp = null;
  53.                 _tp = Activator.GetObject(_type, _url);
  54.             }
  55.         }
  56.         //[DefaultValue(false), Description("Enable automatic handling of server redirects.")]
  57.         /// <include file='doc/RemotingClientProxy.uex' path='docs/doc[@for="RemotingClientProxy.AllowAutoRedirect"]/*' />
  58.         public bool AllowAutoRedirect
  59.         {
  60.             get { return(bool)ChannelServices.GetChannelSinkProperties(_tp)["AllowAutoRedirect"];}
  61.             set { ChannelServices.GetChannelSinkProperties(_tp)["AllowAutoRedirect"] = value;}
  62.         }
  63.         //[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.")]
  64.         //public CookieCollection Cookies
  65.         /// <include file='doc/RemotingClientProxy.uex' path='docs/doc[@for="RemotingClientProxy.Cookies"]/*' />
  66.         public Object Cookies
  67.         {
  68.             get { return null; }
  69.         }
  70.         //[DefaultValue(true), Description("Enables handling of cookies received from the server.")]
  71.         /// <include file='doc/RemotingClientProxy.uex' path='docs/doc[@for="RemotingClientProxy.EnableCookies"]/*' />
  72.         public bool EnableCookies
  73.         {
  74.             get { return false; }
  75.             set { throw new NotSupportedException(); }
  76.         }
  77.         //[DefaultValue(false), Description("Enables pre authentication of the request.")]
  78.         /// <include file='doc/RemotingClientProxy.uex' path='docs/doc[@for="RemotingClientProxy.PreAuthenticate"]/*' />
  79.         public bool PreAuthenticate
  80.         {
  81.             get { return(bool)ChannelServices.GetChannelSinkProperties(_tp)["PreAuthenticate"];}
  82.             set { ChannelServices.GetChannelSinkProperties(_tp)["PreAuthenticate"] = value;}
  83.         }
  84.         //[DefaultValue(""), RecommendedAsConfigurable(true), Description("The base URL to the server to use for requests.")]
  85.         /// <include file='doc/RemotingClientProxy.uex' path='docs/doc[@for="RemotingClientProxy.Path"]/*' />
  86.         public String Path
  87.         {
  88.             get { return Url; }
  89.             set { Url = value; }
  90.         }
  91.         //[DefaultValue(-1), RecommendedAsConfigurable(true), Description("Sets the timeout in milliseconds to be used for synchronous calls.  The default of -1 means infinite.")]
  92.         /// <include file='doc/RemotingClientProxy.uex' path='docs/doc[@for="RemotingClientProxy.Timeout"]/*' />
  93.         public int Timeout
  94.         {
  95.             get { return (int)ChannelServices.GetChannelSinkProperties(_tp)["Timeout"];}
  96.             set { ChannelServices.GetChannelSinkProperties(_tp)["Timeout"] = value;}
  97.         }
  98. //
  99. //                                                     
  100. //
  101.         /// <include file='doc/RemotingClientProxy.uex' path='docs/doc[@for="RemotingClientProxy.Url"]/*' />
  102.         public String Url
  103.         {
  104.             get
  105.             {
  106.                 //return (String)ChannelServices.GetChannelSinkProperties(_tp)["Url"];
  107.                 return _url;
  108.             }
  109.             set
  110.             {
  111.                 lock(this)
  112.                 {
  113.                     _url = value;
  114.                 }
  115.                 ConnectProxy();
  116.                 ChannelServices.GetChannelSinkProperties(_tp)["Url"] = value;
  117.             }
  118.         }
  119.         //[Description("Sets the user agent http header for the request.")]
  120.         /// <include file='doc/RemotingClientProxy.uex' path='docs/doc[@for="RemotingClientProxy.UserAgent"]/*' />
  121.         public String UserAgent
  122.         {
  123.             get { return HttpClientTransportSink.UserAgent;}
  124.             set { throw  new NotSupportedException(); }
  125.         }
  126.         //[DefaultValue(""), Description("The user name to be sent for basic and digest authentication.")]
  127.         /// <include file='doc/RemotingClientProxy.uex' path='docs/doc[@for="RemotingClientProxy.Username"]/*' />
  128.         public String Username
  129.         {
  130.             get { return(String)ChannelServices.GetChannelSinkProperties(_tp)["UserName"];}
  131.             set { ChannelServices.GetChannelSinkProperties(_tp)["UserName"] = value;}
  132.         }
  133.         //[DefaultValue(""), Description("The password to be used for basic and digest authentication.")]
  134.         /// <include file='doc/RemotingClientProxy.uex' path='docs/doc[@for="RemotingClientProxy.Password"]/*' />
  135.         public String Password
  136.         {
  137.             get { return(String)ChannelServices.GetChannelSinkProperties(_tp)["Password"];}
  138.             set { ChannelServices.GetChannelSinkProperties(_tp)["Password"] = value;}
  139.         }
  140.         //[DefaultValue(""), Description("The domain to be used for basic and digest authentication.")]
  141.         /// <include file='doc/RemotingClientProxy.uex' path='docs/doc[@for="RemotingClientProxy.Domain"]/*' />
  142.         public String Domain
  143.         {
  144.             get { return(String)ChannelServices.GetChannelSinkProperties(_tp)["Domain"];}
  145.             set { ChannelServices.GetChannelSinkProperties(_tp)["Domain"] = value;}
  146.         }
  147.         //[DefaultValue(""), Description("The name of the proxy server to use for requests.")]
  148.         /// <include file='doc/RemotingClientProxy.uex' path='docs/doc[@for="RemotingClientProxy.ProxyName"]/*' />
  149.         public String ProxyName
  150.         {
  151.             get { return(String)ChannelServices.GetChannelSinkProperties(_tp)["ProxyName"];}
  152.             set { ChannelServices.GetChannelSinkProperties(_tp)["ProxyName"] = value;}
  153.         }
  154.         //[DefaultValue(80), Description("The port number of the proxy server to use for requests.")]
  155.         /// <include file='doc/RemotingClientProxy.uex' path='docs/doc[@for="RemotingClientProxy.ProxyPort"]/*' />
  156.         public int ProxyPort {
  157.             get { return(int)ChannelServices.GetChannelSinkProperties(_tp)["ProxyPort"];}
  158.             set { ChannelServices.GetChannelSinkProperties(_tp)["ProxyPort"] = value;}
  159.         }
  160.     }
  161. }
原创粉丝点击