Пример #1
0
 /// <summary>
 /// Subscribe to model element changes
 /// </summary>
 public override void SubscribeToModelChanges()
 {
     // subscribe to <#= domainElement.Name #>.<#= property.Name #> changes
     foreach (ModelElement modelElement in this.Elements)
     {
         Guid?propertyId = PropertyGridEditorViewModel.GetPropertyDomainObjectId(modelElement, this.PropertyName);
         if (propertyId != null)
         {
             this.EventManager.GetEvent <ModelElementPropertyChangedEvent>().Subscribe(this.Store.DomainDataDirectory.GetDomainProperty(propertyId.Value), modelElement.Id, new System.Action <ElementPropertyChangedEventArgs>(OnPropertyChanged));
         }
     }
 }
Пример #2
0
        /// <summary>
        /// Unregister from events although they are weak.
        /// </summary>
        protected override void OnDispose()
        {
            foreach (ModelElement modelElement in this.Elements)
            {
                Guid?propertyId = PropertyGridEditorViewModel.GetPropertyDomainObjectId(modelElement, this.PropertyName);
                if (propertyId != null)
                {
                    this.EventManager.GetEvent <ModelElementPropertyChangedEvent>().Unsubscribe(this.Store.DomainDataDirectory.GetDomainProperty(propertyId.Value), modelElement.Id, new System.Action <ElementPropertyChangedEventArgs>(OnPropertyChanged));
                }
            }

            base.OnDispose();
        }