Exemple #1
0
        /// <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);
            }
        }
        private static void SetEndNavigationProperty(NavigationProperty navProp, string value)
        {
            var     cpc = PropertyWindowViewModelHelper.GetCommandProcessorContext();
            Command c   = new EntityDesignRenameCommand(navProp, value, true);
            var     cp  = new CommandProcessor(cpc, c);

            cp.Invoke();
        }
        private static void SetEndRole(AssociationEnd end, string value)
        {
            var     cpc = PropertyWindowViewModelHelper.GetCommandProcessorContext();
            Command c   = new ChangeAssociationEndCommand(end, null, value);
            var     cp  = new CommandProcessor(cpc, c);

            cp.Invoke();
        }
        private static void SetEndOnDelete(AssociationEnd end, string value)
        {
            var cpc = PropertyWindowViewModelHelper.GetCommandProcessorContext();

            if (end.OnDeleteAction != null &&
                value == ModelConstants.OnDeleteAction_None)
            {
                DeleteEFElementCommand.DeleteInTransaction(cpc, end.OnDeleteAction);
            }
            else if (end.OnDeleteAction == null &&
                     value == ModelConstants.OnDeleteAction_Cascade)
            {
                CommandProcessor.InvokeSingleCommand(cpc, new CreateOnDeleteActionCommand(end, value));
            }
        }