public ServiceInvokerBase(IRegistery registery, string groupPath, ILoadBalance loadBalance, IWeightCalculator <ServiceMetadata> weightCalculator) { _serviceIdentity = typeof(TService).Name; _loadBalance = loadBalance; _weightCalculator = weightCalculator; _groupPath = groupPath; _listener = new NotifyListener(); _listener.OnMetadataChanged += (metas) => _metadatas = metas; _registery = registery; _registery.Subscribe(_groupPath, _listener, true); }
protected virtual T DoSelect <T>(IWeightCalculator <T> calculator, List <T> items, string key) { var weights = calculator.Calculate(items); if (weights.AllEqual()) { return(this.DoSelectEqual(items, key)); } else { return(this.DoSelectWeight(items, key, weights)); } }
public GoalsController(IRepository repository, IWeightCalculator calculator) { if (repository == null) { throw new ArgumentNullException(nameof(repository)); } if (calculator == null) { throw new ArgumentNullException(nameof(calculator)); } _repository = repository; _calculator = calculator; }
public T Select <T>(IWeightCalculator <T> calculator, List <T> items, string key = "") { if (calculator == null) { throw new ArgumentNullException("calculator", "calculator can not be null."); } if (items == null || !items.Any()) { throw new ArgumentNullException("items", "items can not be null or empty."); } if (items.Count == 1) { return(items.ElementAt(0)); } return(this.DoSelect(calculator, items, key)); }
protected override T DoSelect <T>(IWeightCalculator <T> calculator, List <T> items, string key) { Ensure.NotNullOrEmpty(key, "key"); return(base.DoSelect(calculator, items, key)); }
public WeightCalculatorWrapper(IWeightCalculator baseWeightCalculator) { _underlyingWeightCalculator = baseWeightCalculator; }
public WeighedRandomItemSelector(List <TObject> items, Random randomizer, IWeightCalculator <TObject> weightCalculator) { _randomizer = randomizer; _items = items; _weightCalculator = weightCalculator; }
public UnaryServiceInvoker(IRegistery registery, string groupPath, ILoadBalance loadBalance, IWeightCalculator <ServiceMetadata> weightCalculator) : base(registery, groupPath, loadBalance, weightCalculator) { }
public PenalisingWeightCalculator(IWeightCalculator _baseWeightCalculator) : base(_baseWeightCalculator) { }
public AStarPathFinder(IGraph <AStarNode> graph, IWeightCalculator weightCalculator, IWeightCalculator heuristicCalculator) { _graph = graph; _weightCalculator = weightCalculator; _heuristicCalculator = heuristicCalculator; }