Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/21/11 17:35:42 (14 years ago)
Author:
cneumuel
Message:

#1233

  • fixed handling of StateLog in DataLayer
  • extended unit tests
  • changed style of service calls to OKB-like style (using delegates)
  • added possibility that parent jobs can be finished immediately when child jobs are finished
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ServiceLocator.cs

    r5405 r5526  
    2020#endregion
    2121
     22using System;
     23using System.ServiceModel;
    2224using HeuristicLab.Clients.Common;
    2325using HeuristicLab.Services.Hive.Common.ServiceContracts;
     
    3840    }
    3941
    40     public Disposable<IHiveService> GetService() {
    41       return ClientFactory.CreateClient<IHiveService>("wsHttpBinding_IHiveService");
     42    private string username;
     43    public string Username {
     44      get { return username; }
     45      set { username = value; }
    4246    }
    4347
    44     public Disposable<IHiveService> GetService(string username, string password) {
    45       return ClientFactory.CreateClient<IHiveService>("wsHttpBinding_IHiveService", null, username, password);
     48    private string password;
     49    public string Password {
     50      get { return password; }
     51      set { password = value; }
     52    }
     53   
     54    public Disposable<ChannelFactory<IHiveService>> GetService() {
     55      if (string.IsNullOrEmpty(username) && string.IsNullOrEmpty(password)) {
     56        return ClientFactory.CreateChannelFactory<IHiveService>("wsHttpBinding_IHiveService");
     57      } else {
     58        return ClientFactory.CreateChannelFactory<IHiveService>("wsHttpBinding_IHiveService", null, username, password);
     59      }
     60    }
     61
     62    public void CallHiveService(Action<IHiveService> call) {
     63      using (var channelFactory = this.GetService()) {
     64        var service = channelFactory.Obj.CreateChannel();
     65        call(service);
     66      } // disposing the channelfactory is done by the disposable object; the channel gets disposed when the channelfactory is disposed
     67    }
     68
     69    private T CallHiveService<T>(Func<IHiveService, T> call) {
     70      using (var channelFactory = this.GetService()) {
     71        var service = channelFactory.Obj.CreateChannel();
     72        return call(service);
     73      } // disposing the channelfactory is done by the disposable object; the channel gets disposed when the channelfactory is disposed
     74    }
     75
     76    T IServiceLocator.CallHiveService<T>(Func<IHiveService, T> call) {
     77      return CallHiveService<T>(call);
    4678    }
    4779  }
Note: See TracChangeset for help on using the changeset viewer.