Пример #1
0
        private void Initialize(MergedCommandParameterMetadata parameterMetadata, int parameterSetFlag)
        {
            Collection <CommandParameterInfo> list = new Collection <CommandParameterInfo>();

            foreach (MergedCompiledCommandParameter parameter in parameterMetadata.GetParametersInParameterSet(parameterSetFlag))
            {
                if (parameter != null)
                {
                    list.Add(new CommandParameterInfo(parameter.Parameter, parameterSetFlag));
                }
            }
            this.Parameters = new ReadOnlyCollection <CommandParameterInfo>(list);
        }
Пример #2
0
        private void BuildSyntaxForParameterSet(XmlElement command, XmlElement syntax, MergedCommandParameterMetadata parameterMetadata, int i)
        {
            XmlElement newChild = this.doc.CreateElement("command:syntaxItem", commandURI);
            XmlElement element2 = this.doc.CreateElement("maml:name", mamlURI);
            XmlText    text     = this.doc.CreateTextNode(this.commandName);

            newChild.AppendChild(element2).AppendChild(text);
            foreach (MergedCompiledCommandParameter parameter in parameterMetadata.GetParametersInParameterSet(((int)1) << i))
            {
                if (parameter.BinderAssociation != ParameterBinderAssociation.CommonParameters)
                {
                    CompiledCommandParameter     parameter2       = parameter.Parameter;
                    ParameterSetSpecificMetadata parameterSetData = parameter2.GetParameterSetData(((int)1) << i);
                    string parameterDescription = this.GetParameterDescription(parameter2.Name);
                    bool   supportsWildcards    = (from attribute in parameter2.CompiledAttributes
                                                   where attribute is SupportsWildcardsAttribute
                                                   select attribute).Any <System.Attribute>();
                    XmlElement element3 = this.BuildXmlForParameter(parameter2.Name, parameterSetData.IsMandatory, parameterSetData.ValueFromPipeline, parameterSetData.ValueFromPipelineByPropertyName, parameterSetData.IsPositional ? ((1 + parameterSetData.Position)).ToString(CultureInfo.InvariantCulture) : "named", parameter2.Type, parameterDescription, supportsWildcards, "", true);
                    newChild.AppendChild(element3);
                }
            }
            command.AppendChild(syntax).AppendChild(newChild);
        }
Пример #3
0
        private void Initialize(MergedCommandParameterMetadata parameterMetadata, uint parameterSetFlag)
        {
            Diagnostics.Assert(
                parameterMetadata != null,
                "The parameterMetadata should never be null");

            Collection <CommandParameterInfo> processedParameters =
                new Collection <CommandParameterInfo>();

            // Get the parameters in the parameter set
            Collection <MergedCompiledCommandParameter> compiledParameters =
                parameterMetadata.GetParametersInParameterSet(parameterSetFlag);

            foreach (MergedCompiledCommandParameter parameter in compiledParameters)
            {
                if (parameter != null)
                {
                    processedParameters.Add(
                        new CommandParameterInfo(parameter.Parameter, parameterSetFlag));
                }
            }

            Parameters = new ReadOnlyCollection <CommandParameterInfo>(processedParameters);
        }
Пример #4
0
        private void BuildSyntaxForParameterSet(
            XmlElement command,
            XmlElement syntax,
            MergedCommandParameterMetadata parameterMetadata,
            int i)
        {
            XmlElement element1 = this.doc.CreateElement("command:syntaxItem", HelpCommentsParser.commandURI);
            XmlElement element2 = this.doc.CreateElement("maml:name", HelpCommentsParser.mamlURI);
            XmlText    textNode = this.doc.CreateTextNode(this.commandName);

            element1.AppendChild((XmlNode)element2).AppendChild((XmlNode)textNode);
            foreach (MergedCompiledCommandParameter parametersInParameter in parameterMetadata.GetParametersInParameterSet((uint)(1 << i)))
            {
                if (parametersInParameter.BinderAssociation != ParameterBinderAssociation.CommonParameters)
                {
                    CompiledCommandParameter     parameter        = parametersInParameter.Parameter;
                    ParameterSetSpecificMetadata parameterSetData = parameter.GetParameterSetData((uint)(1 << i));
                    string     parameterDescription = this.GetParameterDescription(parameter.Name);
                    XmlElement xmlElement           = this.BuildXmlForParameter(parameter.Name, parameterSetData.IsMandatory, parameterSetData.ValueFromPipeline, parameterSetData.ValueFromPipelineByPropertyName, parameterSetData.IsPositional ? (1 + parameterSetData.Position).ToString((IFormatProvider)CultureInfo.InvariantCulture) : "named", parameter.Type, parameterDescription, true);
                    element1.AppendChild((XmlNode)xmlElement);
                }
            }
            command.AppendChild((XmlNode)syntax).AppendChild((XmlNode)element1);
        }
Пример #5
0
        private void BuildSyntaxForParameterSet(XmlElement command, XmlElement syntax, MergedCommandParameterMetadata parameterMetadata, int i)
        {
            XmlElement syntaxItem = _doc.CreateElement("command:syntaxItem", commandURI);
            XmlElement syntaxItemName = _doc.CreateElement("maml:name", mamlURI);
            XmlText syntaxItemName_text = _doc.CreateTextNode(_commandName);

            syntaxItem.AppendChild(syntaxItemName).AppendChild(syntaxItemName_text);

            Collection<MergedCompiledCommandParameter> compiledParameters =
                parameterMetadata.GetParametersInParameterSet(1u << i);

            foreach (MergedCompiledCommandParameter mergedParameter in compiledParameters)
            {
                if (mergedParameter.BinderAssociation == ParameterBinderAssociation.CommonParameters)
                {
                    continue;
                }

                CompiledCommandParameter parameter = mergedParameter.Parameter;
                ParameterSetSpecificMetadata parameterSetData = parameter.GetParameterSetData(1u << i);
                string description = GetParameterDescription(parameter.Name);
                bool supportsWildcards = parameter.CompiledAttributes.Any(attribute => attribute is SupportsWildcardsAttribute);
                XmlElement parameterElement = BuildXmlForParameter(parameter.Name,
                    parameterSetData.IsMandatory, parameterSetData.ValueFromPipeline,
                    parameterSetData.ValueFromPipelineByPropertyName,
                    parameterSetData.IsPositional ? (1 + parameterSetData.Position).ToString(CultureInfo.InvariantCulture) : "named",
                    parameter.Type, description, supportsWildcards, defaultValue: "", forSyntax: true);
                syntaxItem.AppendChild(parameterElement);
            }
            command.AppendChild(syntax).AppendChild(syntaxItem);
        }
Пример #6
0
        private void Initialize(MergedCommandParameterMetadata parameterMetadata, uint parameterSetFlag)
        {
            Diagnostics.Assert(
                parameterMetadata != null,
                "The parameterMetadata should never be null");

            Collection<CommandParameterInfo> processedParameters =
                new Collection<CommandParameterInfo>();

            // Get the parameters in the parameter set
            Collection<MergedCompiledCommandParameter> compiledParameters =
                parameterMetadata.GetParametersInParameterSet(parameterSetFlag);

            foreach (MergedCompiledCommandParameter parameter in compiledParameters)
            {
                if (parameter != null)
                {
                    processedParameters.Add(
                        new CommandParameterInfo(parameter.Parameter, parameterSetFlag));
                }
            }

            Parameters = new ReadOnlyCollection<CommandParameterInfo>(processedParameters);
        }
Пример #7
0
 private void BuildSyntaxForParameterSet(XmlElement command, XmlElement syntax, MergedCommandParameterMetadata parameterMetadata, int i)
 {
     XmlElement newChild = this.doc.CreateElement("command:syntaxItem", commandURI);
     XmlElement element2 = this.doc.CreateElement("maml:name", mamlURI);
     XmlText text = this.doc.CreateTextNode(this.commandName);
     newChild.AppendChild(element2).AppendChild(text);
     foreach (MergedCompiledCommandParameter parameter in parameterMetadata.GetParametersInParameterSet(((int) 1) << i))
     {
         if (parameter.BinderAssociation != ParameterBinderAssociation.CommonParameters)
         {
             CompiledCommandParameter parameter2 = parameter.Parameter;
             ParameterSetSpecificMetadata parameterSetData = parameter2.GetParameterSetData(((int) 1) << i);
             string parameterDescription = this.GetParameterDescription(parameter2.Name);
             bool supportsWildcards = (from attribute in parameter2.CompiledAttributes
                 where attribute is SupportsWildcardsAttribute
                 select attribute).Any<System.Attribute>();
             XmlElement element3 = this.BuildXmlForParameter(parameter2.Name, parameterSetData.IsMandatory, parameterSetData.ValueFromPipeline, parameterSetData.ValueFromPipelineByPropertyName, parameterSetData.IsPositional ? ((1 + parameterSetData.Position)).ToString(CultureInfo.InvariantCulture) : "named", parameter2.Type, parameterDescription, supportsWildcards, "", true);
             newChild.AppendChild(element3);
         }
     }
     command.AppendChild(syntax).AppendChild(newChild);
 }
Пример #8
0
 private void Initialize(MergedCommandParameterMetadata parameterMetadata, int parameterSetFlag)
 {
     Collection<CommandParameterInfo> list = new Collection<CommandParameterInfo>();
     foreach (MergedCompiledCommandParameter parameter in parameterMetadata.GetParametersInParameterSet(parameterSetFlag))
     {
         if (parameter != null)
         {
             list.Add(new CommandParameterInfo(parameter.Parameter, parameterSetFlag));
         }
     }
     this.Parameters = new ReadOnlyCollection<CommandParameterInfo>(list);
 }