/// <summary> /// Get session launcher binding /// </summary> /// <param name="info"></param> /// <returns></returns> public static Binding GetSessionLauncherBinding(this IConnectionInfo info) { #if API if (LocalSession.LocalBroker) { return(new NetNamedPipeBinding(NetNamedPipeSecurityMode.Transport)); } #endif if ((info.TransportScheme & TransportScheme.NetTcp) == TransportScheme.NetTcp) { Binding binding; try { binding = new NetTcpBinding(BindingHelper.LauncherNetTcpBindingName); } catch (KeyNotFoundException) { binding = info.DefaultSessionLauncherNetTcpBinding(); } return(binding); } #if !net40 else if ((info.TransportScheme & TransportScheme.NetHttp) == TransportScheme.NetHttp) { Binding binding; try { binding = new NetTcpBinding(BindingHelper.LauncherNetHttpBindingName); } catch (KeyNotFoundException) { binding = BindingHelper.HardCodedSessionLauncherNetHttpsBinding; } return(binding); } #endif else if ((info.TransportScheme & TransportScheme.Http) == TransportScheme.Http) { Binding binding; try { binding = new BasicHttpBinding(BindingHelper.LauncherHttpBindingName); } catch (KeyNotFoundException) { binding = BindingHelper.HardCodedSessionLauncherHttpsBinding; } return(binding); } #if AZURE_STORAGE_BINDING else if ((info.TransportScheme & TransportScheme.AzureStorage) == TransportScheme.AzureStorage) { if (string.IsNullOrEmpty(info.AzureStorageConnectionString)) { Trace.TraceError($"{nameof(info.AzureStorageConnectionString)} is not presented in {nameof(IConnectionInfo)}"); throw new InvalidOperationException($"{nameof(info.AzureStorageConnectionString)} is not presented in {nameof(IConnectionInfo)}"); } string partitionKey; if (string.IsNullOrEmpty(info.AzureTableStoragePartitionKey)) { partitionKey = Guid.NewGuid().ToString(); Trace.TraceWarning($"{nameof(info.AzureTableStoragePartitionKey)} is not presented in {nameof(IConnectionInfo)}. Use generated key {partitionKey}"); } else { partitionKey = info.AzureTableStoragePartitionKey; Trace.TraceInformation($"{nameof(info.AzureTableStoragePartitionKey)}: {partitionKey}"); } return(new TableTransportBinding() { ConnectionString = info.AzureStorageConnectionString, TargetPartitionKey = partitionKey }); } #endif else if ((info.TransportScheme & TransportScheme.Custom) == TransportScheme.Custom) { return(info.DefaultSessionLauncherNetTcpBinding()); } else { return(info.DefaultSessionLauncherNetTcpBinding()); } }