aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Synchronization/Diff.cs
blob: 1ae3541e8d90c87afa914b195a8ac1c7135749da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tango.Synchronization
{
    /// <summary>
    /// Represents an <see cref="IDBComparer.Compare"/> result.
    /// </summary>
    public class Diff
    {
        private Action _action;

        /// <summary>
        /// Gets the action which will be taken in order to commit this difference.
        /// </summary>
        public DiffAction Action { get; private set; }

        /// <summary>
        /// Gets the difference description.
        /// </summary>
        public String Description { get; private set; }

        /// <summary>
        /// Gets the <see cref="Commit"/> SQL command.
        /// </summary>
        public String Command { get; private set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="Diff"/> class.
        /// </summary>
        /// <param name="diffAction">The difference action type.</param>
        /// <param name="description">The action description.</param>
        /// <param name="action">The action delegate.</param>
        /// <param name="command">The SQL command.</param>
        public Diff(DiffAction diffAction, String description, Action action, String command)
        {
            Action = diffAction;
            Description = description;
            _action = action;
            Command = command;
        }

        /// <summary>
        /// Commits this difference to the target DB.
        /// </summary>
        public void Commit()
        {
            _action();
        }

        /// <summary>
        /// Returns a <see cref="System.String" /> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String" /> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            return Command;
        }
    }
}