Exemple #1
0
        private IWebSocket socketServer; //WebSocket实例

        public ArticlesController(IArticle articleServer,
                                  IUser userServer,
                                  IType typeServer,
                                  ILang langServer,
                                  IRedis redisServer,
                                  IHelpful helpfulServer)
        {
            this.articleServer = articleServer;
            this.userServer    = userServer;
            this.typeServer    = typeServer;
            this.langServer    = langServer;
            this.redisServer   = redisServer;
            this.helpfulServer = helpfulServer;

            socketServer = new WebSocketImpl();
        }
Exemple #2
0
        public ActionResult Help(string SearchTerm = "", bool IncludeInGame = true)
        {
            List <IHelp>    validEntries = TemplateCache.GetAll <IHelp>(true).ToList();
            ApplicationUser user         = null;
            string          searcher     = SearchTerm.Trim().ToLower();

            if (User.Identity.IsAuthenticated)
            {
                user = UserManager.FindById(User.Identity.GetUserId());
                StaffRank userRank = user.GetStaffRank(User);
            }

            if (IncludeInGame)
            {
                //All the entities with helps
                IEnumerable <ILookupData> entityHelps = TemplateCache.GetAll <ILookupData>(true).Where(data => !data.ImplementsType <IHelp>());
                validEntries.AddRange(entityHelps.Select(helpful => new Data.Administrative.Help()
                {
                    Name = helpful.Name, HelpText = helpful.HelpText
                }));

                //All the commands
                Assembly           commandsAssembly = Assembly.GetAssembly(typeof(CommandParameterAttribute));
                IEnumerable <Type> validTargetTypes = commandsAssembly.GetTypes().Where(t => !t.IsAbstract && t.ImplementsType <IHelpful>());

                foreach (Type command in validTargetTypes)
                {
                    IHelpful       instance = (IHelpful)Activator.CreateInstance(command);
                    MarkdownString body     = instance.HelpText;
                    string         subject  = command.Name;

                    validEntries.Add(new Data.Administrative.Help()
                    {
                        Name = subject, HelpText = body
                    });
                }
            }

            HelpViewModel vModel = new HelpViewModel(validEntries.Where(help => help.HelpText.ToLower().Contains(searcher) || help.Name.ToLower().Contains(searcher)))
            {
                AuthedUser    = user,
                SearchTerm    = SearchTerm,
                IncludeInGame = IncludeInGame
            };

            return(View(vModel));
        }
Exemple #3
0
        /// <summary>
        /// Executes this command
        /// </summary>
        public override void Execute()
        {
            IHelpful       topic = (IHelpful)Subject;
            IList <string> sb    = GetHelpHeader(topic);

            sb = sb.Concat(topic.RenderHelpBody()).ToList();

            //If it's a command render the syntax help at the bottom
            if (topic.GetType().GetInterfaces().Contains(typeof(ICommand)))
            {
                ICommand subject = (ICommand)topic;
                sb.Add(string.Empty);
                sb = sb.Concat(subject.RenderSyntaxHelp()).ToList();
            }

            ILexicalParagraph toActor = new LexicalParagraph(sb.ToString());

            Message messagingObject = new Message(toActor);

            messagingObject.ExecuteMessaging(Actor, null, null, null, null);
        }
Exemple #4
0
        private IList <string> GetHelpHeader(IHelpful subject)
        {
            var sb          = new List <string>();
            var subjectName = subject.GetType().Name;
            var typeName    = "Help";

            if (subject.GetType().GetInterfaces().Contains(typeof(IReferenceData)))
            {
                var refSubject = (IReferenceData)subject;

                subjectName = refSubject.Name;
                typeName    = "Reference";
            }
            else if (subject.GetType().GetInterfaces().Contains(typeof(ICommand)))
            {
                typeName = "Commands";
            }

            sb.Add(string.Format("{0} - <span style=\"color: orange\">{1}</span>", typeName, subjectName));
            sb.Add(string.Empty.PadLeft(typeName.Length + 3 + subjectName.Length, '-'));

            return(sb);
        }
Exemple #5
0
        private IList <string> GetHelpHeader(IHelpful subject)
        {
            List <string> sb          = new List <string>();
            string        subjectName = subject.GetType().Name;
            string        typeName    = "Help";

            if (subject.GetType().GetInterfaces().Contains(typeof(ILookupData)))
            {
                ILookupData refSubject = (ILookupData)subject;

                subjectName = refSubject.Name;
                typeName    = "Lookup Data";
            }
            else if (subject.GetType().GetInterfaces().Contains(typeof(ICommand)))
            {
                typeName = "Commands";
            }

            sb.Add(string.Format("{0} - %O%{1}%O%", typeName, subjectName));
            sb.Add(string.Empty.PadLeft(typeName.Length + 3 + subjectName.Length, '-'));

            return(sb);
        }
Exemple #6
0
        private IList<string> GetHelpHeader(IHelpful subject)
        {
            var sb = new List<string>();
            var subjectName = subject.GetType().Name;
            var typeName = "Help";

            if (subject.GetType().GetInterfaces().Contains(typeof(IReferenceData)))
            {
                var refSubject = (IReferenceData)subject;

                subjectName = refSubject.Name;
                typeName = "Reference";
            }
            else if (subject.GetType().GetInterfaces().Contains(typeof(ICommand)))
            {
                typeName = "Commands";
            }

            sb.Add(string.Format("{0} - <span style=\"color: orange\">{1}</span>", typeName, subjectName));
            sb.Add(string.Empty.PadLeft(typeName.Length + 3 + subjectName.Length, '-'));

            return sb;
        }
Exemple #7
0
 public HelpfulImpl(HuobiContext db)
 {
     this.m_db      = db;
     this.m_helpful = this;
 }
Exemple #8
0
        private IList<string> GetHelpHeader(IHelpful subject)
        {
            var sb = new List<string>();
            var subjectName = subject.GetType().Name;
            var typeName = "Help";

            if (subject.GetType().GetInterfaces().Contains(typeof(ILookupData)))
            {
                var refSubject = (ILookupData)subject;

                subjectName = refSubject.Name;
                typeName = "Lookup Data";
            }
            else if (subject.GetType().GetInterfaces().Contains(typeof(ICommand)))
            {
                typeName = "Commands";
            }

            sb.Add(string.Format("{0} - %O%{1}%O%", typeName, subjectName));
            sb.Add(string.Empty.PadLeft(typeName.Length + 3 + subjectName.Length, '-'));

            return sb;
        }
 public void MyMethod(IHelpful x)
 {
     // We don't know much about x
     // ... but we know that it has the method GiveHelp
 }