/// <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>
        internal static void UpdateDefaultableValueIfValuesDiffer(
            StringOrNone existingValue, StringOrNone newValue,
            DefaultableValue<StringOrNone> defaultableValueToUpdate)
        {
            if (null == newValue)
            {
                // user exited drop-down without selecting anything
                return;
            }

            if (existingValue.Equals(newValue))
            {
                // no change in value - so just return
                return;
            }
            else
            {
                // 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
                var valueToSet = (StringOrNone.NoneValue.Equals(newValue) ? null : newValue);
                var cmd =
                    new UpdateDefaultableValueCommand<StringOrNone>(defaultableValueToUpdate, valueToSet);
                var cpc = PropertyWindowViewModelHelper.GetCommandProcessorContext();
                CommandProcessor.InvokeSingleCommand(cpc, cmd);
            }
        }
Exemplo n.º 2
0
 protected override void PreParse()
 {
     ClearEFObject(_localName);
     _localName = null;
     base.PreParse();
 }