Esempio n. 1
0
        //#region Set classes

        /// <summary>
        ///     Establece la propiedad utilizando el operador <c>!=</c> para comprobar si
        ///     ha cambiado.
        ///     No se puede utilizar en estructuras.
        /// </summary>
        public static void SetCl <T>(this INotifyPropertyChangedEx_Helper @this,
                                     string name, T oldValue, T value,
                                     Action <T> setter) where T : class
        {
            if (oldValue != value)
            {
                setter(value);
                @this.NotifyPropertyChanged(new PropertyChangedExEventArgs(name, oldValue, value));
            }
        }
Esempio n. 2
0
 /// <summary>
 ///     Establece la propiedad utilizando el método <c>Equals</c> para comprobar si
 ///     ha cambiado.
 ///     Solo se puede utilizar en estructuras.
 /// </summary>
 public static void SetSt <T>(this INotifyPropertyChangedEx_Helper @this,
                              string name, T?oldValue, T?value,
                              Action <T?> setter) where T : struct
 {
     if (!object.Equals(oldValue, value))
     {
         setter(value);
         @this.NotifyPropertyChanged(name, oldValue, value);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// </summary>
 public static void SetEq <T>(this INotifyPropertyChangedEx_Helper @this,
                              string name, T oldValue, T value,
                              Action <T> setter)
 {
     if (!object.Equals(oldValue, value))
     {
         setter(value);
         @this.NotifyPropertyChanged(name, oldValue, value);
     }
 }
Esempio n. 4
0
 /// <summary>
 ///     Establece la propiedad utilizando el operador <c>!=</c> para comprobar si
 ///     ha cambiado.
 ///     Solo se puede utilizar en <c>uint?</c>.
 /// </summary>
 public static void SetSt(this INotifyPropertyChangedEx_Helper @this,
                          string name, double?oldValue, double?value,
                          Action <double?> setter)
 {
     if (oldValue != value)
     {
         setter(value);
         @this.NotifyPropertyChanged(name, oldValue, value);
     }
 }
Esempio n. 5
0
 public static void EpsilonSet <T>(this INotifyPropertyChangedEx_Helper @this,
                                   ref T backingStore, T value, double epsilon = MathUtils.EPSILON,
                                   [CallerMemberName] string name = "")
 {
     if (!EpsilonEqualityComparer <T> .Default.EpsilonEquals(backingStore, value, epsilon))
     {
         T oldValue = backingStore;
         backingStore = value;
         @this.NotifyPropertyChanged(new PropertyChangedExEventArgs(name, oldValue, value));
     }
 }
Esempio n. 6
0
 public static void Set <T>(this INotifyPropertyChangedEx_Helper @this,
                            ref T backingStore, T value,
                            [CallerMemberName] string name = "")
 {
     if (!EqualityComparer <T> .Default.Equals(backingStore, value))
     {
         T oldValue = backingStore;
         backingStore = value;
         @this.NotifyPropertyChanged(new PropertyChangedExEventArgs(name, oldValue, value));
     }
 }
Esempio n. 7
0
        //#endregion Set structs

        /// <summary>
        /// </summary>
        public static void Set <T>(this INotifyPropertyChangedEx_Helper @this,
                                   string name, T oldValue, T value,
                                   Action <T> setter)
        {
            if (typeof(T).IsValueType)
            {
                if (!object.Equals(oldValue, value))
                {
                    setter(value);
                    @this.NotifyPropertyChanged(name, oldValue, value);
                }
            }
            else
            {
                if (!object.ReferenceEquals(oldValue, value))
                {
                    setter(value);
                    @this.NotifyPropertyChanged(name, oldValue, value);
                }
            }
        }
Esempio n. 8
0
 public static void NotifyPropertyChanged(this INotifyPropertyChangedEx_Helper sender, string name, object oldValue, object value)
 {
     sender.NotifyPropertyChanged(new PropertyChangedExEventArgs(name, oldValue, value));
 }