sexta-feira, 17 de julho de 2015

Android Player - Xamarin Proxy



1) Create your own Assembly Proxy
===========================================

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Configuration;

namespace ProxyUtil
{
    public class MyProxy : IWebProxy
    {
      public ICredentials Credentials
      {
        get
        {
          return new NetworkCredential(ConfigurationManager.AppSettings["NetworkUserName"],
            ConfigurationManager.AppSettings["NetworkUserPass"]);
        }
        set { }
      }

      public Uri GetProxy(Uri destination)
      {
        return new Uri(ConfigurationManager.AppSettings["HttpProxyPort"]);
      }

      public bool IsBypassed(Uri host)
      {
        return false;
      }

    }
}

Copy the Assembly to Directory
 C:\Program Files\Xamarin Android Player\


2) Setup the Variables on the file DeviceManager.exe.config and the AndroidPlayer.exe.config
===========================================================================================

The context bellow must be on DeviceManager.exe.config and 
AndroidPlayer.exe.config


xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="HttpProxyPort" value="http://YOURPROXY:PORT"/>
    <add key="NetworkUserName" value="USERNAME"/>
    <add key="NetworkUserPass" value="PASSWORD"/>
  </appSettings>
  <system.net>
    <defaultProxy enabled="true" useDefaultCredentials="false">
      <module type="ProxyUtil.MyProxy, ProxyUtil"/>
    </defaultProxy>
    <settings>
      <servicePointManager expect100Continue="false" />
    </settings>
  </system.net>
</configuration>


 3) Check the logs on C:\ProgramData\XamarinAndroidPlayer

Postar um comentário