Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ WinInetProxyHelper()

System.Net.Http.WinInetProxyHelper.WinInetProxyHelper ( )
inline

Definition at line 68 of file WinInetProxyHelper.cs.

69 {
70 global::Interop.WinHttp.WINHTTP_CURRENT_USER_IE_PROXY_CONFIG proxyConfig = default(global::Interop.WinHttp.WINHTTP_CURRENT_USER_IE_PROXY_CONFIG);
71 try
72 {
73 if (global::Interop.WinHttp.WinHttpGetIEProxyConfigForCurrentUser(out proxyConfig))
74 {
75 _autoConfigUrl = Marshal.PtrToStringUni(proxyConfig.AutoConfigUrl);
76 _autoDetect = proxyConfig.AutoDetect;
77 _proxy = Marshal.PtrToStringUni(proxyConfig.Proxy);
78 _proxyBypass = Marshal.PtrToStringUni(proxyConfig.ProxyBypass);
79 if (System.Net.NetEventSource.Log.IsEnabled())
80 {
81 System.Net.NetEventSource.Info(this, $"AutoConfigUrl={AutoConfigUrl}, AutoDetect={AutoDetect}, Proxy={Proxy}, ProxyBypass={ProxyBypass}", ".ctor");
82 }
83 _useProxy = true;
84 }
85 else
86 {
87 int lastWin32Error = Marshal.GetLastWin32Error();
88 if (System.Net.NetEventSource.Log.IsEnabled())
89 {
90 System.Net.NetEventSource.Error(this, $"error={lastWin32Error}", ".ctor");
91 }
92 }
93 if (System.Net.NetEventSource.Log.IsEnabled())
94 {
95 System.Net.NetEventSource.Info(this, $"_useProxy={_useProxy}", ".ctor");
96 }
97 }
98 finally
99 {
100 Marshal.FreeHGlobal(proxyConfig.AutoConfigUrl);
101 Marshal.FreeHGlobal(proxyConfig.Proxy);
102 Marshal.FreeHGlobal(proxyConfig.ProxyBypass);
103 }
104 }
static readonly System.Net.NetEventSource Log
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)
static void Error(object thisOrContextObject, FormattableString formattableString, [CallerMemberName] string memberName=null)
static void FreeHGlobal(IntPtr hglobal)
Definition Marshal.cs:1680
static unsafe? string PtrToStringUni(IntPtr ptr)
Definition Marshal.cs:652

References System.Net.Http.WinInetProxyHelper._autoConfigUrl, System.Net.Http.WinInetProxyHelper._autoDetect, System.Net.Http.WinInetProxyHelper._proxy, System.Net.Http.WinInetProxyHelper._proxyBypass, System.Net.Http.WinInetProxyHelper._useProxy, System.Net.NetEventSource.Error(), System.Runtime.InteropServices.Marshal.FreeHGlobal(), System.Runtime.InteropServices.Marshal.GetLastWin32Error(), System.Net.NetEventSource.Info(), System.Net.NetEventSource.Log, and System.Runtime.InteropServices.Marshal.PtrToStringUni().