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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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;
        }
    }
}