当前位置: 首页>>代码示例>>C#>>正文


C# CommandTarget类代码示例

本文整理汇总了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.");
        }
开发者ID:krixalis,项目名称:RohBot,代码行数:34,代码来源:Unban.cs

示例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]);
        }
开发者ID:Rohansi,项目名称:RohBot,代码行数:7,代码来源:Broadcast.cs

示例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);
        }
开发者ID:Naarkie,项目名称:RohBot,代码行数:28,代码来源:Me.cs

示例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);
        }
开发者ID:ToXIcGaming,项目名称:SteamMobile,代码行数:30,代码来源:Users.cs

示例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.");
        }
开发者ID:Naarkie,项目名称:RohBot,代码行数:26,代码来源:Demod.cs

示例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]);
 }
开发者ID:Rohansi,项目名称:RohBot,代码行数:7,代码来源:UserListRequest.cs

示例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);
        }
开发者ID:PhillipPruett,项目名称:Its.Cqrs,代码行数:33,代码来源:NonEventSourcedAggregateCommandSchedulingTests.cs

示例8: Handle

        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!Util.IsSuperAdmin(target))
                return;

            Program.Steam.Disconnect(); // should auto-reconnect
        }
开发者ID:Naarkie,项目名称:RohBot,代码行数:7,代码来源:FixSteam.cs

示例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
        }
开发者ID:ToXIcGaming,项目名称:SteamMobile,代码行数:27,代码来源:Join.cs

示例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.");
        }
开发者ID:ToXIcGaming,项目名称:SteamMobile,代码行数:30,代码来源:Unban.cs

示例11: Commandform

		public Commandform(CommandTarget commandTarget) {
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
            m_commandTarget = commandTarget;
		}
开发者ID:JnS-Software-LLC,项目名称:iiop-net,代码行数:7,代码来源:ClientForm.cs

示例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);
        }
开发者ID:Naarkie,项目名称:RohBot,代码行数:8,代码来源:Reboot.cs

示例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();
        }
开发者ID:Naarkie,项目名称:RohBot,代码行数:8,代码来源:Compile.cs

示例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));
        }
开发者ID:krixalis,项目名称:RohBot,代码行数:9,代码来源:Sessions.cs


注:本文中的CommandTarget类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。