Exemplo n.º 1
0
 private PropertyMetadata Read14_PropertyMetadata(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.id7_PropertyMetadata) || (type.Namespace != this.id2_Item)))
     {
         throw base.CreateUnknownTypeException(type);
     }
     if (flag)
     {
         return null;
     }
     PropertyMetadata o = new PropertyMetadata();
     PropertyQuery[] a = null;
     int length = 0;
     ItemsChoiceType[] typeArray = null;
     int num2 = 0;
     bool[] flagArray = new bool[3];
     while (base.Reader.MoveToNextAttribute())
     {
         if ((!flagArray[2] && (base.Reader.LocalName == this.id101_PropertyName)) && (base.Reader.NamespaceURI == this.id4_Item))
         {
             o.PropertyName = base.Reader.Value;
             flagArray[2] = true;
         }
         else if (!base.IsXmlnsAttribute(base.Reader.Name))
         {
             base.UnknownNode(o, ":PropertyName");
         }
     }
     base.Reader.MoveToElement();
     if (base.Reader.IsEmptyElement)
     {
         base.Reader.Skip();
         o.Items = (PropertyQuery[]) base.ShrinkArray(a, length, typeof(PropertyQuery), true);
         o.ItemsElementName = (ItemsChoiceType[]) base.ShrinkArray(typeArray, num2, typeof(ItemsChoiceType), 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.id89_Type)) && (base.Reader.NamespaceURI == this.id2_Item))
             {
                 o.Type = this.Read2_TypeMetadata(false, true);
                 flagArray[0] = true;
             }
             else if ((base.Reader.LocalName == this.id102_MinValueQuery) && (base.Reader.NamespaceURI == this.id2_Item))
             {
                 a = (PropertyQuery[]) base.EnsureArrayIndex(a, length, typeof(PropertyQuery));
                 a[length++] = this.Read13_PropertyQuery(false, true);
                 typeArray = (ItemsChoiceType[]) base.EnsureArrayIndex(typeArray, num2, typeof(ItemsChoiceType));
                 typeArray[num2++] = ItemsChoiceType.MinValueQuery;
             }
             else if ((base.Reader.LocalName == this.id103_RegularQuery) && (base.Reader.NamespaceURI == this.id2_Item))
             {
                 a = (PropertyQuery[]) base.EnsureArrayIndex(a, length, typeof(PropertyQuery));
                 a[length++] = this.Read12_WildcardablePropertyQuery(false, true);
                 typeArray = (ItemsChoiceType[]) base.EnsureArrayIndex(typeArray, num2, typeof(ItemsChoiceType));
                 typeArray[num2++] = ItemsChoiceType.RegularQuery;
             }
             else if ((base.Reader.LocalName == this.id104_MaxValueQuery) && (base.Reader.NamespaceURI == this.id2_Item))
             {
                 a = (PropertyQuery[]) base.EnsureArrayIndex(a, length, typeof(PropertyQuery));
                 a[length++] = this.Read13_PropertyQuery(false, true);
                 typeArray = (ItemsChoiceType[]) base.EnsureArrayIndex(typeArray, num2, typeof(ItemsChoiceType));
                 typeArray[num2++] = ItemsChoiceType.MaxValueQuery;
             }
             else if ((base.Reader.LocalName == this.id105_ExcludeQuery) && (base.Reader.NamespaceURI == this.id2_Item))
             {
                 a = (PropertyQuery[]) base.EnsureArrayIndex(a, length, typeof(PropertyQuery));
                 a[length++] = this.Read12_WildcardablePropertyQuery(false, true);
                 typeArray = (ItemsChoiceType[]) base.EnsureArrayIndex(typeArray, num2, typeof(ItemsChoiceType));
                 typeArray[num2++] = ItemsChoiceType.ExcludeQuery;
             }
             else
             {
                 base.UnknownNode(o, "http://schemas.microsoft.com/cmdlets-over-objects/2009/11:Type, http://schemas.microsoft.com/cmdlets-over-objects/2009/11:MinValueQuery, http://schemas.microsoft.com/cmdlets-over-objects/2009/11:RegularQuery, http://schemas.microsoft.com/cmdlets-over-objects/2009/11:MaxValueQuery, http://schemas.microsoft.com/cmdlets-over-objects/2009/11:ExcludeQuery");
             }
         }
         else
         {
             base.UnknownNode(o, "http://schemas.microsoft.com/cmdlets-over-objects/2009/11:Type, http://schemas.microsoft.com/cmdlets-over-objects/2009/11:MinValueQuery, http://schemas.microsoft.com/cmdlets-over-objects/2009/11:RegularQuery, http://schemas.microsoft.com/cmdlets-over-objects/2009/11:MaxValueQuery, http://schemas.microsoft.com/cmdlets-over-objects/2009/11:ExcludeQuery");
         }
         base.Reader.MoveToContent();
         base.CheckReaderCount(ref whileIterations, ref readerCount);
     }
     o.Items = (PropertyQuery[]) base.ShrinkArray(a, length, typeof(PropertyQuery), true);
     o.ItemsElementName = (ItemsChoiceType[]) base.ShrinkArray(typeArray, num2, typeof(ItemsChoiceType), true);
     base.ReadEndElement();
     return o;
 }
Exemplo n.º 2
0
 private ParameterMetadata GenerateQueryClause(IEnumerable<string> commonParameterSets, IEnumerable<string> queryParameterSets, IEnumerable<string> methodParameterSets, string queryBuilderMethodName, PropertyMetadata property, PropertyQuery query, TextWriter output)
 {
     ParameterMetadata cmdletParameterMetadata = this.GetParameter(queryParameterSets, property.PropertyName, property.Type, query.CmdletParameterMetadata);
     WildcardablePropertyQuery query2 = query as WildcardablePropertyQuery;
     if ((query2 != null) && !cmdletParameterMetadata.SwitchParameter)
     {
         if (cmdletParameterMetadata.ParameterType == null)
         {
             cmdletParameterMetadata.ParameterType = typeof(object);
         }
         cmdletParameterMetadata.ParameterType = cmdletParameterMetadata.ParameterType.MakeArrayType();
     }
     this.GenerateIfBoundParameter(commonParameterSets, methodParameterSets, cmdletParameterMetadata, output);
     string str = (query2 == null) ? "__cmdletization_value" : "__cmdletization_values";
     if (query2 == null)
     {
         output.WriteLine("        [object]${0} = ${{{1}}}", str, CommandMetadata.EscapeVariableName(cmdletParameterMetadata.Name));
     }
     else
     {
         output.WriteLine("        ${0} = @(${{{1}}})", str, CommandMetadata.EscapeVariableName(cmdletParameterMetadata.Name));
     }
     output.Write("        $__cmdletization_queryBuilder.{0}('{1}', ${2}", queryBuilderMethodName, CommandMetadata.EscapeSingleQuotedString(property.PropertyName), str);
     if (query2 == null)
     {
         output.WriteLine(", '{0}')", GetBehaviorWhenNoMatchesFound(query.CmdletParameterMetadata));
     }
     else
     {
         bool flag = (!query2.AllowGlobbingSpecified && cmdletParameterMetadata.ParameterType.Equals(typeof(string[]))) || (query2.AllowGlobbingSpecified && query2.AllowGlobbing);
         output.WriteLine(", {0}, '{1}')", flag ? "$true" : "$false", GetBehaviorWhenNoMatchesFound(query.CmdletParameterMetadata));
     }
     output.WriteLine("    }");
     return cmdletParameterMetadata;
 }
Exemplo n.º 3
0
 private void Write14_PropertyMetadata(string n, string ns, PropertyMetadata o, bool isNullable, bool needType)
 {
     if (o == null)
     {
         if (isNullable)
         {
             base.WriteNullTagLiteral(n, ns);
         }
     }
     else
     {
         if (!needType && !(o.GetType() == typeof(PropertyMetadata)))
         {
             throw base.CreateUnknownTypeException(o);
         }
         base.WriteStartElement(n, ns, o, false, null);
         if (needType)
         {
             base.WriteXsiType("PropertyMetadata", "http://schemas.microsoft.com/cmdlets-over-objects/2009/11");
         }
         base.WriteAttribute("PropertyName", "", o.PropertyName);
         this.Write2_TypeMetadata("Type", "http://schemas.microsoft.com/cmdlets-over-objects/2009/11", o.Type, false, false);
         PropertyQuery[] items = o.Items;
         if (items != null)
         {
             ItemsChoiceType[] itemsElementName = o.ItemsElementName;
             if ((itemsElementName == null) || (itemsElementName.Length < items.Length))
             {
                 throw base.CreateInvalidChoiceIdentifierValueException("Microsoft.PowerShell.Cmdletization.Xml.ItemsChoiceType", "ItemsElementName");
             }
             for (int i = 0; i < items.Length; i++)
             {
                 PropertyQuery query = items[i];
                 ItemsChoiceType type2 = itemsElementName[i];
                 if ((type2 == ItemsChoiceType.ExcludeQuery) && (query != null))
                 {
                     if ((query != null) && !(query is WildcardablePropertyQuery))
                     {
                         throw base.CreateMismatchChoiceException("Microsoft.PowerShell.Cmdletization.Xml.WildcardablePropertyQuery", "ItemsElementName", "Microsoft.PowerShell.Cmdletization.Xml.ItemsChoiceType.@ExcludeQuery");
                     }
                     this.Write12_WildcardablePropertyQuery("ExcludeQuery", "http://schemas.microsoft.com/cmdlets-over-objects/2009/11", (WildcardablePropertyQuery) query, false, false);
                 }
                 else if ((type2 == ItemsChoiceType.RegularQuery) && (query != null))
                 {
                     if ((query != null) && !(query is WildcardablePropertyQuery))
                     {
                         throw base.CreateMismatchChoiceException("Microsoft.PowerShell.Cmdletization.Xml.WildcardablePropertyQuery", "ItemsElementName", "Microsoft.PowerShell.Cmdletization.Xml.ItemsChoiceType.@RegularQuery");
                     }
                     this.Write12_WildcardablePropertyQuery("RegularQuery", "http://schemas.microsoft.com/cmdlets-over-objects/2009/11", (WildcardablePropertyQuery) query, false, false);
                 }
                 else if ((type2 == ItemsChoiceType.MinValueQuery) && (query != null))
                 {
                     if ((query != null) && (query == null))
                     {
                         throw base.CreateMismatchChoiceException("Microsoft.PowerShell.Cmdletization.Xml.PropertyQuery", "ItemsElementName", "Microsoft.PowerShell.Cmdletization.Xml.ItemsChoiceType.@MinValueQuery");
                     }
                     this.Write13_PropertyQuery("MinValueQuery", "http://schemas.microsoft.com/cmdlets-over-objects/2009/11", query, false, false);
                 }
                 else if ((type2 == ItemsChoiceType.MaxValueQuery) && (query != null))
                 {
                     if ((query != null) && (query == null))
                     {
                         throw base.CreateMismatchChoiceException("Microsoft.PowerShell.Cmdletization.Xml.PropertyQuery", "ItemsElementName", "Microsoft.PowerShell.Cmdletization.Xml.ItemsChoiceType.@MaxValueQuery");
                     }
                     this.Write13_PropertyQuery("MaxValueQuery", "http://schemas.microsoft.com/cmdlets-over-objects/2009/11", query, false, false);
                 }
                 else if (query != null)
                 {
                     throw base.CreateUnknownTypeException(query);
                 }
             }
         }
         base.WriteEndElement(o);
     }
 }