Skip to content

INPC016 warns here #155

Open
Open
@JohanLarsson

Description

@JohanLarsson
    public class LimitsMutableWrapper<T> : INotifyPropertyChanged
        where T : struct, IComparable<T>
    {
        private readonly Func<Limits<T>> _getLimits;
        private readonly Action<Limits<T>> _setLimits;

        public LimitsMutableWrapper(Func<Limits<T>> getLimits, Action<Limits<T>> setLimits)
        {
            _getLimits = getLimits;
            _setLimits = setLimits;
        }

        public event PropertyChangedEventHandler PropertyChanged;

        public T Min
        {
            get => _getLimits().Min;

            set
            {
                if (Equals(value, Min))
                {
                    return;
                }

                _setLimits(new Limits<T>(value, Max));
                OnPropertyChanged();
            }
        }

        public T Max
        {
            get => _getLimits().Max;

            set
            {
                if (Equals(value, Max))
                {
                    return;
                }

                _setLimits(new Limits<T>(Min, value));
                OnPropertyChanged();
            }
        }

        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }

This is weird code, it should bail.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions