/// <summary>
            /// Values are non-default if they differ from the refined parent
            /// </summary>
            public override bool ShouldSerializeValue(object component)
            {
                NameGenerator generator       = (NameGenerator)component;
                NameGenerator parentGenerator = generator.RefinesGenerator;

                return((parentGenerator != null) ? !DomainPropertyInfo.GetValue(parentGenerator).Equals(DomainPropertyInfo.GetValue(generator)) : base.ShouldSerializeValue(component));
            }
 private static void PropagateChange(NameGenerator parentGenerator, DomainPropertyInfo propertyInfo, object oldValue, object newValue)
 {
     foreach (NameGenerator refinement in parentGenerator.RefinedByGeneratorCollection)
     {
         if (propertyInfo.GetValue(refinement).Equals(oldValue))
         {
             propertyInfo.SetValue(refinement, newValue);
             PropagateChange(refinement, propertyInfo, oldValue, newValue);
         }
     }
 }
            /// <summary>
            /// Reset the value to the value of the refined generator
            /// </summary>
            public override void ResetValue(object component)
            {
                NameGenerator generator       = (NameGenerator)component;
                NameGenerator parentGenerator = generator.RefinesGenerator;

                if (parentGenerator != null)
                {
                    // This gives a different transaction name that the default ResetValue, but
                    // the correct string is not accessible and the duplication is not worth the effort
                    base.SetValue(component, DomainPropertyInfo.GetValue(parentGenerator));
                }
                else
                {
                    base.ResetValue(component);
                }
            }
 private static void PropagateChange(NameGenerator parentGenerator, DomainPropertyInfo propertyInfo, object oldValue, object newValue, Type nameUsageType)
 {
     foreach (NameGenerator refinement in parentGenerator.RefinedByGeneratorCollection)
     {
         Type refinementUsage = refinement.NameUsageType;
         if (refinementUsage == null)
         {
             // Make sure we skip the level to get the corresponding usages
             PropagateChange(refinement, propertyInfo, oldValue, newValue, nameUsageType);
         }
         else if (refinementUsage == nameUsageType &&
                  propertyInfo.GetValue(refinement).Equals(oldValue))
         {
             propertyInfo.SetValue(refinement, newValue);
             PropagateChange(refinement, propertyInfo, oldValue, newValue, nameUsageType);
         }
     }
 }
Example #5
0
        /// <summary>Notify each model element in a collection that a tracked property has changed.</summary>
        /// <param name="store">The store for the model.</param>
        /// <param name="collection">The collection of model elements that contain the tracking property.</param>
        /// <param name="propertyId">The ID of the tracking property.</param>
        /// <param name="trackingPropertyId">The ID of the property that indicates whether the tracking property is tracking.</param>
        internal static void UpdateTrackingCollectionProperty(
            Store store,
            IEnumerable collection,
            Guid propertyId,
            Guid trackingPropertyId)
        {
            DomainPropertyInfo propInfo         = store.DomainDataDirectory.GetDomainProperty(propertyId);
            DomainPropertyInfo trackingPropInfo = store.DomainDataDirectory.GetDomainProperty(trackingPropertyId);

            Debug.Assert(propInfo != null);
            Debug.Assert(trackingPropInfo != null);
            Debug.Assert(trackingPropInfo.PropertyType == typeof(bool), "Tracking property not specified as a boolean");

            // If the tracking property is currently tracking, then notify
            // it that the tracked property has changed.
            foreach (ModelElement element in collection.Cast <ModelElement>()
                     .Where(element => element.GetDomainClass() == trackingPropInfo.DomainClass &&
                            (bool)trackingPropInfo.GetValue(element)))
            {
                propInfo.NotifyValueChange(element);
            }
        }