src/Misc/EFTools/XmlCore/UI/ViewModels/PropertyWindow/TypeEditors/NoneOptionListBoxTypeEditor.cs
/// <summary>
///     Helper method to update the DefaultableValue if and only if the value has changed
/// </summary>
/// <param name="existingValue">
///     existing value of attribute (StringOrNone.NoneValue indicates attribute
///     currently does not exist)
/// </param>
/// <param name="newValue">
///     new value of attribute passed into setter (null indicates user did not select
///     anything on the drop-down and so no setting should take place, StringOrNone.NoneValue indicates user
///     selected '(None)' on the drop-down and so attribute should be removed if present)
/// </param>
/// <param name="defaultableValueToUpdate"></param>
Helper method to update the DefaultableValue if and only if the value has changed
Helper method to update the DefaultableValue if and only if the value has changed
internal static void UpdateDefaultableValueIfValuesDiffer(
            StringOrNone existingValue, StringOrNone newValue,
            DefaultableValue<StringOrNone> defaultableValueToUpdate)
        {
            if (null == newValue)
            {
                return;
            }
            if (existingValue.Equals(newValue))
            {
                return;
            }
            else
            {
                var valueToSet = (StringOrNone.NoneValue.Equals(newValue) ? null : newValue);
                var cmd =
                    new UpdateDefaultableValueCommand<StringOrNone>(defaultableValueToUpdate, valueToSet);
                var cpc = PropertyWindowViewModelHelper.GetCommandProcessorContext();
                CommandProcessor.InvokeSingleCommand(cpc, cmd);
            }
        }
internal static void UpdateDefaultableValueIfValuesDiffer ( StringOrNone existingValue , StringOrNone newValue , DefaultableValue < StringOrNone > defaultableValueToUpdate ) { if ( null == newValue ) { return ; } if ( existingValue . Equals ( newValue ) ) { return ; } else { var valueToSet = ( StringOrNone . NoneValue . Equals ( newValue ) ? null : newValue ) ; var cmd = new UpdateDefaultableValueCommand < StringOrNone > ( defaultableValueToUpdate , valueToSet ) ; var cpc = PropertyWindowViewModelHelper . GetCommandProcessorContext ( ) ; CommandProcessor . InvokeSingleCommand ( cpc , cmd ) ; } }
Helper method to update the DefaultableValue if and only if the value has changed
Helper method to update the DefaultableValue if and only if the value has changed
// user exited drop-down without selecting anything // no change in value - so just return // existingValue and valueToSet are different - so update the DefaultableValue // if newValue is NoneValue then set valueToSet to null which will remove the attribute // otherwise use newValue as is
existingValue
StringOrNone
existing value of attribute (StringOrNone.NoneValue indicates attribute
currently does not exist)
existing value of attribute ( StringOrNone . NoneValue indicates attribute currently does not exist )
newValue
StringOrNone
new value of attribute passed into setter (null indicates user did not select
anything on the drop-down and so no setting should take place, StringOrNone.NoneValue indicates user
selected '(None)' on the drop-down and so attribute should be removed if present)
new value of attribute passed into setter ( null indicates user did not select anything on the drop - down and so no setting should take place StringOrNone . NoneValue indicates user selected ' ( None ) ' on the drop - down and so attribute should be removed if present )
defaultableValueToUpdate
DefaultableValue<StringOrNone>
None