本文整理汇总了C#中IMemento类的典型用法代码示例。如果您正苦于以下问题:C# IMemento类的具体用法?C# IMemento怎么用?C# IMemento使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IMemento类属于命名空间,在下文中一共展示了IMemento类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Build
public IAggregate Build(Type type, Guid id, IMemento snapshot)
{
//if (type == typeof(IMyInterface))
// return new MyAggregate();
//else
return Activator.CreateInstance(type) as IAggregate;
}
示例2:
void IOrginator.SetMemento(IMemento memento)
{
var bankCardMemento = (BankCardMemento)memento;
Id = bankCardMemento.Id;
_accountId = bankCardMemento.AccountId;
_disabled = bankCardMemento.Disabled;
}
示例3: CommandContext
/// <summary>
/// Initializes a new instance of the CommandContext class.
/// </summary>
/// <param name="game">Command context's IGame.</param>
/// <param name="scoreboard">Command context'sIScoreboard.</param>
/// <param name="boardHistory">Command context's IMemento.</param>
public CommandContext(IGame game, IScoreboard scoreboard, IMemento boardHistory)
{
this.Game = game;
this.ScoreboardInfo = scoreboard;
this.BoardHistory = boardHistory;
this.Moves = 0;
}
示例4: Build
public IAggregate Build(Type type, Guid id, IMemento snapshot)
{
ConstructorInfo constructor = type.GetConstructor(
BindingFlags.NonPublic | BindingFlags.Instance, null, new[] { typeof(Guid) }, null);
return constructor.Invoke(new object[] { id }) as IAggregate;
}
示例5: Build
public IAggregate Build(Type type, Guid id, IMemento snapshot)
{
var types = snapshot == null ? new[] { typeof(Guid) } : new[] { typeof(Guid), typeof(IMemento) };
var args = snapshot == null ? new object[] { id } : new object[] { id, snapshot };
ConstructorInfo constructor = type.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, types, null);
return constructor.Invoke(args) as IAggregate;
}
示例6: SetMemento
protected override void SetMemento(IMemento memento)
{
var productMemento = (ProductMemento)memento;
Id = productMemento.Id;
Version = productMemento.Version;
Name = productMemento.Name;
Price = new Money(productMemento.Price);
}
示例7: RestoreSnapshot
void IAmRestorable.RestoreSnapshot(IMemento memento)
{
if (memento == null)
{
return;
}
RestoreSnapshot(memento);
}
示例8: Redo
/// <summary>
/// Redo 操作を実行し、データを取得します。
/// </summary>
public IMemento Redo()
{
if (!canRedo) return null;
undo.Push(Now);
Now = redo.Pop();
return Now.Clone();
}
示例9: Merge
public bool Merge(IMemento otherMemento) {
TextChangeMemento other = otherMemento as TextChangeMemento;
if (other != null) {
if (other.textContainer.Equals(textContainer)) {
// Match, do not store anything as the initial state is what we want.
return true;
}
}
return false;
}
示例10: Merge
public bool Merge(IMemento otherMemento) {
DrawableContainerBoundsChangeMemento other = otherMemento as DrawableContainerBoundsChangeMemento;
if (other != null) {
if (Objects.CompareLists<IDrawableContainer>(listOfdrawableContainer, other.listOfdrawableContainer)) {
// Lists are equal, as we have the state already we can ignore the new memento
return true;
}
}
return false;
}
示例11: RestoreSnapshot
protected override void RestoreSnapshot(IMemento memento)
{
var portfolioMemento = (PortfolioMemento)memento;
isOpen = portfolioMemento.IsOpen;
foreach (var accountSnapshot in portfolioMemento.Accounts)
{
accounts.Add(RestoreEntity<Account>(accountSnapshot));
}
}
示例12: Merge
public bool Merge(IMemento otherMemento) {
ChangeFieldHolderMemento other = otherMemento as ChangeFieldHolderMemento;
if (other != null) {
if (other.drawableContainer.Equals(drawableContainer)) {
if (other.fieldToBeChanged.Equals(fieldToBeChanged)) {
// Match, do not store anything as the initial state is what we want.
return true;
}
}
}
return false;
}
示例13: Build
public IAggregate Build(Type type, Guid id, IMemento snapshot)
{
ConstructorInfo constructor = type.GetConstructor(
BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] {typeof (Guid)}, null);
if (constructor == null)
{
throw new InvalidOperationException(
string.Format("Aggregate {0} cannot be created: constructor with only id parameter not provided",
type.Name));
}
return constructor.Invoke(new object[] {id}) as IAggregate;
}
示例14: MigrateSettings
public static void MigrateSettings(bool createTargetCategoryAndFields,
bool migrateFieldValues,
IMemento newState,
IMemento oldState)
{
Migrator migrator = new Migrator();
if (createTargetCategoryAndFields)
{
migrator.EnsureTargetCategory(newState.CategoryName);
migrator.EnsureFields(newState.CategoryName, new MigrationInfo(oldState, newState).AllFields);
}
if (migrateFieldValues)
{
migrator.Migrate(new MigrationInfo(oldState, newState));
}
}
示例15: MainForm
public MainForm( )
{
_memento = ObjectFactory.GetInstance<IMemento>() ;
_model = ObjectFactory.GetInstance<IModel>() ;
InitializeComponent();
_model.ActiveLayerChanged += activeLayerChanged ;
_model.NewModelLoaded += newModelLoaded ;
_model.OnBeforeUnloadingModel += modelUnloading ;
_memento.OnCommandEnded += mementoCommandEnded ;
_memento.OnCommandUndone += mementoCommandUndone;
_memento.OnCommandRedone += mementoCommandRedone;
uiAssetsControl.AssetChosenByDoubleClicking += assetChosenByDoubleClicking ;
}