public static bool SetRefProperty <TProperty>(this IFreezable that, ref TProperty thisProperty, TProperty value) where TProperty : class { if (ReferenceEquals(thisProperty, value)) { return(false); } that.ThrowIfFrozen(); thisProperty = value; return(true); }
public static bool SetValueProperty <TProperty>(this IFreezable that, ref TProperty thisProperty, TProperty value) where TProperty : struct { if (thisProperty.Equals(value)) { return(false); } that.ThrowIfFrozen(); thisProperty = value; return(true); }
public static bool SetValueProperty <TProperty>(this IFreezable that, ref Nullable <TProperty> thisProperty, Nullable <TProperty> value) where TProperty : struct { if (thisProperty.HasValue && value.HasValue && thisProperty.Value.Equals(value.Value)) { return(false); } if (!thisProperty.HasValue && !value.HasValue) { return(false); } that.ThrowIfFrozen(); thisProperty = value; return(true); }
//[System.Diagnostics.DebuggerStepThrough] //[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static bool SetStringProperty(this IFreezable that, ref string thisProperty, string value, string nameOfProperty = null) { //if (value == string.Empty) { value = null; } if (ReferenceEquals(thisProperty, value)) { return(false); } if (string.Equals(thisProperty, value, System.StringComparison.Ordinal)) { return(false); } that.ThrowIfFrozen(nameOfProperty); thisProperty = value; return(true); }