Example #1
0
        public MarkdownParameterHelpInfo(PsParameterHelpInfo[] parameterHelpInfos, ParameterGroup parameterGroup)
        {
            Name        = parameterGroup.ParameterName;
            Description = parameterGroup.Description.NullIfEmpty()
                          ?? parameterHelpInfos.Select(phi => phi.Description).FirstOrDefault(d => !String.IsNullOrEmpty(d)).EmptyIfNull();
            Type     = parameterGroup.ParameterType;
            Position = parameterGroup.FirstPosition?.ToString()
                       ?? parameterHelpInfos.Select(phi => phi.PositionText).FirstOrDefault(d => !String.IsNullOrEmpty(d)).ToUpperFirstCharacter().NullIfEmpty()
                       ?? "Named";
            // This no longer uses firstHelpInfo.DefaultValueAsString since it seems to be broken. For example, it has a value of 0 for Int32, but no default value was declared.
            DefaultValue = parameterGroup.DefaultInfo?.Script ?? "None";

            HasAllParameterSets = parameterGroup.HasAllVariants;
            ParameterSetNames   = (parameterGroup.Parameters.Select(p => p.VariantName).ToArray().NullIfEmpty()
                                   ?? parameterHelpInfos.SelectMany(phi => phi.ParameterSetNames).Distinct())
                                  .OrderBy(psn => psn).ToArray();
            Aliases = parameterGroup.Aliases.NullIfEmpty() ?? parameterHelpInfos.SelectMany(phi => phi.Aliases).ToArray();

            IsRequired                    = parameterHelpInfos.Select(phi => phi.IsRequired).FirstOrDefault(r => r == true) ?? parameterGroup.Parameters.Any(p => p.IsMandatory);
            IsDynamic                     = parameterHelpInfos.Select(phi => phi.IsDynamic).FirstOrDefault(d => d == true) ?? false;
            AcceptsPipelineByValue        = parameterHelpInfos.Select(phi => phi.SupportsPipelineInput?.Contains("ByValue")).FirstOrDefault(bv => bv == true) ?? parameterGroup.ValueFromPipeline;
            AcceptsPipelineByPropertyName = parameterHelpInfos.Select(phi => phi.SupportsPipelineInput?.Contains("ByPropertyName")).FirstOrDefault(bv => bv == true) ?? parameterGroup.ValueFromPipelineByPropertyName;
            AcceptsWildcardCharacters     = parameterGroup.SupportsWildcards;
        }
Example #2
0
 public static DefaultInfo ToDefaultInfo(this PSDefaultValueAttribute defaultValueAttribute, ParameterGroup parameterGroup) => new DefaultInfo(defaultValueAttribute, parameterGroup);
Example #3
0
 public static DefaultInfo ToDefaultInfo(this DefaultInfoAttribute infoAttribute, ParameterGroup parameterGroup) => new DefaultInfo(infoAttribute, parameterGroup);
 public DefaultInfoOutput(ParameterGroup parameterGroup)
 {
     HasDefaultInfo = parameterGroup.HasDefaultInfo;
     DefaultInfo    = parameterGroup.DefaultInfo;
 }