Пример #1
0
 private ParameterMetadata GetParameter(IEnumerable<string> queryParameterSets, string objectModelParameterName, TypeMetadata parameterType, CmdletParameterMetadataForGetCmdletParameter parameterCmdletization)
 {
     ParameterMetadata metadata = this.GetParameter("__AllParameterSets", objectModelParameterName, parameterType, parameterCmdletization, ((parameterCmdletization != null) && parameterCmdletization.ValueFromPipelineSpecified) && parameterCmdletization.ValueFromPipeline, ((parameterCmdletization != null) && parameterCmdletization.ValueFromPipelineByPropertyNameSpecified) && parameterCmdletization.ValueFromPipelineByPropertyName);
     ParameterSetMetadata metadata2 = metadata.ParameterSets["__AllParameterSets"];
     metadata.ParameterSets.Clear();
     if (((parameterCmdletization != null) && (parameterCmdletization.CmdletParameterSets != null)) && (parameterCmdletization.CmdletParameterSets.Length > 0))
     {
         queryParameterSets = parameterCmdletization.CmdletParameterSets;
     }
     foreach (string str in queryParameterSets)
     {
         if (!str.Equals("InputObject (cdxml)", StringComparison.OrdinalIgnoreCase))
         {
             metadata.ParameterSets.Add(str, metadata2);
         }
     }
     return metadata;
 }
Пример #2
0
 private void Write10_Item(string n, string ns, CmdletParameterMetadataForGetCmdletParameter o, bool isNullable, bool needType)
 {
     if (o == null)
     {
         if (isNullable)
         {
             base.WriteNullTagLiteral(n, ns);
         }
     }
     else
     {
         if (!needType)
         {
             Type type = o.GetType();
             if (type != typeof(CmdletParameterMetadataForGetCmdletParameter))
             {
                 if (type != typeof(CmdletParameterMetadataForGetCmdletFilteringParameter))
                 {
                     throw base.CreateUnknownTypeException(o);
                 }
                 this.Write11_Item(n, ns, (CmdletParameterMetadataForGetCmdletFilteringParameter) o, isNullable, true);
                 return;
             }
         }
         base.WriteStartElement(n, ns, o, false, null);
         if (needType)
         {
             base.WriteXsiType("CmdletParameterMetadataForGetCmdletParameter", "http://schemas.microsoft.com/cmdlets-over-objects/2009/11");
         }
         if (o.IsMandatorySpecified)
         {
             base.WriteAttribute("IsMandatory", "", XmlConvert.ToString(o.IsMandatory));
         }
         string[] aliases = o.Aliases;
         if (aliases != null)
         {
             base.Writer.WriteStartAttribute(null, "Aliases", "");
             for (int i = 0; i < aliases.Length; i++)
             {
                 string str = aliases[i];
                 if (i != 0)
                 {
                     base.Writer.WriteString(" ");
                 }
                 base.WriteValue(str);
             }
             base.Writer.WriteEndAttribute();
         }
         base.WriteAttribute("PSName", "", o.PSName);
         base.WriteAttribute("Position", "", o.Position);
         if (o.ValueFromPipelineSpecified)
         {
             base.WriteAttribute("ValueFromPipeline", "", XmlConvert.ToString(o.ValueFromPipeline));
         }
         if (o.ValueFromPipelineByPropertyNameSpecified)
         {
             base.WriteAttribute("ValueFromPipelineByPropertyName", "", XmlConvert.ToString(o.ValueFromPipelineByPropertyName));
         }
         string[] cmdletParameterSets = o.CmdletParameterSets;
         if (cmdletParameterSets != null)
         {
             base.Writer.WriteStartAttribute(null, "CmdletParameterSets", "");
             for (int j = 0; j < cmdletParameterSets.Length; j++)
             {
                 string str2 = cmdletParameterSets[j];
                 if (j != 0)
                 {
                     base.Writer.WriteString(" ");
                 }
                 base.WriteValue(str2);
             }
             base.Writer.WriteEndAttribute();
         }
         this.Write1_Object("AllowEmptyCollection", "http://schemas.microsoft.com/cmdlets-over-objects/2009/11", o.AllowEmptyCollection, false, false);
         this.Write1_Object("AllowEmptyString", "http://schemas.microsoft.com/cmdlets-over-objects/2009/11", o.AllowEmptyString, false, false);
         this.Write1_Object("AllowNull", "http://schemas.microsoft.com/cmdlets-over-objects/2009/11", o.AllowNull, false, false);
         this.Write1_Object("ValidateNotNull", "http://schemas.microsoft.com/cmdlets-over-objects/2009/11", o.ValidateNotNull, false, false);
         this.Write1_Object("ValidateNotNullOrEmpty", "http://schemas.microsoft.com/cmdlets-over-objects/2009/11", o.ValidateNotNullOrEmpty, false, false);
         this.Write4_Item("ValidateCount", "http://schemas.microsoft.com/cmdlets-over-objects/2009/11", o.ValidateCount, false, false);
         this.Write5_Item("ValidateLength", "http://schemas.microsoft.com/cmdlets-over-objects/2009/11", o.ValidateLength, false, false);
         this.Write6_Item("ValidateRange", "http://schemas.microsoft.com/cmdlets-over-objects/2009/11", o.ValidateRange, false, false);
         string[] validateSet = o.ValidateSet;
         if (validateSet != null)
         {
             base.WriteStartElement("ValidateSet", "http://schemas.microsoft.com/cmdlets-over-objects/2009/11", null, false);
             for (int k = 0; k < validateSet.Length; k++)
             {
                 base.WriteElementString("AllowedValue", "http://schemas.microsoft.com/cmdlets-over-objects/2009/11", validateSet[k]);
             }
             base.WriteEndElement();
         }
         bool isMandatorySpecified = o.IsMandatorySpecified;
         bool valueFromPipelineSpecified = o.ValueFromPipelineSpecified;
         bool valueFromPipelineByPropertyNameSpecified = o.ValueFromPipelineByPropertyNameSpecified;
         base.WriteEndElement(o);
     }
 }
Пример #3
0
 private CmdletParameterMetadataForGetCmdletParameter Read10_Item(bool isNullable, bool checkType)
 {
     XmlQualifiedName type = checkType ? base.GetXsiType() : null;
     bool flag = false;
     if (isNullable)
     {
         flag = base.ReadNull();
     }
     if ((checkType && (type != null)) && ((type.Name != this.id12_Item) || (type.Namespace != this.id2_Item)))
     {
         if ((type.Name != this.id13_Item) || (type.Namespace != this.id2_Item))
         {
             throw base.CreateUnknownTypeException(type);
         }
         return this.Read11_Item(isNullable, false);
     }
     if (flag)
     {
         return null;
     }
     CmdletParameterMetadataForGetCmdletParameter o = new CmdletParameterMetadataForGetCmdletParameter();
     string[] a = null;
     int index = 0;
     string[] strArray2 = null;
     int num2 = 0;
     bool[] flagArray = new bool[0x10];
     while (base.Reader.MoveToNextAttribute())
     {
         if ((!flagArray[9] && (base.Reader.LocalName == this.id46_IsMandatory)) && (base.Reader.NamespaceURI == this.id4_Item))
         {
             o.IsMandatory = XmlConvert.ToBoolean(base.Reader.Value);
             o.IsMandatorySpecified = true;
             flagArray[9] = true;
         }
         else
         {
             if ((base.Reader.LocalName == this.id47_Aliases) && (base.Reader.NamespaceURI == this.id4_Item))
             {
                 string[] strArray3 = base.Reader.Value.Split(null);
                 for (int i = 0; i < strArray3.Length; i++)
                 {
                     a = (string[]) base.EnsureArrayIndex(a, index, typeof(string));
                     a[index++] = strArray3[i];
                 }
                 continue;
             }
             if ((!flagArray[11] && (base.Reader.LocalName == this.id48_PSName)) && (base.Reader.NamespaceURI == this.id4_Item))
             {
                 o.PSName = base.Reader.Value;
                 flagArray[11] = true;
                 continue;
             }
             if ((!flagArray[12] && (base.Reader.LocalName == this.id49_Position)) && (base.Reader.NamespaceURI == this.id4_Item))
             {
                 o.Position = base.CollapseWhitespace(base.Reader.Value);
                 flagArray[12] = true;
                 continue;
             }
             if ((!flagArray[13] && (base.Reader.LocalName == this.id50_ValueFromPipeline)) && (base.Reader.NamespaceURI == this.id4_Item))
             {
                 o.ValueFromPipeline = XmlConvert.ToBoolean(base.Reader.Value);
                 o.ValueFromPipelineSpecified = true;
                 flagArray[13] = true;
                 continue;
             }
             if ((!flagArray[14] && (base.Reader.LocalName == this.id51_Item)) && (base.Reader.NamespaceURI == this.id4_Item))
             {
                 o.ValueFromPipelineByPropertyName = XmlConvert.ToBoolean(base.Reader.Value);
                 o.ValueFromPipelineByPropertyNameSpecified = true;
                 flagArray[14] = true;
                 continue;
             }
             if ((base.Reader.LocalName == this.id52_CmdletParameterSets) && (base.Reader.NamespaceURI == this.id4_Item))
             {
                 string[] strArray4 = base.Reader.Value.Split(null);
                 for (int j = 0; j < strArray4.Length; j++)
                 {
                     strArray2 = (string[]) base.EnsureArrayIndex(strArray2, num2, typeof(string));
                     strArray2[num2++] = strArray4[j];
                 }
                 continue;
             }
             if (!base.IsXmlnsAttribute(base.Reader.Name))
             {
                 base.UnknownNode(o, ":IsMandatory, :Aliases, :PSName, :Position, :ValueFromPipeline, :ValueFromPipelineByPropertyName, :CmdletParameterSets");
             }
         }
     }
     base.Reader.MoveToElement();
     if (base.Reader.IsEmptyElement)
     {
         base.Reader.Skip();
         o.Aliases = (string[]) base.ShrinkArray(a, index, typeof(string), true);
         o.CmdletParameterSets = (string[]) base.ShrinkArray(strArray2, num2, typeof(string), true);
         return o;
     }
     base.Reader.ReadStartElement();
     base.Reader.MoveToContent();
     int whileIterations = 0;
     int readerCount = base.ReaderCount;
     while ((base.Reader.NodeType != XmlNodeType.EndElement) && (base.Reader.NodeType != XmlNodeType.None))
     {
         if (base.Reader.NodeType == XmlNodeType.Element)
         {
             if ((!flagArray[0] && (base.Reader.LocalName == this.id54_AllowEmptyCollection)) && (base.Reader.NamespaceURI == this.id2_Item))
             {
                 o.AllowEmptyCollection = this.Read1_Object(false, true);
                 flagArray[0] = true;
             }
             else if ((!flagArray[1] && (base.Reader.LocalName == this.id55_AllowEmptyString)) && (base.Reader.NamespaceURI == this.id2_Item))
             {
                 o.AllowEmptyString = this.Read1_Object(false, true);
                 flagArray[1] = true;
             }
             else if ((!flagArray[2] && (base.Reader.LocalName == this.id56_AllowNull)) && (base.Reader.NamespaceURI == this.id2_Item))
             {
                 o.AllowNull = this.Read1_Object(false, true);
                 flagArray[2] = true;
             }
             else if ((!flagArray[3] && (base.Reader.LocalName == this.id57_ValidateNotNull)) && (base.Reader.NamespaceURI == this.id2_Item))
             {
                 o.ValidateNotNull = this.Read1_Object(false, true);
                 flagArray[3] = true;
             }
             else if ((!flagArray[4] && (base.Reader.LocalName == this.id58_ValidateNotNullOrEmpty)) && (base.Reader.NamespaceURI == this.id2_Item))
             {
                 o.ValidateNotNullOrEmpty = this.Read1_Object(false, true);
                 flagArray[4] = true;
             }
             else if ((!flagArray[5] && (base.Reader.LocalName == this.id59_ValidateCount)) && (base.Reader.NamespaceURI == this.id2_Item))
             {
                 o.ValidateCount = this.Read4_Item(false, true);
                 flagArray[5] = true;
             }
             else if ((!flagArray[6] && (base.Reader.LocalName == this.id60_ValidateLength)) && (base.Reader.NamespaceURI == this.id2_Item))
             {
                 o.ValidateLength = this.Read5_Item(false, true);
                 flagArray[6] = true;
             }
             else if ((!flagArray[7] && (base.Reader.LocalName == this.id61_ValidateRange)) && (base.Reader.NamespaceURI == this.id2_Item))
             {
                 o.ValidateRange = this.Read6_Item(false, true);
                 flagArray[7] = true;
             }
             else if ((base.Reader.LocalName == this.id62_ValidateSet) && (base.Reader.NamespaceURI == this.id2_Item))
             {
                 if (!base.ReadNull())
                 {
                     string[] strArray5 = null;
                     int num7 = 0;
                     if (base.Reader.IsEmptyElement)
                     {
                         base.Reader.Skip();
                     }
                     else
                     {
                         base.Reader.ReadStartElement();
                         base.Reader.MoveToContent();
                         int num8 = 0;
                         int num9 = base.ReaderCount;
                         while ((base.Reader.NodeType != XmlNodeType.EndElement) && (base.Reader.NodeType != XmlNodeType.None))
                         {
                             if (base.Reader.NodeType == XmlNodeType.Element)
                             {
                                 if ((base.Reader.LocalName == this.id63_AllowedValue) && (base.Reader.NamespaceURI == this.id2_Item))
                                 {
                                     strArray5 = (string[]) base.EnsureArrayIndex(strArray5, num7, typeof(string));
                                     strArray5[num7++] = base.Reader.ReadElementString();
                                 }
                                 else
                                 {
                                     base.UnknownNode(null, "http://schemas.microsoft.com/cmdlets-over-objects/2009/11:AllowedValue");
                                 }
                             }
                             else
                             {
                                 base.UnknownNode(null, "http://schemas.microsoft.com/cmdlets-over-objects/2009/11:AllowedValue");
                             }
                             base.Reader.MoveToContent();
                             base.CheckReaderCount(ref num8, ref num9);
                         }
                         base.ReadEndElement();
                     }
                     o.ValidateSet = (string[]) base.ShrinkArray(strArray5, num7, typeof(string), false);
                 }
             }
             else
             {
                 base.UnknownNode(o, "http://schemas.microsoft.com/cmdlets-over-objects/2009/11:AllowEmptyCollection, http://schemas.microsoft.com/cmdlets-over-objects/2009/11:AllowEmptyString, http://schemas.microsoft.com/cmdlets-over-objects/2009/11:AllowNull, http://schemas.microsoft.com/cmdlets-over-objects/2009/11:ValidateNotNull, http://schemas.microsoft.com/cmdlets-over-objects/2009/11:ValidateNotNullOrEmpty, http://schemas.microsoft.com/cmdlets-over-objects/2009/11:ValidateCount, http://schemas.microsoft.com/cmdlets-over-objects/2009/11:ValidateLength, http://schemas.microsoft.com/cmdlets-over-objects/2009/11:ValidateRange, http://schemas.microsoft.com/cmdlets-over-objects/2009/11:ValidateSet");
             }
         }
         else
         {
             base.UnknownNode(o, "http://schemas.microsoft.com/cmdlets-over-objects/2009/11:AllowEmptyCollection, http://schemas.microsoft.com/cmdlets-over-objects/2009/11:AllowEmptyString, http://schemas.microsoft.com/cmdlets-over-objects/2009/11:AllowNull, http://schemas.microsoft.com/cmdlets-over-objects/2009/11:ValidateNotNull, http://schemas.microsoft.com/cmdlets-over-objects/2009/11:ValidateNotNullOrEmpty, http://schemas.microsoft.com/cmdlets-over-objects/2009/11:ValidateCount, http://schemas.microsoft.com/cmdlets-over-objects/2009/11:ValidateLength, http://schemas.microsoft.com/cmdlets-over-objects/2009/11:ValidateRange, http://schemas.microsoft.com/cmdlets-over-objects/2009/11:ValidateSet");
         }
         base.Reader.MoveToContent();
         base.CheckReaderCount(ref whileIterations, ref readerCount);
     }
     o.Aliases = (string[]) base.ShrinkArray(a, index, typeof(string), true);
     o.CmdletParameterSets = (string[]) base.ShrinkArray(strArray2, num2, typeof(string), true);
     base.ReadEndElement();
     return o;
 }
Пример #4
0
        private ParameterMetadata GetParameter(
            IEnumerable<string> queryParameterSets,
            string objectModelParameterName,
            TypeMetadata parameterType,
            CmdletParameterMetadataForGetCmdletParameter parameterCmdletization)
        {
            ParameterMetadata result = GetParameter(
                ParameterAttribute.AllParameterSets,
                objectModelParameterName,
                parameterType,
                parameterCmdletization,
                parameterCmdletization != null && parameterCmdletization.ValueFromPipelineSpecified && parameterCmdletization.ValueFromPipeline,
                parameterCmdletization != null && parameterCmdletization.ValueFromPipelineByPropertyNameSpecified && parameterCmdletization.ValueFromPipelineByPropertyName);

            ParameterSetMetadata parameterSetMetadata = result.ParameterSets[ParameterAttribute.AllParameterSets];
            result.ParameterSets.Clear();
            if (parameterCmdletization != null && parameterCmdletization.CmdletParameterSets != null && parameterCmdletization.CmdletParameterSets.Length > 0)
            {
                queryParameterSets = parameterCmdletization.CmdletParameterSets;
            }
            foreach (string parameterSetName in queryParameterSets)
            {
                if (parameterSetName.Equals(ScriptWriter.InputObjectQueryParameterSetName, StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                result.ParameterSets.Add(parameterSetName, parameterSetMetadata);
            }

            return result;
        }