public Model GetModel(string resourceString) { if (Models.Count(res => res.ResourceString.Equals(resourceString)) == 1) { return(Models.First(res => res.ResourceString.Equals(resourceString)).Content); } else { return(null); } }
private void ModelsListCreator(IList <Model> list, Delegate lambdaDept) { Models.Clear(); foreach (var item in list) { int devicesCount = item.Devices.Count(); if (lambdaDept != null) { devicesCount = item.Devices.Where((Func <Device, bool>)lambdaDept).Count(); } Models.Add(new MView(item, devicesCount, Models.Count() + 1)); } }
public string[] this[string Index] { get { for (int i = 0; i != Models.Count(); i++) { if (Models[i][0] == Index) { return(Models[i]); } } throw new Exception("Can't find " + Index); } }
public void MoveModel(ModbusTableModel model = null, int index = -1, MOVE_DIRECTION direct = MOVE_DIRECTION.UP) { _ArguemntsTranslate(ref model, ref index); switch (direct) { case MOVE_DIRECTION.UP: if (index > 0) { RemoveModel(model); AddModel(model, index - 1); } break; case MOVE_DIRECTION.DOWN: if (index < Models.Count() - 1) { RemoveModel(model); AddModel(model, index + 1); } break; } }
internal async Task AddOrUpdateModels() { var service = ServicesManager.SelfService; try { if (CurrentModel == null || string.IsNullOrEmpty(CurrentModel.Name)) { MainWindow.Instance.AddNotification(new BaseResponse() { Error = ErrorCode.ValidationError, Message = "Model cannot be empty." }); return; } if (Models.Count(x => x.Name == CurrentModel.Name) > 1) { MainWindow.Instance.AddNotification(new BaseResponse() { Error = ErrorCode.ValidationError, Message = "Model name already exists." }); return; } var locationsResponse = await service.UpdateModel(Token, CurrentModel); MainWindow.Instance.AddNotification(locationsResponse ?? new BaseResponse() { Error = ErrorCode.InternalError, Message = "Failed to receive response from host." }); } catch (ServiceException ex) { //TODO: HIGH Add logging MainWindow.Instance.AddNotification(ex); } }
protected bool GetSelectedOne(out CheckableModel model, string optDesc) { model = null; if (Models == null || Models.Count() < 1) { return(false); } var items = Models.Where(m => m.IsChecked == true); var count = items.Count(); if (count < 1) { MessageWindow.ShowMsg(MessageType.Warning, optDesc, MsgConst.Msg_SelectData); return(false); } if (count > 1) { MessageWindow.ShowMsg(MessageType.Warning, optDesc, MsgConst.Msg_SelectOnlyone); return(false); } model = items.First(); return(true); }
static PrositIntensityModel() { // Not sure if the models count will ever change. Maybe in the future // users can somehow add their own models. But this is just capacity anyways. _instances = new List <PrositIntensityModel>(Models.Count()); }
//Counts the number of guys still alive in the unit. public int LiveCount() { return(Models.Count(p => p != null)); }