/// <summary> /// Исключения: /// System.ArgumentNullException: /// Параметр model имеет значение null. /// </summary> /// <param name="model"></param> public DetailItemViewModel(IItemModelAdapter <DataModelType> model, IDataDetailViewModelCreator <DataModelType, DataDetailViewModelType> viewModelCreator, IItemModelAdapterCreator <DataModelType> itemModelCreator) { if (model == null) { throw new ArgumentNullException("model can't be null"); } if (viewModelCreator == null) { throw new ArgumentNullException("viewModelCreator can't be null"); } if (itemModelCreator == null) { throw new ArgumentNullException("itemModelCreator can't be null"); } _model = model; _model.Updated += OnUpdate; UpdateCommand = new UpdateItemCommand <DataModelType, DataDetailViewModelType>(this); EditCommand = new EditItemCommand <DataModelType, DataDetailViewModelType>(this); SaveCommand = new SaveItemCommand <DataModelType, DataDetailViewModelType>(this); Debug.Assert(_model.DataModel != null); _viewModelCreator = viewModelCreator; _itemModelCreator = itemModelCreator; DataViewModel = _viewModelCreator.CreateDataDetailViewModel(_model.DataModel); }
public DetailItemViewModelTimer(IItemModelAdapter <DataModelType> model, IDataDetailViewModelCreator <DataModelType, DataDetailViewModelType> viewModelCreator, IItemModelAdapterCreator <DataModelType> itemModelCreator, int updateInterval = 5) : base(model, viewModelCreator, itemModelCreator) { timer = new System.Windows.Threading.DispatcherTimer(); timer.Tick += Timer_Tick; timer.Interval = new TimeSpan(0, 0, updateInterval); timer.Start(); }
public ListViewModel(IListModel <DataModelType> model, IViewModelCreator <DataModelType, DataViewModelType, DataDetailViewModelType> creator, IItemModelAdapterCreator <DataModelType> itemModelCreator) { if (creator == null) { throw new ArgumentNullException("creator can't be null"); } _creator = creator; if (itemModelCreator == null) { throw new ArgumentNullException("itemModelCreator can't be null"); } _itemModelCreator = itemModelCreator; if (model == null) { throw new ArgumentNullException("model can't be null"); } _model = model; _model.Updated += OnUpdate; var itemViewModels = GetItemViewModels(_model.GetItems()); UpdateList(itemViewModels); AddItemCommand = new AddItemCommand <DataModelType, DataViewModelType, DataDetailViewModelType>(this); DeleteItemCommand = new DeleteItemCommand <DataModelType, DataViewModelType, DataDetailViewModelType>(this); EditListCommand = new EditListCommand <DataModelType, DataViewModelType, DataDetailViewModelType>(this); SaveListCommand = new SaveListCommand <DataModelType, DataViewModelType, DataDetailViewModelType>(this); SelectItemCommand = new SelectItemCommand <DataModelType, DataViewModelType, DataDetailViewModelType>(this); UpdateListCommand = new UpdateListCommand <DataModelType, DataViewModelType, DataDetailViewModelType>(this); addedAndDelatedItems = new Dictionary <IItemModelAdapter <DataModelType>, ChangeStatus>(); IsSaved = true; }