Some refactor ideas

This commit is contained in:
soukoku
2014-04-05 16:48:28 -04:00
parent 4fa3e77fba
commit 67c6705224
49 changed files with 183 additions and 163 deletions

67
NTwain/ITwainState.cs Normal file
View File

@@ -0,0 +1,67 @@
using NTwain.Data;
using NTwain.Triplets;
using System;
using System.ComponentModel;
namespace NTwain
{
/// <summary>
/// Interface for keeping track of current TWAIN state with current app and source ids.
/// </summary>
public interface ITwainState : INotifyPropertyChanged
{
/// <summary>
/// Gets the app id used for the session.
/// </summary>
/// <value>The app id.</value>
TWIdentity AppId { get; }
/// <summary>
/// Gets the source id used for the session.
/// </summary>
/// <value>The source id.</value>
TWIdentity SourceId { get; }
/// <summary>
/// Gets the current state number as defined by the TWAIN spec.
/// </summary>
/// <value>The state.</value>
int State { get; }
}
/// <summary>
/// Internal interface for state management.
/// </summary>
interface ITwainStateInternal : ITwainState
{
/// <summary>
/// Gets or sets a value indicating whether calls to triplets will verify the current twain session state.
/// </summary>
/// <value>
/// <c>true</c> if state value is enforced; otherwise, <c>false</c>.
/// </value>
bool EnforceState { get; set; }
/// <summary>
/// Changes the state right away.
/// </summary>
/// <param name="newState">The new state.</param>
/// <param name="notifyChange">if set to <c>true</c> to notify change.</param>
void ChangeState(int newState, bool notifyChange);
/// <summary>
/// Gets the pending state changer and tentatively changes the session state to the specified value.
/// Value will only stick if committed.
/// </summary>
/// <param name="newState">The new state.</param>
/// <returns></returns>
ICommitable GetPendingStateChanger(int newState);
void ChangeSourceId(TWIdentity sourceId);
}
interface ICommitable : IDisposable
{
void Commit();
}
}