Beispiel #1
0
        private void SetValueWithEvents <T>(T property, object newValue, Action <T, Object, Object> action) where T : StructuralProperty
        {
            var oldValue = GetValue(property);

            if (Object.Equals(oldValue, newValue))
            {
                return;
            }

            if (!EntityAspect.OnEntityChanging(EntityAction.PropertyChange))
            {
                return;
            }

            action(property, newValue, oldValue);

            EntityAspect.OnPropertyChanged(this.ParentEntityProperty);

            if (this.IsAttached)
            {
                if (!EntityManager.IsLoadingEntity)
                {
                    if (this.EntityState == EntityState.Unchanged)
                    {
                        EntityAspect.SetModified();
                    }
                }

                // TODO: implement this.
                //if (entityManager.validationOptions.validateOnPropertyChange) {
                //    entityAspect._validateProperty(newValue,
                //        { entity: entity, property: property, propertyName: propPath, oldValue: oldValue });
                //}
            }
        }
Beispiel #2
0
        private void SetValueWithEvents <T>(T property, object newValue, Action <T, Object, Object> action) where T : StructuralProperty
        {
            var oldValue = GetValue(property);

            if (Object.Equals(oldValue, newValue))
            {
                return;
            }

            if (!EntityAspect.OnEntityChanging(EntityAction.PropertyChange))
            {
                return;
            }

            action(property, newValue, oldValue);

            EntityAspect.OnPropertyChanged(this.ParentEntityProperty);

            if (this.IsAttached)
            {
                if (!EntityManager.IsLoadingEntity)
                {
                    if (this.EntityState == EntityState.Unchanged)
                    {
                        EntityAspect.SetModified();
                    }
                }

                if ((EntityManager.ValidationOptions.ValidationApplicability & ValidationApplicability.OnPropertyChange) > 0)
                {
                    ValidateProperty(property, newValue);
                }
            }
        }