Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INPC016 warns here #155

Open
JohanLarsson opened this issue Nov 8, 2019 · 0 comments
Open

INPC016 warns here #155

JohanLarsson opened this issue Nov 8, 2019 · 0 comments

Comments

@JohanLarsson
Copy link
Collaborator

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant