public override string GetElementKey(
     Dictionary <string, MetadataElementLoader> childrenLoaders,
     XmlElement srcChild,
     MergeAction mergeAction)
 {
     return(srcChild.Name + ":" + XmlUtils.GetOwnText((XmlNode)srcChild));
 }
        private ToolStrip GetChildToolMenu(IPopup childMenuSettings, MergeAction mergeAction)
        {
            ToolStrip toolStrip1 = new System.Windows.Forms.ToolStrip();
            toolStrip1.RenderMode = ToolStripRenderMode.Professional;
            toolStrip1.CanOverflow = false;
            toolStrip1.Font = new System.Drawing.Font("Tahoma", 8, FontStyle.Regular);
            toolStrip1.GripStyle = ToolStripGripStyle.Visible; // перемещение
            toolStrip1.LayoutStyle = ToolStripLayoutStyle.HorizontalStackWithOverflow;
            toolStrip1.ImageScalingSize = new System.Drawing.Size(32, 32);
            toolStrip1.BackColor = System.Drawing.SystemColors.ActiveBorder;
            toolStrip1.Name = childMenuSettings.tittle;
            toolStrip1.AllowMerge = true;
            for (int i = 0; i < childMenuSettings.items.Count; i++)
            {

                ToolStripButton toolStripButton = new ToolStripButton();
                toolStripButton.ImageScaling = ToolStripItemImageScaling.SizeToFit;
                toolStripButton.Image = childMenuSettings.items[i].image;
                toolStripButton.AutoSize = true;
                toolStripButton.ToolTipText = childMenuSettings.items[i].tittle;
                toolStripButton.Margin = new Padding(1, 1, 1, 3);
                toolStripButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(128)))));
                toolStripButton.MergeAction = mergeAction;
                toolStripButton.Tag = childMenuSettings.items[i];
                toolStripButton.Click += (t, e) => {
                    IItem button = ((t as ToolStripButton).Tag) as IItem;
                    button.sendClickItem();
                };
                toolStripButton.Name = childMenuSettings.tittle + i.ToString();
                toolStrip1.Items.Add(toolStripButton);

            }

            return toolStrip1;
        }
 public override string GetElementKey(
     Dictionary <string, MetadataElementLoader> childrenLoaders,
     XmlElement srcChild,
     MergeAction mergeAction)
 {
     return(srcChild.Name);
 }
        public MergeActionOptions <T> Insert()
        {
            var typeMeta = TypeMeta.Get <T>();

            Action = MergeAction.Insert;
            ColumnsByPropertyInfo(typeMeta.PropertiesExceptKeyAndComputed);

            return(this);
        }
Exemple #5
0
        public override string GetElementKey(
            Dictionary <string, MetadataElementLoader> childrenLoaders,
            XmlElement srcChild,
            MergeAction mergeAction)
        {
            string attr = XmlUtils.GetAttr((XmlNode)srcChild, "name", (string)null);

            return(attr == null ? (string)null : srcChild.Name + ":" + attr);
        }
 public ComparisonObject(
     ComparisonObjectType comparisonObjectType,
     ComparisonObjectStatus status,
     TabularObject sourceObject,
     TabularObject targetObject,
     MergeAction mergeAction) : base(comparisonObjectType, status, mergeAction)
 {
     _sourceObject = sourceObject;
     _targetObject = targetObject;
 }
Exemple #7
0
 /// <summary>
 /// Initializes a new instance of the ComparisonObject class using multiple parameters.
 /// </summary>
 /// <param name="comparisonObjectType">Type of ComaprisonObject such as Table, Measure, Relationship, etc.</param>
 /// <param name="status">Status of ComaprisonObject such as Same Definition, Different Definitions and Missing In Target.</param>
 /// <param name="mergeAction">Action of ComaprisonObject such as Create, Update, Delete and Skip.</param>
 public ComparisonObject(
     ComparisonObjectType comparisonObjectType,
     ComparisonObjectStatus status,
     MergeAction mergeAction)
 {
     _comparisonObjectType = (comparisonObjectType == ComparisonObjectType.Connection ? ComparisonObjectType.DataSource : comparisonObjectType); //Need to support connection for backwards compatibility when deserializing from xml
     _status                 = status;
     _mergeAction            = mergeAction;
     _childComparisonObjects = new List <ComparisonObject>();
 }
        public MergeActionOptions <T> Update()
        {
            var typeMeta = TypeMeta.Get <T>();

            Action = MergeAction.Update;
            ColumnsByPropertyInfo(typeMeta.PropertiesExceptKeyAndComputed);
            CheckConditionOnColumns();

            return(this);
        }
        public void Dirty_delete_resolves_with_delete()
        {
            var action = new MergeAction<object>(MergeKind.DirtyDelete, A.Dummy<object>(), null, null);
            var p = new LastWriteWinsAttribute(true);

            p.Merge(action);

            Assert.IsTrue(p.DoesLastWriteWin);
            Assert.AreEqual(MergeActionResult.Delete, action.Result);
            Assert.AreEqual(null, action.ResolvedValue);
        }
        public void Merge_delete_on_hidden_delete_results_in_noop_resolution()
        {
            var action = new MergeAction<object>(MergeKind.HiddenDelete, A.Dummy<object>(), null, null);
            var p = new LastWriteWinsAttribute(true);

            p.Merge(action);

            Assert.IsTrue(p.DoesLastWriteWin);
            Assert.AreEqual(MergeActionResult.Resolved, action.Result);
            Assert.AreEqual(null, action.ResolvedValue);
        }
        public void Dirty_update_resolves_with_update()
        {
            var update = A.Dummy<object>();
            var action = new MergeAction<object>(MergeKind.ConflictingUpdate, A.Dummy<object>(), null, update);
            var p = new LastWriteWinsAttribute(true);

            p.Merge(action);

            Assert.IsTrue(p.DoesLastWriteWin);
            Assert.AreEqual(MergeActionResult.Update, action.Result);
            Assert.AreEqual(update, action.ResolvedValue);
        }
        public void Rejects_Auto_Actions()
        {
            var action = new MergeAction<object>(MergeKind.Auto,null,null,null);
            var p = new LastWriteWinsAttribute(true);

            ExceptionAssert.Throws<NotSupportedException>(() => p.Merge(action));


            Assert.IsTrue(p.DoesLastWriteWin);
            Assert.AreEqual(MergeActionResult.Unresolved, action.Result);
            Assert.IsFalse(action.Resolved);
        }
        public void Merge_update_on_hidden_delete_results_in_create_resolution()
        {
            var restoreWith = A.Dummy<object>();

            var action = new MergeAction<object>(MergeKind.HiddenDelete, A.Dummy<object>(), null, restoreWith);
            var p = new LastWriteWinsAttribute(true);

            p.Merge(action);

            Assert.IsTrue(p.DoesLastWriteWin);
            Assert.AreEqual(MergeActionResult.Create, action.Result);
            Assert.AreEqual(restoreWith, action.ResolvedValue);
        }
Exemple #14
0
        public override string GetElementKey(
            Dictionary <string, MetadataElementLoader> childrenLoaders,
            XmlElement srcChild,
            MergeAction mergeAction)
        {
            string attr1 = XmlUtils.GetAttr((XmlNode)srcChild, "name", (string)null);
            string attr2 = XmlUtils.GetAttr((XmlNode)srcChild, "id", (string)null);

            if (attr1 == null && attr2 == null)
            {
                return((string)null);
            }
            string key = srcChild.Name + ":" + attr1 + ":" + attr2;

            return(mergeAction != MergeAction.Supplement || !childrenLoaders.ContainsKey(key) ? key : (string)null);
        }
Exemple #15
0
    /// <summary>
    /// tes3cmd multipatch
    /// Merge LEVI and LEVC
    /// </summary>
    /// <exception cref="Exception"></exception>
    private static void Multipatch()
    {
        using var ssw = new ScopedStopwatch();

        MergeAction.Merge(
            new MergeAction.Settings(
                true,
                new List <string>()
        {
            "LEVI", "LEVC", "CREA", "CELL"
        },
                null,
                Util.EPatch.All,
                false,
                true,
                "multipatch.esp"));
    }
Exemple #16
0
        private void StartDrag(PointerEventInfo info, ILevelGeometry viewport, MergeAction action)
        {
            TileCoord location = TileLocation(info);

            int x = (int)(location.X * Layer.TileWidth);
            int y = (int)(location.Y * Layer.TileHeight);

            _band           = new RubberBand(new Point(location.X, location.Y));
            _selectionAnnot = new SelectionAnnot(new Point((int)info.X, (int)info.Y))
            {
                Fill = new SolidColorBrush(new Color(76, 178, 255, 128)),
            };

            _annots.Add(_selectionAnnot);
            _action      = UpdateAction.Box;
            _mergeAction = action;

            StartAutoScroll(info, viewport);
        }
Exemple #17
0
 public ComparisonObject(
     ComparisonObjectType comparisonObjectType,
     ComparisonObjectStatus status,
     ITabularObject sourceObject,
     string sourceObjectName,
     string sourceObjectId,
     string sourceObjectDefinition,
     MergeAction mergeAction,
     ITabularObject targetObject,
     string targetObjectName,
     string targetObjectId,
     string targetObjectDefinition) : base(comparisonObjectType, status, mergeAction)
 {
     _sourceObject           = sourceObject;
     _sourceObjectName       = sourceObjectName;
     _sourceObjectId         = sourceObjectId;
     _sourceObjectDefinition = sourceObjectDefinition;
     _targetObject           = targetObject;
     _targetObjectName       = targetObjectName;
     _targetObjectId         = targetObjectId;
     _targetObjectDefinition = targetObjectDefinition;
 }
Exemple #18
0
        public override p4dn.P4MergeStatus Resolve(p4dn.P4MergeData mergeData)
        {
            if (DeferedException != null)
            {
                return(p4dn.P4MergeStatus.CMS_QUIT);
            }
            try
            {
                using (MergeData merger = new MergeData(mergeData))
                {
                    MergeAction action = _callback.ResolveFile(merger);
                    switch (action)
                    {
                    case MergeAction.Quit:
                        return(p4dn.P4MergeStatus.CMS_QUIT);

                    case MergeAction.Skip:
                        return(p4dn.P4MergeStatus.CMS_SKIP);

                    case MergeAction.AcceptEdit:
                        return(p4dn.P4MergeStatus.CMS_EDIT);

                    case MergeAction.AcceptMerged:
                        return(p4dn.P4MergeStatus.CMS_MERGED);

                    case MergeAction.AcceptTheirs:
                        return(p4dn.P4MergeStatus.CMS_THEIRS);

                    case MergeAction.AcceptYours:
                        return(p4dn.P4MergeStatus.CMS_YOURS);
                    }
                }
            }
            catch (Exception e)
            {
                DeferedException = e;
            }
            return(p4dn.P4MergeStatus.CMS_QUIT);
        }
Exemple #19
0
        public static IList <FieldPairReference> GetFieldPairReferences(
            this MergeAction mergeAction,
            ILogger logger,
            SchemaFile file
            )
        {
            switch (mergeAction)
            {
            case InsertMergeAction insertMergeAction:
                return(insertMergeAction
                       .Source
                       .GetFieldPairReferences(logger, file));

            case UpdateMergeAction updateMergeAction:
                return(updateMergeAction
                       .SetClauses
                       .GetFieldPairs(logger, file));

            default:
                return(new List <FieldPairReference>());
            }
        }
Exemple #20
0
        public static void Evaluate(MergeAction action, Table targetTable, Row row, IOutputSink sink, Scope scope)
        {
            Row GetTargetRow() => row.Sources[EquatableArray.Of(scope.ExpandTableName(new[] { targetTable.Name }))];

            switch (action)
            {
            case InsertMergeAction insert:
                Evaluate(targetTable, insert.Columns, insert.Source, new RowArgument(row), sink, scope);
                return;

            case UpdateMergeAction update:
                Evaluate(update.SetClauses, GetTargetRow(), row, sink, scope);
                return;

            case DeleteMergeAction _:
                var r = GetTargetRow();
                sink.Deleted(r, scope.Env);
                targetTable.Rows.Remove(r);
                return;

            default:
                throw FeatureNotSupportedException.Subtype(action);
            }
        }
        private void StartDrag(PointerEventInfo info, ILevelGeometry viewport, MergeAction action)
        {
            TileCoord location = TileLocation(info);

            int x = (int)(location.X * Layer.TileWidth);
            int y = (int)(location.Y * Layer.TileHeight);

            _band = new RubberBand(new Point(location.X, location.Y));
            _selectionAnnot = new SelectionAnnot(new Point((int)info.X, (int)info.Y))
            {
                Fill = new SolidColorBrush(new Color(76, 178, 255, 128)),
            };

            _annots.Add(_selectionAnnot);
            _action = UpdateAction.Box;
            _mergeAction = action;

            StartAutoScroll(info, viewport);
        }
Exemple #22
0
        /// <summary>
        /// Attempts to combine two forrests of messages.
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public virtual void ZipInto(ref Message other)
        {
            if (this == other)
            {
                throw new ArgumentException("A message cannot be zipped into itself.", "other");
            }

            else if (other == null)
            {
                other = this;
                return;
            }

            else if (this.TargetId.Equals(other.TargetId))
            {
                if (this.Parent != other.Parent && this.Parent != null && other.Parent != null)
                {
                    throw new ArgumentException("Two child messages cannot be zipped if they have different parents.", "other");
                }

                // Attempt to copy this message's information into the other one.
                MergeAction result = this.MergeInto(other);

                switch (result)
                {
                case MergeAction.KeepBothInOrder:
                    // The default action: Insert this message chronologically after the other,
                    // and keep all children and information separately from both messages.
                    // (This is the same as if the messages were unrelated, below.)
                    this.AddOldestPredecessor(other);
                    other = this;
                    break;

                case MergeAction.DiscardOther:
                    // The information in this packet completely replaces that in the other.
                    // The other packet is now useless, so we steal its predecessors.
                    this.AddOldestPredecessor(other.Predecessor);
                    other.Predecessor = null;

                    // We can also recursively merge the children, being careful to copy
                    // from this message into the other to preserve chronological order.
                    this.ZipChildrenInto(other);

                    // Then move the children back to be children of this message.
                    // Disconnect the new children's parent first so InsertChild doesn't complain.
                    if (other.Child != null)
                    {
                        for (Message child = other.Child; child != null; child = child.Predecessor)
                        {
                            child.Parent = null;
                        }
                        this.InsertChild(other.Child);
                        other.Child = null;
                    }

                    // Having copied all children, predecessors, and information,
                    // replace the useless message with this one.
                    other = this;
                    break;

                case MergeAction.DiscardThis:
                    // The information in the other packet is "better" than in this packet,
                    // or the subclass has copied all relavent information to the other.
                    // This packet is now useless.  We can also recursively merge the children.
                    other.AddOldestPredecessor(this.Predecessor);
                    this.Predecessor = null;
                    this.ZipChildrenInto(other);
                    break;

                default:
                    throw new ArgumentException("Invalid MergedAction value returned by MergeInto.");
                }
            }
            else
            {
                // If the messages are unrelated, simply arrange them in chronological order,
                // and keep all children and information separately from both messages.
                // (This is the same as MergeAction.KeepBothInOrder, above.)
                this.AddOldestPredecessor(other);
                other = this;
            }
        }
 public sealed override void Visit(MergeAction node)
 {
     base.Visit(node);
 }
Exemple #24
0
 public ValidationError(MergeAction diff, string message)
 {
     _diff    = diff;
     _message = message;
 }
Exemple #25
0
        /// <summary>
        /// Synchronizes two IEnumerable lists based on a unique property value.
        /// The process uses reflection to get the unique values as strings, and then compares them.
        /// </summary>
        /// <param name="target">The list to update.</param>
        /// <param name="source">The list to synchronize with.</param>
        /// <param name="uniquePropertyName">A primary key name for the record objects associated with the specified list/collection type.</param>
        /// <param name="removeMissingTargetItems">Set true to remove any target items that are not found in the source.</param>
        /// <param name="addMissingSourceItems">Set true to add any source items now found in the target.</param>
        /// <param name="mergeAction">A primary key name for the record objects associated with the specified list/collection type.</param>
        /// <returns></returns>
        public static void SyncCollections <T>(IList <T> target, IEnumerable <T> source, string uniqueFieldOrPropertyName, bool removeMissingTargetItems, bool addMissingSourceItems, MergeAction mergeAction)
            where T : class
        {
            object targetUID, sourceUID;
            bool   tarFieldOrPropFound, srcFieldOrPropFound;
            T      targetItem, sourceItem;

            // ... remove the missing records first to allow reused of existing item locations ...

            if (removeMissingTargetItems || mergeAction != MergeAction.Skip) // ("short circuit" attempt, since this effectively does nothing)
            {
                for (int i = target.Count() - 1; i >= 0; i--)
                {
                    targetItem = target[i];
                    if (targetItem == null)
                    {
                        continue;
                    }
                    tarFieldOrPropFound = Objects.GetFieldOrPropertyValue <object>(targetItem, uniqueFieldOrPropertyName, out targetUID);
                    if (!tarFieldOrPropFound)
                    {
                        throw new Exception("Field or property name '" + uniqueFieldOrPropertyName + "' was not found on object '" + typeof(T).Name + "'.");
                    }

                    sourceItem = GetUniqueCollectionItem(source, uniqueFieldOrPropertyName, targetUID);

                    if (sourceItem != null)
                    {
                        // (target item exists in source collection)
                        if (mergeAction == MergeAction.Merge)
                        {
                            Objects.MergeData(targetItem, sourceItem);
                        }
                        else if (mergeAction == MergeAction.Replace)
                        {
                            target[i] = sourceItem;
                        }
                        continue; // (MergeAction.Remove handled in the second pass below)
                    }

                    // ... not found, or merge action is 'Replace', remove it ...
                    if (removeMissingTargetItems)
                    {
                        target.RemoveAt(i);
                    }
                }
            }

            // ... add any new items in the source list to the target list (in the correct order) ...
            // (an insert index is used in attempts to maintain the same order - assuming the target list came from the same order)

            if (addMissingSourceItems || mergeAction == MergeAction.Remove)
            {
                int itemIndex = -1, insertIndex = 0;
                for (int i = 0; i < source.Count(); i++)
                {
                    sourceItem = source.ElementAt(i);
                    if (sourceItem == null)
                    {
                        continue;
                    }
                    srcFieldOrPropFound = Objects.GetFieldOrPropertyValue <object>(sourceItem, uniqueFieldOrPropertyName, out sourceUID);
                    if (!srcFieldOrPropFound)
                    {
                        throw new Exception("Field or property name '" + uniqueFieldOrPropertyName + "' was not found on object '" + typeof(T).Name + "'.");
                    }

                    targetItem = GetUniqueCollectionItem(target, uniqueFieldOrPropertyName, sourceUID, out itemIndex);

                    if (targetItem != null) // (source exists in the target)
                    {
                        if (mergeAction == MergeAction.Remove)
                        {
                            target.RemoveAt(itemIndex); // (no merge, just delete item)
                        }
                        if (insertIndex > itemIndex)
                        {
                            itemIndex--;             // (move insert location back also)
                        }
                        insertIndex = itemIndex + 1; // (insert next new source item after target item skipped)
                        continue;
                    }

                    // ... not found, add it ...
                    if (addMissingSourceItems)
                    {
                        target.Insert(insertIndex++, sourceItem);
                    }

                    //if (addMissingSourceItems)
                    //{
                    //    if (insertIndex >= target.Count)
                    //        target.Add(sourceItem);
                    //    else
                    //        target.Insert(insertIndex, sourceItem);
                    //    insertIndex++;
                    //}
                }
            }
        }
Exemple #26
0
 private void TestPass(DecaySpanMergeableAttribute step, DateTime current, MergeActionResult expectedResult = MergeActionResult.Update)
 {
     var action = new MergeAction<DateTime>(MergeKind.ConflictingUpdate, DateTime.MaxValue, current, DateTime.MaxValue);
     step.Merge(action);
     Assert.AreEqual(expectedResult, action.Result);
 }
 public sealed override void ExplicitVisit(MergeAction node)
 {
     base.ExplicitVisit(node);
 }
 public override void ExplicitVisit(MergeAction fragment)
 {
     _fragments.Add(fragment);
 }
Exemple #29
0
 public static void Set_MergeAction(this UpgradeHelpers.BasicViewModels.ToolStripItemViewModel _ToolStripItem, MergeAction MergeAction)
 {
     throw new NotImplementedException("This is an automatic generated code, please implement the requested logic.");
 }
Exemple #30
0
 public MergeHistoryItem(MergeAction mergeAction) {
     this.mergeAction = mergeAction;
 }
 public MergeActionOptions <T> Raw(string query)
 {
     Action = MergeAction.Query;
     Query  = query;
     return(this);
 }
 public MergeActionOptions <T> Delete()
 {
     Action = MergeAction.Delete;
     return(this);
 }
        public void Rejects_Unknown_Actions()
        {
            var action = new MergeAction<object>((MergeKind)42, null, null, null);
            var p = new LastWriteWinsAttribute(true);

            ExceptionAssert.Throws<ArgumentException>(() => p.Merge(action));


            Assert.IsTrue(p.DoesLastWriteWin);
            Assert.AreEqual(MergeActionResult.Unresolved, action.Result);
            Assert.IsFalse(action.Resolved);
        }
 public MergeHistoryItem(MergeAction mergeAction)
 {
     MergeAction = mergeAction;
 }
		protected ToolStripItem (string text, Image image, EventHandler onClick, string name)
		{
			this.alignment = ToolStripItemAlignment.Left;
			this.anchor = AnchorStyles.Left | AnchorStyles.Top;
			this.auto_size = true;
			this.auto_tool_tip = this.DefaultAutoToolTip;
			this.available = true;
			this.back_color = Color.Empty;
			this.background_image_layout = ImageLayout.Tile;
			this.can_select = true;
			this.display_style = this.DefaultDisplayStyle;
			this.dock = DockStyle.None;
			this.enabled = true;
			this.fore_color = Color.Empty;
			this.image = image;
			this.image_align = ContentAlignment.MiddleCenter;
			this.image_index = -1;
			this.image_key = string.Empty;
			this.image_scaling = ToolStripItemImageScaling.SizeToFit;
			this.image_transparent_color = Color.Empty;
			this.margin = this.DefaultMargin;
			this.merge_action = MergeAction.Append;
			this.merge_index = -1;
			this.name = name;
			this.overflow = ToolStripItemOverflow.AsNeeded;
			this.padding = this.DefaultPadding;
			this.placement = ToolStripItemPlacement.None;
			this.right_to_left = RightToLeft.Inherit;
			this.bounds.Size = this.DefaultSize;
			this.text = text;
			this.text_align = ContentAlignment.MiddleCenter;
			this.text_direction = DefaultTextDirection;
			this.text_image_relation = TextImageRelation.ImageBeforeText;
			this.visible = true;

			this.Click += onClick;
			OnLayout (new LayoutEventArgs (null, string.Empty));
		}
Exemple #36
0
 public override void ExplicitVisit(MergeAction node) { this.action(node); }