Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / XmlUtils / System / Xml / Xsl / QIL / QilList.cs / 1 / QilList.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Diagnostics; namespace System.Xml.Xsl.Qil { ////// View over a Qil operator having N children. /// ////// Don't construct QIL nodes directly; instead, use the internal class QilList : QilNode { private int count; private QilNode[] members; //----------------------------------------------- // Constructor //----------------------------------------------- ///QilFactory . ////// Construct a new (empty) QilList /// public QilList(QilNodeType nodeType) : base(nodeType) { this.members = new QilNode[4]; this.xmlType = null; } //----------------------------------------------- // QilNode methods //----------------------------------------------- ////// Lazily create the XmlQueryType. /// public override XmlQueryType XmlType { get { if (this.xmlType == null) { XmlQueryType xt = XmlQueryTypeFactory.Empty; if (this.count > 0) { if (this.nodeType == QilNodeType.Sequence) { for (int i = 0; i < this.count; i++) xt = XmlQueryTypeFactory.Sequence(xt, this.members[i].XmlType); // Sequences do not preserve DocOrderDistinct if (xt.IsDod) xt = XmlQueryTypeFactory.PrimeProduct(XmlQueryTypeFactory.NodeNotRtfS, xt.Cardinality); } else if (this.nodeType == QilNodeType.BranchList) { xt = this.members[0].XmlType; for (int i = 1; i < this.count; i++) xt = XmlQueryTypeFactory.Choice(xt, this.members[i].XmlType); } } this.xmlType = xt; } return this.xmlType; } } ////// Override in order to clone the "members" array. /// public override QilNode ShallowClone(QilFactory f) { QilList n = (QilList) MemberwiseClone(); n.members = (QilNode[]) this.members.Clone(); f.TraceNode(n); return n; } //----------------------------------------------- // IListmethods -- override //----------------------------------------------- public override int Count { get { return this.count; } } public override QilNode this[int index] { get { if (index >= 0 && index < this.count) return this.members[index]; throw new IndexOutOfRangeException(); } set { if (index >= 0 && index < this.count) this.members[index] = value; else throw new IndexOutOfRangeException(); // Invalidate XmlType this.xmlType = null; } } public override void Insert(int index, QilNode node) { if (index < 0 || index > this.count) throw new IndexOutOfRangeException(); if (this.count == this.members.Length) { QilNode[] membersNew = new QilNode[this.count * 2]; Array.Copy(this.members, membersNew, this.count); this.members = membersNew; } if (index < this.count) Array.Copy(this.members, index, this.members, index + 1, this.count - index); this.count++; this.members[index] = node; // Invalidate XmlType this.xmlType = null; } public override void RemoveAt(int index) { if (index < 0 || index >= this.count) throw new IndexOutOfRangeException(); this.count--; if (index < this.count) Array.Copy(this.members, index + 1, this.members, index, this.count - index); this.members[this.count] = null; // Invalidate XmlType this.xmlType = null; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Diagnostics; namespace System.Xml.Xsl.Qil { ////// View over a Qil operator having N children. /// ////// Don't construct QIL nodes directly; instead, use the internal class QilList : QilNode { private int count; private QilNode[] members; //----------------------------------------------- // Constructor //----------------------------------------------- ///QilFactory . ////// Construct a new (empty) QilList /// public QilList(QilNodeType nodeType) : base(nodeType) { this.members = new QilNode[4]; this.xmlType = null; } //----------------------------------------------- // QilNode methods //----------------------------------------------- ////// Lazily create the XmlQueryType. /// public override XmlQueryType XmlType { get { if (this.xmlType == null) { XmlQueryType xt = XmlQueryTypeFactory.Empty; if (this.count > 0) { if (this.nodeType == QilNodeType.Sequence) { for (int i = 0; i < this.count; i++) xt = XmlQueryTypeFactory.Sequence(xt, this.members[i].XmlType); // Sequences do not preserve DocOrderDistinct if (xt.IsDod) xt = XmlQueryTypeFactory.PrimeProduct(XmlQueryTypeFactory.NodeNotRtfS, xt.Cardinality); } else if (this.nodeType == QilNodeType.BranchList) { xt = this.members[0].XmlType; for (int i = 1; i < this.count; i++) xt = XmlQueryTypeFactory.Choice(xt, this.members[i].XmlType); } } this.xmlType = xt; } return this.xmlType; } } ////// Override in order to clone the "members" array. /// public override QilNode ShallowClone(QilFactory f) { QilList n = (QilList) MemberwiseClone(); n.members = (QilNode[]) this.members.Clone(); f.TraceNode(n); return n; } //----------------------------------------------- // IListmethods -- override //----------------------------------------------- public override int Count { get { return this.count; } } public override QilNode this[int index] { get { if (index >= 0 && index < this.count) return this.members[index]; throw new IndexOutOfRangeException(); } set { if (index >= 0 && index < this.count) this.members[index] = value; else throw new IndexOutOfRangeException(); // Invalidate XmlType this.xmlType = null; } } public override void Insert(int index, QilNode node) { if (index < 0 || index > this.count) throw new IndexOutOfRangeException(); if (this.count == this.members.Length) { QilNode[] membersNew = new QilNode[this.count * 2]; Array.Copy(this.members, membersNew, this.count); this.members = membersNew; } if (index < this.count) Array.Copy(this.members, index, this.members, index + 1, this.count - index); this.count++; this.members[index] = node; // Invalidate XmlType this.xmlType = null; } public override void RemoveAt(int index) { if (index < 0 || index >= this.count) throw new IndexOutOfRangeException(); this.count--; if (index < this.count) Array.Copy(this.members, index + 1, this.members, index, this.count - index); this.members[this.count] = null; // Invalidate XmlType this.xmlType = null; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- EncryptedPackage.cs
- CheckBoxFlatAdapter.cs
- ComponentDispatcherThread.cs
- Path.cs
- FontInfo.cs
- MenuTracker.cs
- templategroup.cs
- Vector3DAnimation.cs
- TransformGroup.cs
- ExceptionNotification.cs
- DataControlReferenceCollection.cs
- HttpCacheVaryByContentEncodings.cs
- ConfigurationManagerInternal.cs
- CodePrimitiveExpression.cs
- ContextMenuStrip.cs
- Transform.cs
- StructuralCache.cs
- MetaDataInfo.cs
- TextSpanModifier.cs
- SafeReversePInvokeHandle.cs
- TraceInternal.cs
- XamlVector3DCollectionSerializer.cs
- SpellCheck.cs
- SoapElementAttribute.cs
- SourceElementsCollection.cs
- SessionPageStateSection.cs
- ConstructorBuilder.cs
- WeakHashtable.cs
- ClientCredentialsSecurityTokenManager.cs
- TemplateControlBuildProvider.cs
- PrintDialogDesigner.cs
- ChangePassword.cs
- LambdaCompiler.Lambda.cs
- File.cs
- ProtectedProviderSettings.cs
- Ray3DHitTestResult.cs
- RegularExpressionValidator.cs
- ReferentialConstraintRoleElement.cs
- HostSecurityManager.cs
- AssemblyAttributesGoHere.cs
- CurrentChangingEventArgs.cs
- UniqueCodeIdentifierScope.cs
- CurrentChangingEventManager.cs
- UnsafeNativeMethods.cs
- metrodevice.cs
- PopOutPanel.cs
- CipherData.cs
- ByteStream.cs
- XslUrlEditor.cs
- XhtmlBasicListAdapter.cs
- StreamReader.cs
- HtmlTableRowCollection.cs
- RowToFieldTransformer.cs
- Timer.cs
- Point3DCollectionValueSerializer.cs
- EditorZoneAutoFormat.cs
- VariableQuery.cs
- HandledMouseEvent.cs
- ResizingMessageFilter.cs
- ErrorWrapper.cs
- SerializationFieldInfo.cs
- TextTreeText.cs
- Schema.cs
- HierarchicalDataTemplate.cs
- DbExpressionBuilder.cs
- HijriCalendar.cs
- InputScope.cs
- arc.cs
- ErrorTableItemStyle.cs
- GridItemPattern.cs
- XhtmlBasicValidatorAdapter.cs
- WebPartMinimizeVerb.cs
- AddInSegmentDirectoryNotFoundException.cs
- XmlTypeAttribute.cs
- SvcMapFileSerializer.cs
- TypeConverterHelper.cs
- TraceSection.cs
- While.cs
- WeakReference.cs
- Color.cs
- AspNetCacheProfileAttribute.cs
- ArgumentDirectionHelper.cs
- JapaneseCalendar.cs
- PageRanges.cs
- HandleExceptionArgs.cs
- DomainUpDown.cs
- LoginCancelEventArgs.cs
- Calendar.cs
- RulePatternOps.cs
- WeakEventTable.cs
- Pointer.cs
- PartialArray.cs
- CapabilitiesUse.cs
- FlowchartSizeFeature.cs
- Part.cs
- DataGridViewDataErrorEventArgs.cs
- PnrpPermission.cs
- BaseInfoTable.cs
- DecimalConstantAttribute.cs
- XmlElementAttributes.cs