RadicalFx / Radical

Radical is an infrastructure framework whose primary role is to help in the development of composite WPF applications based on the Model View ViewModel pattern.
http://www.radicalframework.com/
MIT License
38 stars 3 forks source link

Obsolete Expression based stuff that can be replaced with nameof operator where possible #336

Open mauroservienti opened 4 years ago

nazarenomanco commented 4 years ago

@mauroservienti I have a problem... may you help me how to solve this without having entity?

        public EntityPropertyStates GetEntityPropertyState<TEntity>(TEntity entity, string propertyName)
        {
            var property = entity.GetType().GetProperty(propertyName);

            Ensure.That(property)
                .WithMessage("Cannot find property: {0}", propertyName)
                .IsNotNull();

            var state = EntityPropertyStates.None;

            if (TryGetOriginalValue(propertyName, out TProperty originalValue))
            {
                state |= EntityPropertyStates.Changed;

                TProperty actualValue;
                if (entity is Model.Entity e)
                {
                    actualValue = e.GetPropertyValue<TProperty>(propertyName);
                }
                else
                {
                    actualValue = (TProperty)property.GetValue(entity, null);
                }

                if (!Equals(originalValue, actualValue))
                {
                    state |= EntityPropertyStates.ValueChanged;
                }
            }

            return state;
        }

Thanks

mauroservienti commented 4 years ago

Skip it, raise a dedicated issue and move forward. I have a couple of ideas but they are viral changes that might take a long time to tackle.

mauroservienti commented 4 years ago

I'm not sure where this stands, removing it from the 2.1.0 milestone to get it out of the door. We can continue working on it for the next release.