本文整理汇总了C#中CommandDelegate类的典型用法代码示例。如果您正苦于以下问题:C# CommandDelegate类的具体用法?C# CommandDelegate怎么用?C# CommandDelegate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommandDelegate类属于命名空间,在下文中一共展示了CommandDelegate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CommandWrapper
public CommandWrapper(CommandDelegate del)
{
if (del == null) {
throw new ArgumentNullException ("del");
}
this.d = del;
}
示例2: Command
public Command(CommandDelegate cmd, params string[] names)
{
if (names == null || names.Length < 1)
throw new NotSupportedException();
permission = null;
Names = new List<string>(names);
command = cmd;
}
示例3: Register
public bool Register(string Cmd, CommandDelegate Func)
{
if (!Cmds.ContainsKey(Cmd))
Cmds.Add(Cmd, Func);
else
return false;
return true;
}
示例4: Add
/// <summary>
/// Add a command to be executed in parallel.
/// </summary>
/// <param name="command">
/// The command to execute. Should be non-null.
/// </param>
/// <exception cref="System.ArgumentNullException"></exception>
public void Add(CommandDelegate command)
{
if (command == null) {
throw new System.ArgumentNullException("command");
}
CommandQueue queue = new CommandQueue();
queue.Enqueue(command);
_queues.AddLast(queue);
}
示例5: SchumixRegisterHandler
public void SchumixRegisterHandler(string code, CommandDelegate method, CommandPermission permission = CommandPermission.Normal)
{
if(sIgnoreCommand.IsIgnore(code))
return;
if(CommandMethodMap.ContainsKey(code.ToLower()))
CommandMethodMap[code.ToLower()].Method += method;
else
CommandMethodMap.Add(code.ToLower(), new CommandMethod(method, permission));
}
示例6: AddCommand
/// <summary>
/// Add a command to those which can be invoked from the console.
/// </summary>
/// <param name = "command">The string that will make the command execute</param>
/// <param name = "commandHelp">The message that will show the user how to use the command</param>
/// <param name = "info">Any information about how the command works or what it does</param>
/// <param name = "fn"></param>
public void AddCommand(string command, string commandHelp, string infomessage, CommandDelegate fn)
{
CommandInfo info = new CommandInfo{
command = command,
commandHelp = commandHelp,
info = infomessage,
fn = new List<CommandDelegate> {fn}
};
tree.AddCommand(info);
}
示例7: RegisterCommandHandler
public static void RegisterCommandHandler(string command, CommandDelegate handler)
{
try
{
handlers.Add(command, handler);
}
catch (ArgumentException)
{
Debug.Log("An element with Key = " + command + " already exists.");
}
}
示例8: AddCommand
/// <summary>
/// Add a command to those which can be invoked from the console.
/// </summary>
/// <param name="command">The string that will make the command execute</param>
/// <param name="commandHelp">The message that will show the user how to use the command</param>
/// <param name="infomessage">Any information about how the command works or what it does</param>
/// <param name="fn"></param>
/// <param name="requiresAScene">Whether this command requires a scene to be fired</param>
/// <param name="fireOnceForAllScenes">Whether this command will only be executed once if there is no current scene</param>
public void AddCommand (string command, string commandHelp, string infomessage, CommandDelegate fn, bool requiresAScene, bool fireOnceForAllScenes)
{
CommandInfo info = new CommandInfo {
command = command,
commandHelp = commandHelp,
info = infomessage,
fireOnceForAllScenes = fireOnceForAllScenes,
requiresAScene = requiresAScene,
fn = new List<CommandDelegate> { fn }
};
tree.AddCommand (info);
}
示例9: Command
public Command(CommandDelegate cmd, params string[] names)
{
if (cmd == null)
throw new ArgumentNullException("cmd");
if (names == null || names.Length < 1)
throw new ArgumentException("names");
AllowServer = true;
CommandDelegate = cmd;
DoLog = true;
HelpText = "No help available.";
Names = new List<string>(names);
Permissions = new List<string>();
}
示例10: Database
/// <summary>
/// Creates instance of EJDB.
/// </summary>
/// <param name="library"></param>
public Database(Library library)
{
var libraryHandle = library.LibraryHandle;
DatabaseHandle = new DatabaseHandle(libraryHandle);
Library = library;
_openDatabase = libraryHandle.GetUnmanagedDelegate<OpenDatabaseDelegate>();
_closeDatabase = libraryHandle.GetUnmanagedDelegate<CloseDatabaseDelegate>();
_isOpen = libraryHandle.GetUnmanagedDelegate<IsOpenDelegate>();
_getErrorCode = libraryHandle.GetUnmanagedDelegate<GetErrorCodeDelegate>();
_getMetadata = libraryHandle.GetUnmanagedDelegate<GetMetaDelegate>();
_command = libraryHandle.GetUnmanagedDelegate<CommandDelegate>();
_sync = libraryHandle.GetUnmanagedDelegate<SyncDelegate>();
}
示例11: ProxyFrame
public ProxyFrame(string[] args)
{
bool externalPlugin = false;
this.args = args;
ProxyConfig proxyConfig = new ProxyConfig("SLProxy", "Austin Jennings / Andrew Ortman", args);
proxy = new Proxy(proxyConfig);
// add delegates for login
proxy.SetLoginRequestDelegate(new XmlRpcRequestDelegate(LoginRequest));
proxy.SetLoginResponseDelegate(new XmlRpcResponseDelegate(LoginResponse));
// add a delegate for outgoing chat
proxy.AddDelegate(PacketType.ChatFromViewer, Direction.Outgoing, new PacketDelegate(ChatFromViewerOut));
// handle command line arguments
foreach (string arg in args)
if (arg == "--log-login")
logLogin = true;
else if (arg.Substring(0, 2) == "--")
{
int ipos = arg.IndexOf("=");
if (ipos != -1)
{
string sw = arg.Substring(0, ipos);
string val = arg.Substring(ipos + 1);
Console.WriteLine("arg '" + sw + "' val '" + val + "'");
if (sw == "--load")
{
externalPlugin = true;
LoadPlugin(val);
}
}
}
commandDelegates["/load"] = new CommandDelegate(CmdLoad);
if (!externalPlugin)
{
ProxyPlugin analyst = new Analyst(this);
analyst.Init();
}
}
示例12: Condition
/// <summary>
/// A Condition command allows branching behaviour. After a condition evaluates to <c>true</c>
/// then onTrue will be evaluated until it finishes. Otherise onFalse will be evaluated, (if it
/// isn't null). When nested in a Repeat command, conditions will be re-evaluated once for every
/// repeat.
/// </summary>
/// <param name="condition">
/// The condition to evaluate. Must be non-null.
/// </param>
/// <param name="onTrue">
/// The command to execute if condition evaluates to true. Must be non-null.
/// </param>
/// <param name="onFalse">
/// The command to execute if condition evaluates to false.
/// </param>
/// <exception cref="System.ArgumentNullException"></exception>
public static CommandDelegate Condition(CommandCondition condition, CommandDelegate onTrue, CommandDelegate onFalse = null)
{
CheckArgumentNonNull(condition, "condition");
CheckArgumentNonNull(onTrue, "onTrue");
CommandDelegate result = onFalse;
return Sequence(
Commands.Do( () => {
result = onFalse;
if (condition()) {
result = onTrue;
}
}),
(ref double deltaTime) => {
if (result != null) {
return result(ref deltaTime);
}
return true;
}
);
}
示例13: Command
public Command(string permissionneeded, CommandDelegate cmd, params string[] names)
: this(cmd, names)
{
Permission = permissionneeded;
}
示例14: InternalCommand
internal InternalCommand( CommandDelegate Command, string Line )
{
command = Command;
line = Line;
}
示例15: FromXml
public void FromXml(XmlElement root, CommandDelegate fn)
{
CommandInfo help = (CommandInfo)((Dictionary<string, object>)tree["help"])[String.Empty];
((Dictionary<string, object>)tree["help"]).Remove(string.Empty);
if (((Dictionary<string, object>)tree["help"]).Count == 0)
tree.Remove("help");
CommandInfo quit = (CommandInfo)((Dictionary<string, object>)tree["quit"])[String.Empty];
((Dictionary<string, object>)tree["quit"]).Remove(string.Empty);
if (((Dictionary<string, object>)tree["quit"]).Count == 0)
tree.Remove("quit");
tree.Clear();
ReadTreeLevel(tree, root, fn);
if (!tree.ContainsKey("help"))
tree["help"] = (object) new Dictionary<string, object>();
((Dictionary<string, object>)tree["help"])[String.Empty] = help;
if (!tree.ContainsKey("quit"))
tree["quit"] = (object) new Dictionary<string, object>();
((Dictionary<string, object>)tree["quit"])[String.Empty] = quit;
}