aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Synchronization/SqlDiff.cs
blob: b5a274cdc84055e74012a40743247c8dce8104cb (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="SqlDataBaseComparer.Compare"/> result.
    /// </summary>
    public class SqlDiff
    {
        private Action _action;

        /// <summary>
        /// Gets the difference action.
        /// </summary>
        public SqlDiffAction Action { get; private set; }

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

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

        /// <summary>
        /// Initializes a new instance of the <see cref="SqlDiff"/> class.
        /// </summary>
        /// <param name="dataBaseAction">The data base action.</param>
        /// <param name="description">The description.</param>
        /// <param name="action">The action.</param>
        /// <param name="command">The command.</param>
        public SqlDiff(SqlDiffAction dataBaseAction, String description, Action action, String command)
        {
            Action = dataBaseAction;
            Description = description;
            _action = action;
            Command = command;
        }

        /// <summary>
        /// Commits the 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;
        }
    }
}