示例#1
0
        public void Notify <TType>(Expression <Func <TType> > propertyExpression,
                                   Func <TType> propertyGetter,
                                   Action <TType> propertySetter,
                                   MigratorMode mode = MigratorMode.Smart)
        {
            if (!Recording)
            {
                return;
            }

            if (propertyExpression == null)
            {
                throw new ArgumentNullException(nameof(propertyExpression));
            }

            //Remove all "future" steps
            RemoveFutureSteps();

            //Check if the previous migrations edits the same property
            if (migrations.Count > 0 && mode == MigratorMode.Smart &&
                PropertyAttributeGetter.GetMemberInfo(propertyExpression.Body).HasSameMetadataDefinitionAs(
                    PropertyAttributeGetter.GetMemberInfo(migrations.First().PropertyExpression))
                )
            {
                //Do nothing
            }

            //Create new migration
            else
            {
                var newMigration = new GetSetValueMigration <TType>(propertyExpression.Body, propertyGetter, propertySetter);
                migrations.Insert(0, newMigration);
                InvokeMigratorChange();
            }
        }
示例#2
0
        public void Notify <TType>(Expression <Func <TType> > propertyExpression,
                                   Action <TType> propertySetter,
                                   MigratorMode mode = MigratorMode.Smart)
        {
            if (propertyExpression == null)
            {
                throw new ArgumentNullException(nameof(propertyExpression));
            }

            Notify(propertyExpression, propertyExpression.Compile(), propertySetter, mode);
        }