本文整理汇总了C#中CommandArgs类的典型用法代码示例。如果您正苦于以下问题:C# CommandArgs类的具体用法?C# CommandArgs怎么用?C# CommandArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommandArgs类属于命名空间,在下文中一共展示了CommandArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public async void Run(CommandArgs e)
{
if(!File.Exists(filePath))
{
MessageBox.Show(
$"Script File was not found. Please check if file exists: {Path.GetFullPath(filePath)}"
);
return;
}
var script = CSharpScript.Create(
File.ReadAllText(filePath),
_scriptOption,
typeof(ApiHolder)
);
if(!CheckScriptValidity(script))
{
MessageBox.Show(
$"Detected compile error. Please check log file: {Path.GetFullPath(errorLogPath)}"
);
return;
}
var mmm = new ApiHolder(new ScriptPluginApi(Scene, ApplicationForm));
await script.RunAsync(mmm);
}
示例2: Execute
public Response.IResponse Execute( CommandArgs args )
{
var pa = args.As<renameArgs>();
if( string.IsNullOrWhiteSpace( pa.target ) )
return new Response.ErrorResponse( "target not specified" );
// get volume for our target
var vol = _volumeManager.GetByHash( pa.target );
if( vol == null )
return new Response.ErrorResponse( "invalid target" );
// rename this object and change first if this is directory or a file
var dirToChange = vol.GetDirectoryByHash( pa.target );
if( dirToChange == null )
{
var fileToChange = vol.GetFileByHash( pa.target );
if( fileToChange == null )
return new Response.ErrorResponse( "target not found" );
var newFile = vol.RenameFile( fileToChange, pa.name );
if( newFile == null )
return new Response.ErrorResponse( "errRename" );
return new Response.RenameResponse( pa.target, newFile );
}
else
{
var newDir = vol.RenameDirectory( dirToChange, pa.name );
if( newDir == null )
return new Response.ErrorResponse( "errRename" );
return new Response.RenameResponse( pa.target, newDir );
}
}
示例3: Execute
public void Execute(CommandArgs args)
{
LoadAllTransactions();
ConvertTodayPaymentsToPending();
//WriteAllTransactionsToWorsheets();
ShowSplashWindow();
}
示例4: Execute
public Response.IResponse Execute( CommandArgs args )
{
var pa = args.As<parentsArgs>();
if( string.IsNullOrWhiteSpace( pa.target ) )
return new Response.ErrorResponse( "target not specified" );
// get volume for our target
var vol = _volumeManager.GetByHash( pa.target );
// try to get directory for our target
var cwd = ( vol != null ? vol.GetDirectoryByHash( pa.target ) : null );
// if we still haven't got volume service, then something is wrong
if( cwd == null || cwd.IsReadable.IsFalse() )
return new Response.ErrorResponse( "target dir not found or access denied" );
HashSet<Model.DirectoryModel> tree = new HashSet<Model.DirectoryModel>();
tree.Add( cwd );
var rootDir = vol.GetRootDirectory();
// now get parent untill we reach root
while( cwd != null && cwd.Hash != rootDir.Hash )
{
if( cwd.ParentHash == null )
break;
var parentDir = vol.GetDirectoryByHash( cwd.ParentHash );
if( parentDir == null )
return new Response.ErrorResponse( "error getting parent dir: not found or access denied" );
tree.Add( parentDir );
var subDirs = vol.GetSubdirectoriesFlat( parentDir, 0 );
foreach( var sd in subDirs )
tree.Add( sd );
cwd = parentDir;
}
return new Response.TreeResponse( tree.ToArray() );
}
示例5: Parse
public string Parse(MessageSource sender, CommandArgs args)
{
if(args.Args.Count != 2)
{
return String.Format("Error - Usage {0} <stream-name> <stream-url>", args.Name);
}
var name = args.Args[0];
var url = args.Args[1];
Logger.InfoFormat("{0} is adding a new stream. {1} - {2}", sender, name, url);
if(_handler.GetStream(name) != null) {
return "Error - A streamer already exists with that name";
}
if( !_handler.AddStream(name, url) )
{
// Yeah yeah, it's hacky.
_handler.RemoveAll(a => a.Name == name);
return "Error - The URL provided can not be handled by any stream plugins.";
}
_settings.AddStream(name, url);
Logger.InfoFormat("{0} added a new stream. {1} - {2}", sender, name, url);
return string.Format("Success, {0} added as a new streamer", name);
}
示例6: Execute
public Response.IResponse Execute( CommandArgs args )
{
var ra = args.As<rmArgs>();
if( ra.targets == null || ra.targets.Length == 0 )
return new Response.ErrorResponse( "target(s) not specified" );
IList<string> removeHashes = new List<string>();
foreach( var toRemove in ra.targets )
{
var vol = _volumeManager.GetByHash( toRemove );
if( vol == null )
continue;
var dirToRemove = vol.GetDirectoryByHash( toRemove );
if( dirToRemove == null )
{
var fileToRemove = vol.GetFileByHash( toRemove );
if( fileToRemove == null )
continue;
if( vol.DeleteFile( fileToRemove ) )
removeHashes.Add( toRemove );
}
else
{
if( vol.DeleteDirectory( dirToRemove ) )
removeHashes.Add( toRemove );
}
}
return new Response.RmResponse( removeHashes.ToArray() );
}
示例7: Start
public static void Start(CommandArgs args)
{
var server = args.Read<string>();
var alias = args.Read<string>();
ConsoleManager.Start(server, alias, $"--alias {alias}");
}
示例8: OnCommand
protected override void OnCommand(CommandArgs e)
{
switch (e.Command)
{
case "navigate":
if (e.Data["day"] != null)
{
StartDate = (DateTime)e.Data["day"];
}
Update(CallBackUpdateType.Full);
break;
case "refresh":
Update(CallBackUpdateType.Full);
break;
case "selected":
if (SelectedEvents.Count > 0)
{
EventInfo ei = SelectedEvents[0];
SelectedEvents.RemoveAt(0);
UpdateWithMessage("Event removed from selection: " + ei.Text);
}
break;
}
}
示例9: Execute
public void Execute(CommandArgs args)
{
var sidePanelArg = args as SidePanelCommandArgs;
if (sidePanelArg == null)
{
return;
}
if (sidePanelArg.WpfControl != null) _host.CurrentControl = sidePanelArg.WpfControl;
if (sidePanelArg.Model != null) _host.Model = sidePanelArg.Model;
_host.Refresh();
_host.Show();
//todo: only for tests
var svc = new SummaryCalculationService();
var currentMonthBalance = svc.CalculateBalanceForCurrentMonth(sidePanelArg.Transactions);
var incomesUpToDate = svc.CalculateIncomesForCurrentMonthUpToGivenDate(sidePanelArg.Transactions, SystemTime.Now());
var expensesUpToDate = svc.CalculateExpensesForCurrentMonthUpToGivenDate(sidePanelArg.Transactions, SystemTime.Now());
var accountSummary = svc.CalculateAccountSummary(sidePanelArg.Accounts,
sidePanelArg.Transactions);
Singleton<MainStatusAppService>.Instance.EndOfMonthBalance = currentMonthBalance;
Singleton<MainStatusAppService>.Instance.IncomesUpToDate = incomesUpToDate;
Singleton<MainStatusAppService>.Instance.ExpensesUpToDate = expensesUpToDate;
Singleton<MainStatusAppService>.Instance.AccountSummary = accountSummary;
}
示例10: Execute
public void Execute(CommandArgs commandArgs)
{
// ミュート
pecaPlayer.Mute = true;
// 終了時のリレー切断
if (PlayerSettings.DisconnectRealyOnClose)
{
pecaPlayer.DisconnectRelay();
}
// 終了時の位置とサイズを保存
if (PlayerSettings.SaveReturnPositionOnClose)
{
PlayerSettings.ReturnPosition = form.Location;
}
if (PlayerSettings.SaveReturnSizeOnClose)
{
PlayerSettings.ReturnSize = pecaPlayer.Size;
}
try
{
PlayerSettings.Save();
}
catch (Exception e)
{
Logger.Instance.Error(e.Message);
}
Application.Exit();
}
示例11: Parse
public string Parse(MessageSource sender, CommandArgs args)
{
Stream stream;
if(args.Args.Count != 0)
{
if(!sender.Permission.IsOperator)
{
return string.Format("Error - usage {0}. Operators may force updates of other streamers", args.Name);
}
stream = _handler.GetStream(args.Args[0]);
if (stream == null)
{
return "Sorry no streamer exists with that name.";
}
}
else
{
stream = _handler.GetStream(sender.Nickname);
if (stream == null)
{
return "Sorry you don't seem to own a stream.";
}
}
Logger.Info("Manual update for " + stream.Name);
stream.Update(_handler);
return "Updating " + stream.Name;
}
示例12: Execute
public void Execute(CommandArgs commandArgs)
{
// 非表示ミュート
form.Visible = false;
pecaPlayer.Mute = true;
// 終了時のリレー切断
if (PlayerSettings.DisconnectRealyOnClose)
{
pecaPlayer.DisconnectRelay();
}
// 終了時の位置とサイズを保存
if (PlayerSettings.SaveReturnPositionOnClose)
{
PlayerSettings.ReturnPosition = form.Location;
}
if (PlayerSettings.SaveReturnSizeOnClose)
{
PlayerSettings.ReturnSize = pecaPlayer.Size;
}
PlayerSettings.Save();
Application.Exit();
}
示例13: HandlePossibleTypingCommand
private void HandlePossibleTypingCommand(CommandArgs args, Action nextHandler, Action<SnapshotSpan> actionIfInsideActiveSpan)
{
if (_renameService.ActiveSession == null)
{
nextHandler();
return;
}
var selectedSpans = args.TextView.Selection.GetSnapshotSpansOnBuffer(args.SubjectBuffer);
if (selectedSpans.Count > 1)
{
// If we have multiple spans active, then that means we have something like box
// selection going on. In this case, we'll just forward along.
nextHandler();
return;
}
var singleSpan = selectedSpans.Single();
SnapshotSpan containingSpan;
if (_renameService.ActiveSession.TryGetContainingEditableSpan(singleSpan.Start, out containingSpan) &&
containingSpan.Contains(singleSpan))
{
actionIfInsideActiveSpan(containingSpan);
}
else
{
// It's in a read-only area, so let's commit the rename and then let the character go
// through
CommitIfActiveAndCallNextHandler(args, nextHandler);
}
}
示例14: if
void IShortcutCommand.Execute(CommandArgs commandArgs)
{
// ウィンドウ状態が通常の場合にのみ実行する
if (form.WindowState != FormWindowState.Normal)
{
return;
}
ScreenSplitCommandArgs args = (ScreenSplitCommandArgs)commandArgs;
// 分割サイズを設定
if (args.WidthNum > 0)
{
int formWidth = Screen.GetWorkingArea(form).Width / args.WidthNum;
form.Width = formWidth;
int movieHeight = (int)(pecaPlayer.Width / pecaPlayer.AspectRate);
pecaPlayer.SetSize(pecaPlayer.Width, movieHeight);
}
else if (args.HeightNum > 0)
{
int formHeight = Screen.GetWorkingArea(form).Height / args.HeightNum;
form.Height = formHeight;
int movieWidth = (int)(pecaPlayer.Height * pecaPlayer.AspectRate);
pecaPlayer.SetSize(movieWidth, pecaPlayer.Height);
}
}
示例15: Parse
public string Parse(MessageSource sender, CommandArgs args)
{
Console.WriteLine(args.Args.Count);
if (args.Args.Count < 1 || args.Args.Count > 2)
{
return String.Format("Error - Usage {0} <hostname> [permission]", args.Name);
}
string permission = "Operator";
if(args.Args.Count == 2)
{
permission = args.Args[1];
}
var targetPermission = _settings.GetUserPermission(args.Args[0]);
// A permission already exists for the target user
if (targetPermission != null)
{
return "This hostname already has permissions attached.";
}
var perm = Permission.GetPermission(permission);
if(perm == null)
{
return "No permission exists by that name";
}
_settings.AddUserPermission(args.Args[0], perm);
return String.Format("Added permissions for {0}.", args.Args[0]);
}