本文整理汇总了C#中CommandTarget类的典型用法代码示例。如果您正苦于以下问题:C# CommandTarget类的具体用法?C# CommandTarget怎么用?C# CommandTarget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommandTarget类属于命名空间,在下文中一共展示了CommandTarget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Handle
public override void Handle(CommandTarget target, string type, string[] parameters)
{
if (!target.IsRoom || !Util.IsMod(target) || parameters.Length == 0)
return;
if (!Util.IsValidUsername(parameters[0]))
{
target.Send("Invalid username.");
return;
}
if (!Account.Exists(parameters[0]))
{
target.Send("Account does not exist.");
return;
}
if (Util.IsAdmin(target.Room, parameters[0]))
{
target.Send("Administrators can not be banned.");
return;
}
string sourceUser;
if (target.IsWeb)
sourceUser = target.Connection.Session.Account.Name;
else
sourceUser = string.Format("steam:{0:D}", (ulong)target.SteamId);
Program.Logger.InfoFormat("User '{0}' unbanning '{1}'", sourceUser, parameters[0]);
target.Room.Unban(parameters[0]);
target.Send("Account unbanned.");
}
示例2: Handle
public override void Handle(CommandTarget target, string type, string[] parameters)
{
if (!Util.IsSuperAdmin(target) || parameters.Length < 1)
return;
Program.RoomManager.Broadcast("Broadcast: " + parameters[0]);
}
示例3: Handle
public override void Handle(CommandTarget target, string type, string[] parameters)
{
if (!target.IsWeb || !target.IsRoom || parameters.Length == 0)
return;
if (Program.DelayManager.AddAndCheck(target.Connection, DelayManager.Message))
return;
var username = target.Connection.Session.Account.Name;
var room = target.Room;
if (room.IsBanned(username))
{
target.Send("You are banned from this room.");
return;
}
var line = new StateLine(
Util.GetCurrentTimestamp(),
target.Room.RoomInfo.ShortName,
"Action",
username,
target.Connection.Session.Account.Id.ToString("D"),
"RohBot",
"", "0", "",
string.Format("{0} {1}", username, parameters[0]));
target.Room.SendLine(line);
}
示例4: Handle
public override void Handle(CommandTarget target, string type, string[] parameters)
{
if (!target.IsSession || !target.IsRoom || !(target.Room is MafiaRoom))
return;
var room = (MafiaRoom)target.Room;
var userList = new Packets.UserList();
if (room.IsPlaying)
{
foreach (var player in room.Players)
{
userList.AddUser(player.Alias, "0", "Member", "", "", true);
}
}
else
{
var sessions = Program.SessionManager.List.Where(s => s.Account != null).ToList();
var accounts = sessions.Where(s => s.Room == room.RoomInfo.ShortName).Select(s => s.Account).Distinct(new Account.Comparer());
foreach (var account in accounts)
{
var userId = account.Id.ToString();
userList.AddUser(account.Name, userId, "Member", "", "", true);
}
}
userList.Users = userList.Users.OrderBy(u => u.Name).ToList();
target.Session.Send(userList);
}
示例5: Handle
public override void Handle(CommandTarget target, string type, string[] parameters)
{
if (!target.IsRoom || !Util.IsAdmin(target) || parameters.Length == 0)
return;
if (!Util.IsValidUsername(parameters[0]))
{
target.Send("Invalid username.");
return;
}
if (!Account.Exists(parameters[0]))
{
target.Send("Account does not exist.");
return;
}
if (!target.Room.IsMod(parameters[0]))
{
target.Send("Account is not a mod.");
return;
}
target.Room.Demod(parameters[0]);
target.Send("Account demodded.");
}
示例6: Handle
public override void Handle(Connection connection)
{
// TODO: move implementation here later
var commandTarget = new CommandTarget(connection, Target);
var command = new Commands.Users();
command.Handle(commandTarget, command.Type, new string[0]);
}
示例7: SetUp
public void SetUp()
{
disposables = new CompositeDisposable
{
VirtualClock.Start()
};
clockName = Any.CamelCaseName();
targetId = Any.Word();
target = new CommandTarget(targetId);
store = new InMemoryStore<CommandTarget>(
_ => _.Id,
id => new CommandTarget(id))
{
target
};
CommandSchedulerDbContext.NameOrConnectionString =
@"Data Source=(localdb)\MSSQLLocalDB; Integrated Security=True; MultipleActiveResultSets=False; Initial Catalog=ItsCqrsTestsCommandScheduler";
configuration = new Configuration()
.UseInMemoryCommandScheduling()
.UseDependency<IStore<CommandTarget>>(_ => store)
.UseDependency<GetClockName>(c => _ => clockName)
.TraceScheduledCommands();
scheduler = configuration.CommandScheduler<CommandTarget>();
Command<CommandTarget>.AuthorizeDefault = (commandTarget, command) => true;
disposables.Add(ConfigurationContext.Establish(configuration));
disposables.Add(configuration);
}
示例8: Handle
public override void Handle(CommandTarget target, string type, string[] parameters)
{
if (!Util.IsSuperAdmin(target))
return;
Program.Steam.Disconnect(); // should auto-reconnect
}
示例9: Handle
public override void Handle(CommandTarget target, string type, string[] parameters)
{
if (!target.IsSession || !target.IsRoom || target.Session.Account == null || !(target.Room is MafiaRoom))
return;
var room = (MafiaRoom)target.Room;
if (room.IsPlaying)
{
target.Send("A game is currently in progress. You must wait until it has finished to join.");
return;
}
if (parameters.Length < 1)
{
target.Send("You must specify an alias to join the game: /join Brian");
return;
}
if (!Util.IsValidUsername(parameters[0]))
{
target.Send(Util.InvalidUsernameMessage);
return;
}
// TODO: add to game
}
示例10: Handle
public override void Handle(CommandTarget target, string type, string[] parameters)
{
if (!target.IsRoom || !Util.IsMod(target) || parameters.Length == 0)
return;
if (!Util.IsValidUsername(parameters[0]))
{
target.Send("Invalid username.");
return;
}
if (!Account.Exists(parameters[0]))
{
target.Send("Account does not exist.");
return;
}
if (Util.IsAdmin(target.Room, parameters[0]))
{
target.Send("Administrators can not be banned.");
return;
}
if (!target.Room.IsWhitelisted)
target.Room.Unban(parameters[0]);
else
target.Room.Ban(parameters[0]);
target.Send("Account unbanned.");
}
示例11: Commandform
public Commandform(CommandTarget commandTarget) {
//
// Required for Windows Form Designer support
//
InitializeComponent();
m_commandTarget = commandTarget;
}
示例12: SetUp
public void SetUp()
{
disposables = new CompositeDisposable
{
VirtualClock.Start()
};
clockName = Any.CamelCaseName();
targetId = Any.Word();
target = new CommandTarget(targetId);
store = new InMemoryStore<CommandTarget>(
_ => _.Id,
id => new CommandTarget(id))
{
target
};
configuration = new Configuration()
.UseInMemoryCommandScheduling()
.UseDependency<IStore<CommandTarget>>(_ => store)
.UseDependency<GetClockName>(c => _ => clockName)
.TraceScheduledCommands();
scheduler = configuration.CommandScheduler<CommandTarget>();
Command<CommandTarget>.AuthorizeDefault = (commandTarget, command) => true;
disposables.Add(ConfigurationContext.Establish(configuration));
disposables.Add(configuration);
}
开发者ID:charlesmccarthyirl,项目名称:Its.Cqrs,代码行数:30,代码来源:NonEventSourcedAggregateCommandSchedulingTests.cs
示例13: Handle
public override void Handle(CommandTarget target, string type, string[] parameters)
{
if (!Util.IsSuperAdmin(target))
return;
Program.Logger.Info("Reboot requested");
Environment.Exit(0);
}
示例14: Handle
public override void Handle(CommandTarget target, string type, string[] parameters)
{
if (!target.IsRoom || !(target.Room is ScriptRoom) || !Util.IsSuperAdmin(target))
return;
var scriptRoom = (ScriptRoom)target.Room;
scriptRoom.Recompile();
}
示例15: Handle
public override void Handle(CommandTarget target, string type, string[] parameters)
{
if (!Util.IsSuperAdmin(target))
return;
var sessions = Program.SessionManager.List.Select(s => string.Format("{0} ({1})", s.Account.Name, s.ConnectionCount));
var sessionsText = string.Join(", ", sessions);
target.Send(string.Format("Active sessions: {0}", sessionsText));
}