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;
}
}
}