Exemplo n.º 1
0
 /// <summary>
 /// Invokes the properties changed.
 /// </summary>
 /// <param name="instance">The INotifyPropertyChanged implementation.</param>
 /// <param name="invoker">The invoker.</param>
 /// <param name="propertyNames">The property name list.</param>
 public static void InvokePropertiesChanged(this INotifyPropertyChanged instance, PropertyChangedInvokerEventHandler invoker, params string[] propertyNames)
 {
     foreach (var propertyName in propertyNames)
     {
         invoker?.Invoke(propertyName);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Sets the specified invoker.
        /// </summary>
        /// <typeparam name="T">.</typeparam>
        /// <param name="instance">The instance.</param>
        /// <param name="invoker">The invoker.</param>
        /// <param name="field">The field.</param>
        /// <param name="value">The value.</param>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="propertyNames">The other optional property names to notify.</param>
        /// <returns> True if old value and new value are different. .</returns>
        public static bool Set <T>(this INotifyPropertyChanged instance, PropertyChangedInvokerEventHandler invoker, ref T field, T value, [CallerMemberName] string propertyName = null, params string[] propertyNames)
        {
            if (EqualityComparer <T> .Default.Equals(field, value))
            {
                return(false);
            }

            field = value;
            invoker?.Invoke(propertyName);
            return(true);
        }