Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PackageCommand"/> class.
        /// </summary>
        public PackageCommand() : base()
        {
            Name        = Id;
            IsInternal  = true;
            Target      = typeof(PackageCommand);
            Description = "";
            Examples.Add(new Example("", ""));
            RelatedLinks.Add("");

            Add(new Argument(nameof(ExecutableFile), typeof(string))
            {
                Position    = 0,
                Description = "",
                IsRequired  = true
            }, new Argument(nameof(PackageKind), typeof(ShellKind))
            {
                Position    = 1,
                Description = "",
                Default     = (ShellKind.Powershell)
            });
        }
        void importRelinks(PSObject relink)
        {
            List <PSObject> relinks = new List <PSObject>();

            if (!(relink.Members["navigationLink"].Value is PSObject))
            {
                relinks = new List <PSObject>((PSObject[])relink.Members["navigationLink"].Value);
            }
            else
            {
                relinks.Add((PSObject)relink.Members["navigationLink"].Value);
            }
            foreach (PSObject link in relinks)
            {
                String linkText = ((String)((PSObject)link.Members["linkText"].Value).BaseObject).Replace("-", String.Empty).Trim();
                String uri      = (String)((PSObject)link.Members["uri"].Value).BaseObject;
                RelatedLinks.Add(new RelatedLink {
                    LinkText = linkText,
                    LinkUrl  = uri
                });
            }
        }
Example #3
0
        /// <summary>
        /// @UE3 Parse each individual row of meta data
        /// </summary>
        /// <param name="match"></param>
        /// <returns></returns>
        private string ParseMetadataRow(Match match, TransformationData data, bool full = true)
        {
            var metaValue        = match.Groups["MetadataValue"].Value;
            var metaDataCategory = match.Groups["MetadataKey"].Value;

            if (metaDataCategory.Contains(' '))
            {
                data.ErrorList.Add(
                    Markdown.GenerateError(
                        Language.Message("MetadataNamesMustNotContainSpaces", metaDataCategory),
                        MessageClass.Warning,
                        metaDataCategory,
                        data.ErrorList.Count,
                        data));
            }

            var metaDataCategoryLowerCase = metaDataCategory.ToLower();

            // If value is blank change to paragraph for table creation classification form
            if (!String.IsNullOrWhiteSpace(match.Groups["MetadataValue"].Value))
            {
                if (metaDataCategoryLowerCase == "title")
                {
                    DocumentTitle = metaValue;
                }

                if (metaDataCategoryLowerCase == "seo-title")
                {
                    SEOTitle = metaValue;
                }

                if (metaDataCategoryLowerCase == "crumbs")
                {
                    CrumbsLinks.Add(metaValue);
                }

                if (metaDataCategoryLowerCase == "related" && full)
                {
                    RelatedLinks.Add(data.Markdown.ProcessRelated(metaValue, data));
                }

                if (metaDataCategoryLowerCase == "prereq" && full)
                {
                    PrereqLinks.Add(data.Markdown.ProcessPrereqs(metaValue, data));
                }

                if (metaDataCategoryLowerCase == "version")
                {
                    EngineVersions.Add(Hash.FromAnonymousObject(new { version = metaValue, label = metaValue.Replace('.', '_') }));
                }

                if (metaDataCategoryLowerCase == "skilllevel")
                {
                    SkillLevels.Add(metaValue);
                }

                if (metaDataCategoryLowerCase == "tags")
                {
                    Tags.Add(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(metaValue));
                }
            }

            // Add meta data to the list, we require some specific meta data keys to be unique others can be duplicates
            if (metaDataCategoryLowerCase.Equals("title") || metaDataCategoryLowerCase.Equals("seo-title") ||
                metaDataCategoryLowerCase.Equals("description") || metaDataCategoryLowerCase.Equals("seo-description") ||
                metaDataCategoryLowerCase.Equals("template") || metaDataCategoryLowerCase.Equals("forcepublishfiles"))
            {
                if (MetadataMap.ContainsKey(metaDataCategoryLowerCase))
                {
                    data.ErrorList.Add(
                        new ErrorDetail(
                            Language.Message("DuplicateMetadataDetected", metaDataCategory),
                            MessageClass.Info,
                            "",
                            "",
                            0,
                            0));
                }
                else
                {
                    var valueList = new List <string>();
                    valueList.Add(match.Groups["MetadataValue"].Value);
                    MetadataMap.Add(metaDataCategoryLowerCase, valueList);
                }
            }
            else
            {
                if (MetadataMap.ContainsKey(metaDataCategoryLowerCase))
                {
                    MetadataMap[metaDataCategoryLowerCase].Add(match.Groups["MetadataValue"].Value);
                }
                else
                {
                    var valueList = new List <string>();
                    valueList.Add(match.Groups["MetadataValue"].Value);
                    MetadataMap.Add(metaDataCategoryLowerCase, valueList);
                }
            }

            // Return empty string, we are removing the meta data from the document
            return("");
        }
        /// <summary>
        /// @UE3 Parse each individual row of meta data
        /// </summary>
        /// <param name="match"></param>
        /// <returns></returns>
        private string ParseMetadataRow(Match match, TransformationData data)
        {
            var metaValue        = match.Groups["MetadataValue"].Value;
            var metaDataCategory = match.Groups["MetadataKey"].Value;

            if (metaDataCategory.Contains(' '))
            {
                data.ErrorList.Add(
                    Markdown.GenerateError(
                        Language.Message("MetadataNamesMustNotContainSpaces", metaDataCategory),
                        MessageClass.Warning,
                        metaDataCategory,
                        data.ErrorList.Count,
                        data));
            }

            var metaDataCategoryLowerCase = metaDataCategory.ToLower();

            // If value is blank change to paragraph for table creation classification form
            if (!String.IsNullOrWhiteSpace(match.Groups["MetadataValue"].Value))
            {
                if (metaDataCategoryLowerCase == "title")
                {
                    DocumentTitle = metaValue;
                }

                if (metaDataCategoryLowerCase == "crumbs")
                {
                    CrumbsLinks.Add(metaValue);
                }

                if (metaDataCategoryLowerCase == "related")
                {
                    RelatedLinks.Add(data.Markdown.ProcessRelated(metaValue, data));
                }
            }

            // Add meta data to the list, we require some specific meta data keys to be unique others can be duplicates
            if (metaDataCategoryLowerCase.Equals("title") || metaDataCategoryLowerCase.Equals("description") ||
                metaDataCategoryLowerCase.Equals("template") || metaDataCategoryLowerCase.Equals("forcepublishfiles"))
            {
                if (MetadataMap.ContainsKey(metaDataCategoryLowerCase))
                {
                    data.ErrorList.Add(
                        new ErrorDetail(
                            Language.Message("DuplicateMetadataDetected", metaDataCategory),
                            MessageClass.Info,
                            "",
                            "",
                            0,
                            0));
                }
                else
                {
                    var valueList = new List <string>();
                    valueList.Add(match.Groups["MetadataValue"].Value);
                    MetadataMap.Add(metaDataCategoryLowerCase, valueList);
                }
            }
            else
            {
                if (MetadataMap.ContainsKey(metaDataCategoryLowerCase))
                {
                    MetadataMap[metaDataCategoryLowerCase].Add(match.Groups["MetadataValue"].Value);
                }
                else
                {
                    var valueList = new List <string>();
                    valueList.Add(match.Groups["MetadataValue"].Value);
                    MetadataMap.Add(metaDataCategoryLowerCase, valueList);
                }
            }

            // Return empty string, we are removing the meta data from the document
            return("");
        }