public bool Remove(Worker item) { Worker[] tempWorkers; if (Workers.Contains(item)) { tempWorkers = new Worker[Count - 1]; } else { return(false); } for (int i = 0, j = 0; j < Count - 1; i++, j++) { if (Workers[i].Equals(item)) { tempWorkers[j] = Workers[++i]; //skip item that we want to remove } else { tempWorkers[j] = Workers[i]; } } Workers = tempWorkers; Count -= 1; return(true); }
/// <summary> /// Удаление сотрудника из списка /// </summary> /// <param name="worker">Сотрудник</param> public void DeleteWorker(Employee worker) { if (Workers.Contains(worker)) { Workers.Remove(worker); } }
/// <summary> /// Добавление сотрудника в список /// </summary> /// <param name="worker">Сотрудник</param> public void AddWorker(Employee worker) { if (!Workers.Contains(worker)) { if (worker is SupportWorker) { if (!CheckPersonalId((SupportWorker)worker)) { throw new Exception("Worker`s ID number was already used"); } } else if (worker is ShopAssistant) { if (!CheckPersonalId((ShopAssistant)worker)) { throw new Exception("Worker`s personal ID was already used"); } } Workers.Add(worker); } }
public void AddSeries(WorkerModel _wm) { LineSeries _ls = new LineSeries(); _ls.Title = _wm.IP.ToString() + _wm.MethodName; foreach (MeasureModel _m in _wm.Measure) { _ls.Points.Add(new DataPoint(DateTimeAxis.ToDouble(_m.Time), _m.Value)); } Model.Series.Add(_ls); _wm.Measure.CollectionChanged += Measures_CollectionChanged; Series.Add(new Tuple < LineSeries, NotifyCollectionChangedEventHandler, ObservableCollection <MeasureModel> > (_ls, Measures_CollectionChanged, _wm.Measure)); RaisePropertyChanged("LineSeries"); RefreshPlot(); if (!Workers.Contains(_wm)) { Workers.Add(_wm); } }
public override void removeEntity(IGameEntity entity) { if (entity.info.isBuilding) { if (entity.info.isResource) { OwnResources.Remove((Resource)entity); } else { if (((BuildingInfo)entity.info).type == BuildingTypes.STRONGHOLD) { hasStronghold = false; } OwnBarracks.Remove((Barrack)entity); } } else { Unit u = (Unit)entity; if (entity.info.isArmy) { if (Army.Contains(u)) { Army.Remove(u); } } else { if (Workers.Contains(u)) { Workers.Remove(u); } } } }
public bool CanWorkHere(IWorker worker) => Workers.Contains(worker) || Workers.Count < maxWorkers;