Ejemplo n.º 1
0
        /// <summary>
        ///     Execute the task.
        /// </summary>
        /// <returns>
        ///     <c>true</c>, if the task executed succesfully; otherwise, <c>false</c>.
        /// </returns>
        public override bool Execute()
        {
            FileInfo moduleAssemblyFile = new FileInfo(
                ModuleAssembly.GetMetadata("FullPath")
                );

            Log.LogMessage(MessageImportance.Low, "Scanning assembly '{0}'...",
                           moduleAssemblyFile.FullName
                           );

            DirectoryAssemblyLoadContext assemblyLoadContext = new DirectoryAssemblyLoadContext(
                fallbackDirectory: moduleAssemblyFile.Directory.FullName
                );

            HelpItems     help      = new HelpItems();
            MamlGenerator generator = new MamlGenerator();

            Assembly moduleAssembly = assemblyLoadContext.LoadFromAssemblyPath(moduleAssemblyFile.FullName);

            foreach (Type cmdletType in Reflector.GetCmdletTypes(moduleAssembly))
            {
                CmdletAttribute cmdletAttribute = cmdletType.GetTypeInfo().GetCustomAttribute <CmdletAttribute>();

                Log.LogMessage(MessageImportance.Low, "Generating help for cmdlet '{0}-{1}' ('{2}').",
                               cmdletAttribute.VerbName,
                               cmdletAttribute.NounName,
                               cmdletType.FullName
                               );

                help.Commands.Add(
                    generator.Generate(cmdletType)
                    );
            }

            FileInfo helpFile = new FileInfo(
                HelpFile.GetMetadata("FullPath")
                );

            if (helpFile.Exists)
            {
                helpFile.Delete();
            }

            using (StreamWriter writer = helpFile.CreateText())
            {
                help.WriteTo(writer);
            }

            Log.LogMessage(MessageImportance.Normal, "'{0}' -> '{1}'",
                           moduleAssemblyFile.Name,
                           helpFile.Name
                           );

            return(true);
        }
Ejemplo n.º 2
0
        private void GetHelpItems()
        {
            var helpItems = _helpProvider.GetHelpItems();

            if (helpItems == null)
            {
                return;
            }

            HelpItems.Clear();
            helpItems.ToList().ForEach(h => HelpItems.Add(new HelpDisplayModel(h)));
        }
Ejemplo n.º 3
0
        public ActionResult Topic(string ID)
        {
            var    items = HelpItems.Load();
            string id    = (ID ?? "").Trim().ToLower();
            var    help  = items.FirstOrDefault(h => id == h.Slug.ToLower());

            if (help == null)
            {
                return(new HttpNotFoundResult());
            }
            help.LoadMarkdown();
            return(View(help));
        }
        public MainMenu(MainWindow form)
        {
            form_ = form;

            ApplicationItems.Add(new NewFileCommand(form_));
            ApplicationItems.Add(new OpenFileCommand(form_));
            ApplicationItems.Add(new SaveFileCommand(form_));
            ApplicationItems.Add(new SaveAsFileCommand(form_));
            ApplicationItems.Add(new SeparatorMenuItem());
            ApplicationItems.Add(new QuitCommand(form_));

            HelpItems.Add(new FormattingHelp(form_));
            HelpItems.Add(new SeparatorMenuItem());
            HelpItems.Add(new AboutCommand(form_));
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     Generate MAML documentation for the specified module.
        /// </summary>
        /// <param name="moduleAssembly">
        ///     The assembly that implements the module.
        /// </param>
        /// <returns>
        ///     A <see cref="Command"/> representing the Cmdlet documentation.
        /// </returns>
        public HelpItems Generate(Assembly moduleAssembly)
        {
            if (moduleAssembly == null)
            {
                throw new ArgumentNullException(nameof(moduleAssembly));
            }

            HelpItems help = new HelpItems();

            help.Commands.AddRange(
                Reflector.GetCmdletTypes(moduleAssembly).Select(
                    cmdletType => Generate(cmdletType)
                    )
                );

            return(help);
        }
Ejemplo n.º 6
0
        public MainMenu(MainWindow form, IEditor <CampaignFile> editor)
        {
            ApplicationItems.Add(new NewFileCommand(editor));
            ApplicationItems.Add(new OpenFileCommand(editor));
            ApplicationItems.Add(new SaveFileCommand(editor));
            //ApplicationItems.Add(new SeparatorMenuItem());
            ApplicationItems.Add(new ButtonMenuItem()
            {
                Text  = "&Import / Export",
                Image = Resources.GetIcon("Package.ico"),
                Items =
                {
                    new ImportFileCommand(editor, form),
                    new ExportFileCommand(editor, form)
                }
            });
            ApplicationItems.Add(new SeparatorMenuItem());
            ApplicationItems.Add(new CloseProjectCommand(editor));
            ApplicationItems.Add(new SeparatorMenuItem());
            ApplicationItems.Add(new SettingsCommand());
            //ApplicationItems.Add(new SeparatorMenuItem());
            ApplicationItems.Add(new QuitCommand(form));

            HelpItems.Add(new FeedbackCommand());
            HelpItems.Add(new TutorialsCommand());
            HelpItems.Add(new SeparatorMenuItem());
            HelpItems.Add(new AboutCommand());

            Items.Add(new ButtonMenuItem()
            {
                Text  = "&Project",
                Items =
                {
                    new RunGameCommand(editor),
                    new CheckFilesCommand(editor),
                    new ProjectFolderCommand(editor)
                }
            });
        }
Ejemplo n.º 7
0
        private HelpItems CreateHelpItemsForPartial()
        {
            var items = new HelpItems();
            for (var i = 1; i < 6; i++)
            {
                items.Add(new HelpItem
                {
                    HelpDescription = string.Format("Help omschrijving {0}", i),
                    HelpInSource = string.Format("Help in source {0}", i),
                    HelpTopic = string.Format("Help topic {0}", i),
                    HelpTopicId = i.ToString(),
                    HelpVersie = string.Format("versie {0}", i)
                });
                if (i == 1 || i == 2) items[i - 1].HelpDescription = "Specifiek";

            }
            return items;
        }
Ejemplo n.º 8
0
 private HelpItems CreateHelpItems()
 {
     var items = new HelpItems();
     for (var i = 1; i < 6; i++)
     {
         items.Add(new HelpItem
                       {
                           HelpDescription = string.Format("Help omschrijving {0}", i),
                           HelpInSource = string.Format("Help in source {0}", i),
                           HelpTopic = string.Format("Help topic {0}", i),
                           HelpTopicId = i.ToString(),
                           HelpVersie = string.Format("versie {0}", i)
                       });
     }
     return items;
 }
Ejemplo n.º 9
0
 public void MyTestInitialize()
 {
     _helpItems = CreateHelpItems();
     _helpItemsPartialTests = CreateHelpItemsForPartial();
     _propertyNames = new[] { "HelpDescription", "HelpInSource", "HelpTopic", "HelpTopicId", "HelpVersie" };
 }
Ejemplo n.º 10
0
 public void MyTestCleanup()
 {
     _helpItems = null;
     _helpItemsPartialTests = null;
     _propertyNames = null;
 }
Ejemplo n.º 11
0
        public ActionResult Topics()
        {
            var items = HelpItems.Load();

            return(View(items));
        }