@@ -958,12 +958,32 @@ public enum MODIFICATIONS_REVERT_METHOD {
958958
959959 // there should be only one HTTP Client per application
960960 // (as of right now though this is exclusively used by DownloadsBefore class)
961- private static readonly HttpClientHandler httpClientHandler = new HttpClientHandler {
962- Proxy = new WebProxy ( "127.0.0.1" , 22500 ) ,
963- UseProxy = true
964- } ;
961+ private static HttpClientHandler httpClientHandler = null ;
962+
963+ private static HttpClientHandler HttpClientHandler {
964+ get {
965+ if ( httpClientHandler == null ) {
966+ FlashpointProxy . GetPreferences ( out bool proxy , out int port ) ;
967+
968+ httpClientHandler = new HttpClientHandler {
969+ Proxy = proxy ? new WebProxy ( "127.0.0.1" , port ) : null ,
970+ UseProxy = proxy
971+ } ;
972+ }
973+ return httpClientHandler ;
974+ }
975+ }
976+
977+ private static HttpClient httpClient = null ;
965978
966- public static readonly HttpClient httpClient = new HttpClient ( httpClientHandler ) ;
979+ public static HttpClient HttpClient {
980+ get {
981+ if ( httpClient == null ) {
982+ httpClient = new HttpClient ( HttpClientHandler ) ;
983+ }
984+ return httpClient ;
985+ }
986+ }
967987
968988 // no parallel downloads
969989 // if parallel downloads are ever supported, the max value should
@@ -1264,7 +1284,7 @@ public ModeElement Mode {
12641284 if ( String . IsNullOrEmpty ( Name ) || _mode == null ) {
12651285 return null ;
12661286 }
1267- return base [ _mode ] as ModeElement ;
1287+ return ( ModeElement ) base [ _mode ] ;
12681288 }
12691289
12701290 set {
@@ -1400,7 +1420,7 @@ protected override ConfigurationPropertyCollection Properties {
14001420 }
14011421
14021422 protected override object GetElementKey ( ConfigurationElement configurationElement ) {
1403- EnvironmentVariablesElement environmentVariablesElement = configurationElement as EnvironmentVariablesElement ;
1423+ EnvironmentVariablesElement environmentVariablesElement = ( EnvironmentVariablesElement ) configurationElement ;
14041424 return environmentVariablesElement . _Key ;
14051425 }
14061426
@@ -1444,7 +1464,7 @@ public string Name {
14441464 }
14451465
14461466 protected override object GetElementKey ( ConfigurationElement configurationElement ) {
1447- DownloadBeforeElement downloadBeforeElement = configurationElement as DownloadBeforeElement ;
1467+ DownloadBeforeElement downloadBeforeElement = ( DownloadBeforeElement ) configurationElement ;
14481468 return downloadBeforeElement . Name ;
14491469 }
14501470
@@ -1653,7 +1673,7 @@ protected override ConfigurationPropertyCollection Properties {
16531673 }
16541674
16551675 protected override object GetElementKey ( ConfigurationElement configurationElement ) {
1656- RegistryStateElement registryStateElement = configurationElement as RegistryStateElement ;
1676+ RegistryStateElement registryStateElement = ( RegistryStateElement ) configurationElement ;
16571677 return registryStateElement . Name ;
16581678 }
16591679
@@ -1848,10 +1868,10 @@ public OldCPUSimulatorElement OldCPUSimulator {
18481868 }
18491869 }
18501870 }
1851-
1871+
18521872 public ModificationsElement Modifications {
18531873 get {
1854- return base [ _modifications ] as ModificationsElement ;
1874+ return ( ModificationsElement ) base [ _modifications ] ;
18551875 }
18561876
18571877 set {
@@ -1867,7 +1887,7 @@ protected override ConfigurationPropertyCollection Properties {
18671887 }
18681888
18691889 protected override object GetElementKey ( ConfigurationElement configurationElement ) {
1870- TemplateElement templateElement = configurationElement as TemplateElement ;
1890+ TemplateElement templateElement = ( TemplateElement ) configurationElement ;
18711891 return templateElement . Name ;
18721892 }
18731893
@@ -1884,6 +1904,22 @@ public override void Remove(string name) {
18841904 }
18851905 }
18861906
1907+ public class FlashpointProxyElement : ConfigurationElement {
1908+ [ ConfigurationProperty ( "proxy" , IsRequired = false ) ]
1909+ public bool ? Proxy {
1910+ get {
1911+ return base [ "proxy" ] as bool ? ;
1912+ }
1913+ }
1914+
1915+ [ ConfigurationProperty ( "port" , IsRequired = false ) ]
1916+ public int ? Port {
1917+ get {
1918+ return base [ "port" ] as int ? ;
1919+ }
1920+ }
1921+ }
1922+
18871923 [ ConfigurationProperty ( "templates" , IsDefaultCollection = true , IsRequired = true ) ]
18881924 [ ConfigurationCollection ( typeof ( TemplatesElementCollection ) , AddItemName = "template" ) ]
18891925 public TemplatesElementCollection Templates {
@@ -1895,6 +1931,13 @@ public TemplatesElementCollection Templates {
18951931 base [ "templates" ] = value ;
18961932 }
18971933 }
1934+
1935+ [ ConfigurationProperty ( "flashpointProxy" , IsDefaultCollection = false , IsRequired = false ) ]
1936+ public FlashpointProxyElement FlashpointProxy {
1937+ get {
1938+ return ( FlashpointProxyElement ) base [ "flashpointProxy" ] ;
1939+ }
1940+ }
18981941 }
18991942
19001943 public const string ACTIVE_EXE_CONFIGURATION_NAME = "" ;
@@ -2227,7 +2270,7 @@ public static async Task<Uri> DownloadAsync(string name) {
22272270 await downloadSemaphoreSlim . WaitAsync ( ) . ConfigureAwait ( true ) ;
22282271
22292272 try {
2230- using ( HttpResponseMessage httpResponseMessage = await httpClient . GetAsync ( name , HttpCompletionOption . ResponseHeadersRead ) . ConfigureAwait ( true ) ) {
2273+ using ( HttpResponseMessage httpResponseMessage = await HttpClient . GetAsync ( name , HttpCompletionOption . ResponseHeadersRead ) . ConfigureAwait ( true ) ) {
22312274 if ( ! httpResponseMessage . IsSuccessStatusCode ) {
22322275 throw new Exceptions . DownloadFailedException ( "The HTTP Response Message failed with a Status Code of \" " + httpResponseMessage . StatusCode + "\" ." ) ;
22332276 }
@@ -2510,8 +2553,11 @@ public static async Task DownloadFlashpointSecurePlayerSectionAsync(string name)
25102553 public static FlashpointSecurePlayerSection . TemplatesElementCollection . TemplateElement GetTemplateElement ( bool createTemplateElement , string exeConfigurationName ) {
25112554 // need the section to operate on
25122555 FlashpointSecurePlayerSection flashpointSecurePlayerSection = GetFlashpointSecurePlayerSection ( createTemplateElement , exeConfigurationName ) ;
2556+
25132557 // get the element
2514- FlashpointSecurePlayerSection . TemplatesElementCollection . TemplateElement templateElement = flashpointSecurePlayerSection . Templates . Get ( exeConfigurationName ) as FlashpointSecurePlayerSection . TemplatesElementCollection . TemplateElement ;
2558+ FlashpointSecurePlayerSection . TemplatesElementCollection . TemplateElement templateElement
2559+ = flashpointSecurePlayerSection . Templates . Get ( exeConfigurationName )
2560+ as FlashpointSecurePlayerSection . TemplatesElementCollection . TemplateElement ;
25152561
25162562 // create it if it doesn't exist...
25172563 if ( createTemplateElement && templateElement == null ) {
@@ -2614,9 +2660,9 @@ public static StringBuilder GetCreateProcessCommandLine(ProcessStartInfo process
26142660 return commandLine ;
26152661 }
26162662
2617- public static void StartProcessCreateBreakawayFromJob ( ProcessStartInfo processStartInfo , out Process process ) {
2618- process = null ;
2619-
2663+ public static Process StartProcessCreateBreakawayFromJob ( ProcessStartInfo processStartInfo ) {
2664+ Process process = null ;
2665+
26202666 if ( processStartInfo == null ) {
26212667 throw new ArgumentNullException ( "The processStartInfo is null." ) ;
26222668 }
@@ -2651,7 +2697,7 @@ public static void StartProcessCreateBreakawayFromJob(ProcessStartInfo processSt
26512697
26522698 if ( ! CreateProcess ( null , commandLine , IntPtr . Zero , IntPtr . Zero , false , creationFlags , IntPtr . Zero , currentDirectory , ref startupInfo , out processInformation ) ) {
26532699 Marshal . ThrowExceptionForHR ( Marshal . GetHRForLastWin32Error ( ) ) ;
2654- return ;
2700+ return process ;
26552701 }
26562702
26572703 try {
@@ -2666,7 +2712,7 @@ public static void StartProcessCreateBreakawayFromJob(ProcessStartInfo processSt
26662712
26672713 if ( ResumeThread ( processInformation . hThread ) == - 1 ) {
26682714 Marshal . ThrowExceptionForHR ( Marshal . GetHRForLastWin32Error ( ) ) ;
2669- return ;
2715+ return process ;
26702716 }
26712717 } catch {
26722718 process . Kill ( ) ;
@@ -2683,6 +2729,7 @@ public static void StartProcessCreateBreakawayFromJob(ProcessStartInfo processSt
26832729 Marshal . ThrowExceptionForHR ( Marshal . GetHRForLastWin32Error ( ) ) ;
26842730 }
26852731 }
2732+ return process ;
26862733 }
26872734
26882735 public static BINARY_TYPE GetLibraryBinaryType ( string libFileName ) {
0 commit comments