/SolutionFramework/Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.10.0/Microsoft/VisualStudio/ServiceModel/DomainServices/Tools/EntityViewModel.cs
C# | 111 lines | 98 code | 13 blank | 0 comment | 11 complexity | c20c7057d1936bd98ea4073a483ec574 MD5 | raw file
Possible License(s): Apache-2.0, LGPL-3.0
- namespace Microsoft.VisualStudio.ServiceModel.DomainServices.Tools
- {
- using System;
- using System.ComponentModel;
- using System.Threading;
-
- internal class EntityViewModel : INotifyPropertyChanged
- {
- private Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.ContextViewModel _contextViewModel;
- private Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.EntityData _entityData;
-
- public event PropertyChangedEventHandler PropertyChanged;
-
- public EntityViewModel(Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.ContextViewModel contextViewModel, Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.EntityData entityData)
- {
- this._contextViewModel = contextViewModel;
- this._entityData = entityData;
- }
-
- private void RaisePropertyChanged(string propertyName)
- {
- if (this.PropertyChanged != null)
- {
- this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
- }
- this.ContextViewModel.EntityStateChanged();
- }
-
- public override string ToString()
- {
- return this.Name;
- }
-
- public bool CanBeEdited
- {
- get
- {
- return this.EntityData.CanBeEdited;
- }
- }
-
- public bool CanBeIncluded
- {
- get
- {
- return this.EntityData.CanBeIncluded;
- }
- }
-
- public Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.ContextViewModel ContextViewModel
- {
- get
- {
- return this._contextViewModel;
- }
- }
-
- public Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.EntityData EntityData
- {
- get
- {
- return this._entityData;
- }
- }
-
- public bool IsEditable
- {
- get
- {
- return (this.EntityData.IsEditable && this.EntityData.CanBeEdited);
- }
- set
- {
- if ((value != this.EntityData.IsEditable) && (!value || this.EntityData.CanBeEdited))
- {
- this.EntityData.IsEditable = value;
- this.RaisePropertyChanged("IsEditable");
- if (value)
- {
- this.IsIncluded = true;
- }
- }
- }
- }
-
- public bool IsIncluded
- {
- get
- {
- return (this.EntityData.IsIncluded && this.EntityData.CanBeIncluded);
- }
- set
- {
- if (this.EntityData.IsIncluded != value)
- {
- this.EntityData.IsIncluded = value;
- this.RaisePropertyChanged("IsIncluded");
- }
- }
- }
-
- public string Name
- {
- get
- {
- return this.EntityData.Name;
- }
- }
- }
- }
-