• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Proxy类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Proxy的典型用法代码示例。如果您正苦于以下问题:C# Proxy类的具体用法?C# Proxy怎么用?C# Proxy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Proxy类属于命名空间,在下文中一共展示了Proxy类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Log

        public void Log(Packet packet, Proxy proxy)
        {
            if (packet.PacketContext == PacketContext.ServerToClient && !settings.LogServer)
                return;
            if (packet.PacketContext == PacketContext.ClientToServer && !settings.LogClient)
                return;
            if (settings.FilterPackets != null)
            {
                if (!settings.FilterPackets.Contains(packet.PacketId))
                    return;
            }
            if (settings.UnloggedPackets != null)
            {
                if (settings.FilterPackets.Contains(packet.PacketId))
                    return;
            }

            StringBuilder sb = new StringBuilder();
            if (packet.PacketContext == PacketContext.ClientToServer)
                sb.Append("{" + DateTime.Now.ToLongTimeString() + "} [CLIENT " + proxy.RemoteSocket.LocalEndPoint + "->SERVER]: ");
            else
                sb.Append("{" + DateTime.Now.ToLongTimeString() + "} [SERVER->CLIENT " + proxy.LocalSocket.RemoteEndPoint + "]: ");

            sb.Append(Packet.AddSpaces(packet.GetType().Name.Replace("Packet", "")));
            sb.AppendFormat(" (0x{0})", packet.PacketId.ToString("X2"));
            sb.AppendLine();
            sb.Append(DataUtility.DumpArrayPretty(packet.Payload));
            sb.AppendLine(packet.ToString(proxy));

            stream.Write(sb + Environment.NewLine);
        }
开发者ID:ammaraskar,项目名称:SMProxy,代码行数:31,代码来源:FileLogProvider.cs


示例2: Main

  public static void Main( string[] args )
  {
    // Create proxy and request a service
    Proxy p = new Proxy();
    p.Request();

  }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:7,代码来源:Proxy_Structure.cs


示例3: AddProxyResult

 public unsafe void AddProxyResult(ushort proxyId, Proxy proxy, int maxCount, SortKeyFunc sortKey)
 {
     float num = sortKey(proxy.UserData);
     if (num >= 0f)
     {
         fixed (float* ptr = this._querySortKeys)
         {
             float* ptr2 = ptr;
             while (*ptr2 < num && ptr2 < ptr + this._queryResultCount)
             {
                 ptr2 += 4 / 4;
             }
             //int num2 = ((int)ptr2 - ((int)ptr) / 4) / 4;
             int num2 = (int)((ulong)ptr2 - (ulong)ptr) / 4; // STEVE
             if (maxCount != this._queryResultCount || num2 != this._queryResultCount)
             {
                 if (maxCount == this._queryResultCount)
                 {
                     this._queryResultCount--;
                 }
                 for (int i = this._queryResultCount + 1; i > num2; i--)
                 {
                     this._querySortKeys[i] = this._querySortKeys[i - 1];
                     this._queryResults[i] = this._queryResults[i - 1];
                 }
                 this._querySortKeys[num2] = num;
                 this._queryResults[num2] = proxyId;
                 this._queryResultCount++;
                 //ptr = null;
             }
         }
     }
 }
开发者ID:litdev1,项目名称:LitDev,代码行数:33,代码来源:BroadPhase.cs


示例4: Main

    public static void Main(string[] args)
    {
        libslAssembly = Assembly.Load("libsecondlife");
        if (libslAssembly == null) throw new Exception("Assembly load exception");

        ProxyConfig proxyConfig = new ProxyConfig("Analyst V2", "Austin Jennings / Andrew Ortman", args);
        proxy = new Proxy(proxyConfig);

        // build the table of /command delegates
        InitializeCommandDelegates();

        // add delegates for login
        proxy.SetLoginRequestDelegate(new XmlRpcRequestDelegate(LoginRequest));
        proxy.SetLoginResponseDelegate(new XmlRpcResponseDelegate(LoginResponse));

        // add a delegate for outgoing chat
        proxy.AddDelegate(PacketType.ChatFromViewer, Direction.Outgoing, new PacketDelegate(ChatFromViewerOut));

        //  handle command line arguments
        foreach (string arg in args)
            if (arg == "--log-all")
                LogAll();
            else if (arg == "--log-login")
                logLogin = true;

        // start the proxy
        proxy.Start();
    }
开发者ID:BackupTheBerlios,项目名称:libsecondlife-svn,代码行数:28,代码来源:Analyst.cs


示例5: PostAction

        private static bool PostAction(Proxy p, Server server, Action action)
        {
            var instance = p.Instance;
            // if we can't issue any commands, bomb out
            if (instance.AdminUser.IsNullOrEmpty() || instance.AdminPassword.IsNullOrEmpty()) return false;

            var loginInfo = $"{instance.AdminUser}:{instance.AdminPassword}";
            var haproxyUri = new Uri(instance.Url);
            var requestBody = $"s={server.Name}&action={action.ToString().ToLower()}&b={p.Name}";
            var requestHeader = $"POST {haproxyUri.AbsolutePath} HTTP/1.1\r\nHost: {haproxyUri.Host}\r\nContent-Length: {Encoding.GetEncoding("ISO-8859-1").GetBytes(requestBody).Length}\r\nAuthorization: Basic {Convert.ToBase64String(Encoding.Default.GetBytes(loginInfo))}\r\n\r\n";

            try
            {
                var socket = new System.Net.Sockets.Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                socket.Connect(haproxyUri.Host, haproxyUri.Port);
                socket.Send(Encoding.UTF8.GetBytes(requestHeader + requestBody));

                var responseBytes = new byte[socket.ReceiveBufferSize];
                socket.Receive(responseBytes);

                var response = Encoding.UTF8.GetString(responseBytes);
                instance.PurgeCache();
                return response.StartsWith("HTTP/1.0 303") || response.StartsWith("HTTP/1.1 303");
            }
            catch (Exception e)
            {
                Current.LogException(e);
                return false;
            }
        }
开发者ID:riiiqpl,项目名称:Opserver,代码行数:30,代码来源:HAProxyAdmin.cs


示例6: Main

        static void Main(string[] args)
        {
            Proxy proxy = new Proxy();
            proxy.Request();

            Console.Read();
        }
开发者ID:niuniuliu,项目名称:CSharp,代码行数:7,代码来源:Program.cs


示例7: ValidationPassedWhenProjectDiffersButNameIsSame

		public void ValidationPassedWhenProjectDiffersButNameIsSame()
		{
			Store store = new Store(typeof(CoreDesignSurfaceDomainModel), typeof(HostDesignerDomainModel));
			using (Transaction t = store.TransactionManager.BeginTransaction())
			{
				ClientApplication clientApp1 = new ClientApplication(store,
									new PropertyAssignment(ClientApplication.ImplementationProjectDomainPropertyId, "Project1"));
				ClientApplication clientApp2 = new ClientApplication(store,
					new PropertyAssignment(ClientApplication.ImplementationProjectDomainPropertyId, "AnotherProject"));

				HostDesignerModel model = new HostDesignerModel(store);

				model.ClientApplications.Add(clientApp1);
				model.ClientApplications.Add(clientApp2);

				Proxy proxy1 = new Proxy(store,
					new PropertyAssignment(Proxy.NameDomainPropertyId, "Proxy1"));
				Proxy proxy2 = new Proxy(store,
					new PropertyAssignment(Proxy.NameDomainPropertyId, "Proxy1"));


				clientApp1.Proxies.Add(proxy1);
				clientApp2.Proxies.Add(proxy2);

				TestableHostModelContainsUniqueProxyNamesAcrossClientsValidator validator = new TestableHostModelContainsUniqueProxyNamesAcrossClientsValidator();


				t.Rollback();
			}
		}
开发者ID:Phidiax,项目名称:open-wssf-2015,代码行数:30,代码来源:HostModelContainsUniqueProxyNamesAcrossClientsValidatorFixture.cs


示例8: Run

 public void Run()
 {
     Subject subject = new Proxy("SubjectName");
     var subjectName = subject.Name;
     subject.Request();
     subject.Request();
 }
开发者ID:rosslight,项目名称:csharpBase,代码行数:7,代码来源:ProxyA.cs


示例9: TestProxySendAndReceive

        public void TestProxySendAndReceive()
        {
            using (var ctx = NetMQContext.Create())
            using (var front = ctx.CreateRouterSocket())
            using (var back = ctx.CreateDealerSocket())
            {
                front.Bind("inproc://frontend");
                back.Bind("inproc://backend");

                var proxy = new Proxy(front, back, null);
                Task.Factory.StartNew(proxy.Start);

                using (var client = ctx.CreateRequestSocket())
                using (var server = ctx.CreateResponseSocket())
                {
                    client.Connect("inproc://frontend");
                    server.Connect("inproc://backend");

                    client.Send("hello");
                    Assert.AreEqual("hello", server.ReceiveString());
                    server.Send("reply");
                    Assert.AreEqual("reply", client.ReceiveString());
                }
            }
        }
开发者ID:jasenkin,项目名称:netmq,代码行数:25,代码来源:ProxyTests.cs


示例10: SendFile

        // transfers the file to the server in blocks of bytes.
        public bool SendFile(string file, string path)
        {
            long blockSize = 512;
            Proxy proxy = new Proxy();

            try
            {
                string filename = Path.GetFileName(file);
                proxy.GetChannel().OpenFileForWrite(filename, path);
                FileStream fs = File.Open(file, FileMode.Open, FileAccess.Read);
                int bytesRead = 0;
                while (true)
                {
                    long remainder = (int)(fs.Length - fs.Position);
                    if (remainder == 0)
                        break;
                    long size = Math.Min(blockSize, remainder);
                    byte[] block = new byte[size];
                    bytesRead = fs.Read(block, 0, block.Length);
                    proxy.channel.WriteFileBlock(block);
                }
                fs.Close();
                proxy.GetChannel().CloseFile();
                return true;
            }
            catch (Exception ex)
            {
                Console.Write("\n  can't open {0} for writing - {1}", file, ex.Message);
                return false;
            }
        }
开发者ID:himanshugpt,项目名称:TestHarness,代码行数:32,代码来源:Proxy.cs


示例11: Client

 /// <summary>
 /// Parametrized cofigurator constructor
 /// </summary>
 /// <param name="domainSetup">domain setups</param>
 public Client(AppDomainSetup domainSetup)
 {
     if (domainSetup == null)
         throw new ArgumentNullException();
     Configurate(domainSetup);
     Proxy = new Proxy(Services.Count, Services);
 }
开发者ID:RomanMakarov1002,项目名称:EPAM.RD.2016S.Makarau,代码行数:11,代码来源:Client.cs


示例12: ImportFile

 // construct the file
 internal ImportFile(BulkImportViewModel model, int fileId, string name, string title, string description)
 {
     _Model = model;
     _Proxy = _Model._Proxy;
     _MaxPreview = _Model.MaxPreview;
     _Description = string.IsNullOrWhiteSpace(description) ? string.Empty : description;
     if (!string.IsNullOrEmpty(_Description))
     {
         if (_Description.Contains("{70}"))
         {
             _PreviousStatus = JobStatus.AllDone;
             _Description = _Description.Replace("{70}", "");
         }
         if (_Description.Contains("{75}"))
         {
             _PreviousStatus = JobStatus.AllDoneError;
             _Description = _Description.Replace("{75}", "");
         }
     }
     _Name = name;
     Title = title;
     _TitleUpper = Title.ToUpperInvariant();
     _FileId = fileId;
     _ProgressPercent = 0;
     _IsShowAllEnabled = false;
     _ShowAll = false;
     _RepairOrders = new ObservableCollection<RepairOrder>();
     _LoadedAll = false;
     _JobStatus = JobStatus.Load;
     _IsImportEnabled = false;
     _Status = String.Empty + _JobStatus;
     _LongStatus = _Status;
     _Stopwatch = new Stopwatch();
     _ProgressTimer = new Stopwatch();
 }
开发者ID:glitch11,项目名称:Accelerators,代码行数:36,代码来源:ImportFile.cs


示例13: CheckIdentity

 public bool CheckIdentity(Proxy proxy, Message message)
 {
     EndpointAddress to = proxy.To;
     bool access = this.identityVerifier.CheckAccess(to, message);
     this.TraceCheckIdentityResult(access, to, message);
     return access;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:CoordinationServiceSecurity.cs


示例14: Start

        public void Start()
        {

            var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
            path = path.Replace("file:\\", "");
            if (!path.EndsWith(@"\")) path += @"\";
            path += "FiddlerRoot.cer";

 
            FiddlerApplication.oDefaultClientCertificate = new X509Certificate(path);
            FiddlerApplication.BeforeRequest += ProcessBeginRequest;

            FiddlerApplication.AfterSessionComplete += ProcessEndResponse;
            CONFIG.IgnoreServerCertErrors = true;
            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.ForgetStreamedData", false);
            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);



            _oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(_sslPort, true, _hostName);
            if (null == _oSecureEndpoint)
            {

                throw new Exception("could not start up secure endpoint");
            }
            FiddlerApplication.Startup(_port, false, true, true);
        }
开发者ID:Domer79,项目名称:CIAPI.CS,代码行数:27,代码来源:Server.cs


示例15: start

        private static void start()
        {
            isActicvated = true;
            List<Fiddler.Session> oAllSessions = new List<Fiddler.Session>();
            List<String> list = new List<string>();

            Fiddler.FiddlerApplication.BeforeResponse += delegate(Fiddler.Session oSession)
            {
                Messages.write(oSession.fullUrl);
            };

            Fiddler.CONFIG.IgnoreServerCertErrors = false;

            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);

            FiddlerCoreStartupFlags oFCSF = FiddlerCoreStartupFlags.Default;
            //Do no decrypt SSL traffic
            oFCSF = (oFCSF & ~FiddlerCoreStartupFlags.DecryptSSL);
            //Do not act like system proxy
            //oFCSF = (oFCSF & ~FiddlerCoreStartupFlags.RegisterAsSystemProxy);

            //Fiddler will auto select available port.
            Fiddler.FiddlerApplication.Startup(0, oFCSF);

            // We'll also create a HTTPS listener, useful for when FiddlerCore is masquerading as a HTTPS server
            // instead of acting as a normal CERN-style proxy server.
            oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(iSecureEndpointPort, true, sSecureEndpointHostname);
            if (null != oSecureEndpoint)
            {
                FiddlerApplication.Log.LogFormat("Created secure end point listening on port {0}, using a HTTPS certificate for '{1}'", iSecureEndpointPort, sSecureEndpointHostname);
            }

            while (isActicvated) ;
            DoQuit();
        }
开发者ID:eranno,项目名称:My-Screen,代码行数:35,代码来源:TrafficHandler.cs


示例16: GenProxyServerStringByProtocol

        /// <summary>
        /// 
        /// </summary>
        /// <param name="proxy"></param>
        /// <returns></returns>
        public static string GenProxyServerStringByProtocol(Proxy proxy)
        {
            string proxyServer = "";

            string http  = proxy.Http;
            string https = proxy.Https;
            string ftp   = proxy.Ftp;
            string socks = proxy.Socks;

            if (http != null && http.Length > 0)
            {
                proxyServer = AddProxyServers(proxyServer, "http", http);
            }
            if (https != null && https.Length > 0)
            {
                proxyServer = AddProxyServers(proxyServer, "https", https);
            }
            if (ftp != null && ftp.Length > 0)
            {
                proxyServer = AddProxyServers(proxyServer, "ftp", ftp);
            }
            if (socks != null && socks.Length > 0)
            {
                proxyServer = AddProxyServers(proxyServer, "socks", socks);
            }

            return proxyServer;
        }
开发者ID:xunyss,项目名称:QuickExchanger,代码行数:33,代码来源:InternetSetting.cs


示例17: ToString

        /// <summary>
        /// Converts the packet to a human-readable format.
        /// </summary>
        public string ToString(Proxy proxy)
        {
            Type type = GetType();
            string value = "";
            FieldInfo[] fields = type.GetFields();
            foreach (FieldInfo field in fields)
            {
                var nameAttribute = Attribute.GetCustomAttribute(field, typeof(FriendlyNameAttribute)) as FriendlyNameAttribute;
                var name = field.Name;

                if (nameAttribute != null)
                    name = nameAttribute.FriendlyName;
                else
                    name = AddSpaces(name);

                value += "    " + name + " (" + field.FieldType.Name + ")";

                var fValue = field.GetValue(this);
                string fieldValue = fValue.ToString();
                if (fValue is byte[])
                    fieldValue = DataUtility.DumpArray(fValue as byte[]);
                value += ": " + fieldValue + "\n";
            }
            if (value.Length == 0)
                return value;
            return value.Remove(value.Length - 1);
        }
开发者ID:ammaraskar,项目名称:SMProxy,代码行数:30,代码来源:Packet.cs


示例18: Main

        static void Main(string[] args)
        {
            var proxy = new Proxy();

            Console.WriteLine(proxy.Add(1, 2));
            Console.WriteLine(proxy.Sub(5, 2));
        }
开发者ID:joenjuki,项目名称:design-patterns,代码行数:7,代码来源:Program.cs


示例19: Main

        static void Main(string[] args)
        {
            Subject subject = new Proxy();
            subject.Request();

            Console.ReadKey();
        }
开发者ID:VladimirTsy,项目名称:Party,代码行数:7,代码来源:Program.cs


示例20: InitializeControl

 // initialize control
 private void InitializeControl(Proxy proxy)
 {
     _Model = new OrderManagementViewModel(proxy, this);
     _PreviousFile = _Model._DefaultFile;
     this.Loaded += MainWindow_Loaded;
     webBrowser1.Loaded += webBrowser1_Loaded;
 }
开发者ID:oo00spy00oo,项目名称:Accelerators,代码行数:8,代码来源:OrderManagementControl.xaml.cs



注:本文中的Proxy类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ProxyCtor类代码示例发布时间:2022-05-24
下一篇:
C# Province类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap