1
This commit is contained in:
52
Src/Core/Command Pattern/CommandPattern.cs
Normal file
52
Src/Core/Command Pattern/CommandPattern.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Microsoft.SqlServer.Server;
|
||||
|
||||
namespace BITKit.CommandPattern
|
||||
{
|
||||
public interface ICommand
|
||||
{
|
||||
void Execute();
|
||||
void Undo();
|
||||
}
|
||||
public interface ICommandService
|
||||
{
|
||||
ICommand[] Commands { get; }
|
||||
event Action<ICommand> OnExecute;
|
||||
event Action<ICommand> OnClear;
|
||||
event Action<ICommand> OnUndo;
|
||||
event Action<ICommand[]> OnRelease;
|
||||
void Execute(ICommand command);
|
||||
void Undo();
|
||||
void Undo(int count);
|
||||
void Redo();
|
||||
void Trace(ICommand command);
|
||||
void Clear();
|
||||
void Rebuild();
|
||||
void Release();
|
||||
}
|
||||
|
||||
public sealed class CommandSequence:List<ICommand>,IBinarySerialize
|
||||
{
|
||||
public void Read(BinaryReader r)
|
||||
{
|
||||
Clear();
|
||||
var count = r.ReadInt32();
|
||||
for (var i = 0; i <count; i++)
|
||||
{
|
||||
Add(BITBinary.Read(r).As<ICommand>());
|
||||
}
|
||||
}
|
||||
|
||||
public void Write(BinaryWriter w)
|
||||
{
|
||||
w.Write(Count);
|
||||
foreach (var x in this)
|
||||
{
|
||||
BITBinary.Write(w,x);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Src/Core/Command Pattern/CommandPattern.cs.meta
Normal file
11
Src/Core/Command Pattern/CommandPattern.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 348d403129b862f46a56448b4e2e9528
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user