Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / XmlUtils / System / Xml / Xsl / QIL / QilList.cs / 1305376 / 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 QilFactory .
///
internal class QilList : QilNode {
private int count;
private QilNode[] members;
//-----------------------------------------------
// Constructor
//-----------------------------------------------
///
/// 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);
Debug.Assert(!xt.IsDod, "Sequences do not preserve DocOrderDistinct");
}
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;
}
//-----------------------------------------------
// IList methods -- 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 QilFactory .
///
internal class QilList : QilNode {
private int count;
private QilNode[] members;
//-----------------------------------------------
// Constructor
//-----------------------------------------------
///
/// 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);
Debug.Assert(!xt.IsDod, "Sequences do not preserve DocOrderDistinct");
}
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;
}
//-----------------------------------------------
// IList methods -- 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
- FileSystemWatcher.cs
- DynamicDataRouteHandler.cs
- ItemList.cs
- ThreadAttributes.cs
- WindowsListView.cs
- WinInet.cs
- XPathBuilder.cs
- XmlEnumAttribute.cs
- TypefaceMap.cs
- CaseInsensitiveOrdinalStringComparer.cs
- CalendarTable.cs
- ScriptHandlerFactory.cs
- GridViewSelectEventArgs.cs
- LayoutEditorPart.cs
- ListChangedEventArgs.cs
- StateRuntime.cs
- WebPartMenu.cs
- PropertyTabAttribute.cs
- SerialErrors.cs
- OdbcPermission.cs
- Constants.cs
- ProfileEventArgs.cs
- StringStorage.cs
- EventLog.cs
- DriveInfo.cs
- WebMessageBodyStyleHelper.cs
- IRCollection.cs
- SurrogateSelector.cs
- AssemblyLoader.cs
- DynamicActivityProperty.cs
- ValidatedControlConverter.cs
- Argument.cs
- BitmapEffectvisualstate.cs
- SHA512Managed.cs
- ControlPaint.cs
- IsolationInterop.cs
- PolyBezierSegment.cs
- Timeline.cs
- AnimationException.cs
- DynamicPropertyReader.cs
- NeutralResourcesLanguageAttribute.cs
- PackageRelationship.cs
- TextAction.cs
- PersonalizationState.cs
- X509ServiceCertificateAuthenticationElement.cs
- basevalidator.cs
- DynamicDocumentPaginator.cs
- Journal.cs
- _FtpControlStream.cs
- FixedDocumentSequencePaginator.cs
- ActivityCodeDomSerializationManager.cs
- KeyManager.cs
- DispatcherOperation.cs
- RulePatternOps.cs
- SpoolingTask.cs
- RegistryPermission.cs
- CustomWebEventKey.cs
- SoapIgnoreAttribute.cs
- IOThreadTimer.cs
- ClassicBorderDecorator.cs
- StylusPointProperties.cs
- Line.cs
- PropertyReferenceExtension.cs
- DefaultAutoFieldGenerator.cs
- ProviderBase.cs
- XmlCharCheckingReader.cs
- SiteMapDesignerDataSourceView.cs
- BigInt.cs
- HTMLTextWriter.cs
- WebPartEditVerb.cs
- ColorTransformHelper.cs
- CompatibleComparer.cs
- PingReply.cs
- PageAsyncTask.cs
- InternalCompensate.cs
- ControlUtil.cs
- GPRECT.cs
- DataListItemEventArgs.cs
- SQLMoneyStorage.cs
- StringTraceRecord.cs
- ExpressionLexer.cs
- DiscreteKeyFrames.cs
- DataPagerFieldCommandEventArgs.cs
- MessageEventSubscriptionService.cs
- TextBoxAutoCompleteSourceConverter.cs
- TextSelectionProcessor.cs
- HttpResponse.cs
- NetDispatcherFaultException.cs
- XmlWhitespace.cs
- RenderCapability.cs
- DataSvcMapFile.cs
- IItemProperties.cs
- Queue.cs
- ForeignConstraint.cs
- ClientOptions.cs
- InvalidOperationException.cs
- CodeTypeDelegate.cs
- Geometry3D.cs
- SoapEnumAttribute.cs
- WebRequestModulesSection.cs