Changeset 5706
- Timestamp:
- 03/16/11 13:27:30 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Clients.Common/3.3
- Files:
-
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Clients.Common/3.3/ClientFactory.cs
r5701 r5706 24 24 using System.ServiceModel.Description; 25 25 using HeuristicLab.Clients.Common.Properties; 26 using HeuristicLab.Common;27 26 28 27 namespace HeuristicLab.Clients.Common { … … 66 65 67 66 #region CreateChannelFactory Methods 68 public static Disposable<ChannelFactory<I>> CreateChannelFactory<I>(string endpointConfigurationName)67 public static ChannelFactory<I> CreateChannelFactory<I>(string endpointConfigurationName) 69 68 where I : class { 70 69 return CreateChannelFactory<I>(endpointConfigurationName, null); 71 70 } 72 public static Disposable<ChannelFactory<I>> CreateChannelFactory<I>(string endpointConfigurationName, string remoteAddress)71 public static ChannelFactory<I> CreateChannelFactory<I>(string endpointConfigurationName, string remoteAddress) 73 72 where I : class { 74 73 return CreateChannelFactory<I>(endpointConfigurationName, remoteAddress, Settings.Default.UserName, Settings.Default.Password); 75 74 } 76 public static Disposable<ChannelFactory<I>> CreateChannelFactory<I>(string endpointConfigurationName, string remoteAddress, string userName, string password)75 public static ChannelFactory<I> CreateChannelFactory<I>(string endpointConfigurationName, string remoteAddress, string userName, string password) 77 76 where I : class { 78 77 ChannelFactory<I> channelFactory = new ChannelFactory<I>(endpointConfigurationName); 79 channelFactory.Credentials.UserName.UserName = userName;80 channelFactory.Credentials.UserName.Password = password;81 channelFactory.Credentials.ServiceCertificate.Authentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.None;82 83 78 if (!string.IsNullOrEmpty(remoteAddress)) { 84 79 SetEndpointAddress(channelFactory.Endpoint, remoteAddress); 85 80 } 86 81 87 Disposable<ChannelFactory<I>> disposableChannelFactory = new Disposable<ChannelFactory<I>>(channelFactory); 88 disposableChannelFactory.OnDisposing += new EventHandler<EventArgs<object>>(DisposableChannelFactory_OnDisposing); 89 return disposableChannelFactory; 90 } 91 92 private static void DisposableChannelFactory_OnDisposing(object sender, EventArgs<object> e) { 93 DisposeCommunicationObject((ICommunicationObject)e.Value); 94 ((Disposable)sender).OnDisposing -= new EventHandler<EventArgs<object>>(DisposableChannelFactory_OnDisposing); 82 channelFactory.Credentials.UserName.UserName = userName; 83 channelFactory.Credentials.UserName.Password = password; 84 channelFactory.Credentials.ServiceCertificate.Authentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.None; 85 return channelFactory; 95 86 } 96 87 #endregion 97 98 public static void DisposeCommunicationObject(ICommunicationObject obj) {99 if (obj != null) {100 if (obj.State != CommunicationState.Faulted && obj.State != CommunicationState.Closed) {101 try { obj.Close(); }102 catch { obj.Abort(); }103 } else {104 obj.Abort();105 }106 }107 }108 88 109 89 #region Helpers -
trunk/sources/HeuristicLab.Clients.Common/3.3/HeuristicLab.Clients.Common-3.3.csproj
r5163 r5706 12 12 <AssemblyName>HeuristicLab.Clients.Common-3.3</AssemblyName> 13 13 <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> 14 <TargetFrameworkProfile></TargetFrameworkProfile> 14 <TargetFrameworkProfile> 15 </TargetFrameworkProfile> 15 16 <FileAlignment>512</FileAlignment> 16 17 <TargetFrameworkProfile /> … … 116 117 <ItemGroup> 117 118 <Compile Include="ClientFactory.cs" /> 118 <Compile Include="Disposable.cs" />119 119 <Compile Include="HeuristicLabClientsCommonPlugin.cs" /> 120 120 <Compile Include="PasswordDialog.cs">
Note: See TracChangeset
for help on using the changeset viewer.