示例#1
0
        /// <summary>
        /// Displays a modal dialog to let the user decide what attribute values should be saved.
        /// </summary>
        /// <param name="toMerge">
        /// The list of element that should be merged prepared in a specialized list.
        /// </param>
        /// <param name="targetList">
        /// The target element list that should later be saved.
        /// </param>
        /// <returns>
        /// The target element list that should be saved with the updated information.
        /// </returns>
        public List <StdElement> PerformAttributeMerge(List <MergeConflict> toMerge, List <StdElement> targetList)
        {
            if (toMerge.Count == 0)
            {
                return(targetList);
            }

            var dataContext = new MergeEntitiesViewModel(toMerge);
            var ui          = new MergeEntities(dataContext);

            if (ui.PerformMerge())
            {
                // get the list of solved merge conflicts
                var merge = from y in dataContext.MergeList select y.Conflict;

                // perform the user selected action
                foreach (var conflict in merge)
                {
                    if (conflict.ActionToDo != MergePropertyAction.CopySourceToTarget)
                    {
                        continue;
                    }

                    var theConflict = conflict;
                    SetPropertyValue(
                        (from x in targetList where x.Id == theConflict.TargetElement.Id select x).FirstOrDefault(),
                        conflict.PathToProperty,
                        conflict.SourcePropertyValue);
                }
            }

            return(targetList);
        }
示例#2
0
 /// <summary>
 ///  Initializes a new instance of the <see cref = "MergeEntities" /> class.
 /// </summary>
 /// <param name="dataContext">Data model to use with this instance</param>
 public MergeEntities(MergeEntitiesViewModel dataContext)
 {
     this.dataContext = dataContext;
     this.InitializeComponent();
 }