Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / XmlUtils / System / Xml / Xsl / IlGen / StaticDataManager.cs / 1 / StaticDataManager.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
// [....]
//-----------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Xml.Xsl.Qil;
using System.Xml.Xsl.Runtime;
namespace System.Xml.Xsl.IlGen {
///
/// This internal class maintains a list of unique values. Each unique value is assigned a unique ID, which can
/// be used to quickly access the value, since it corresponds to the value's position in the list.
///
internal class UniqueList {
private Dictionary lookup = new Dictionary();
private List list = new List();
///
/// If "value" is already in the list, do not add it. Return the unique ID of the value in the list.
///
public int Add(T value) {
int id;
if (!this.lookup.ContainsKey(value)) {
// The value does not yet exist, so add it to the list
id = list.Count;
this.lookup.Add(value, id);
this.list.Add(value);
}
else {
id = this.lookup[value];
}
return id;
}
///
/// Return an array of the unique values.
///
public T[] ToArray() {
return list.ToArray();
}
}
///
/// Manages all static data that is used by the runtime. This includes:
/// 1. All NCName and QName atoms that will be used at run-time
/// 2. All QName filters that will be used at run-time
/// 3. All Xml types that will be used at run-time
/// 4. All global variables and parameters
///
internal class StaticDataManager {
private UniqueList uniqueNames;
private UniqueList uniqueFilters;
private List prefixMappingsList;
private List globalNames;
private UniqueList earlyInfo;
private UniqueList uniqueXmlTypes;
private UniqueList uniqueCollations;
///
/// Add "name" to the list of unique names that are used by this query. Return the index of
/// the unique name in the list.
///
public int DeclareName(string name) {
if (this.uniqueNames == null)
this.uniqueNames = new UniqueList();
return this.uniqueNames.Add(name);
}
///
/// Return an array of all names that are used by the query (null if no names).
///
public string[] Names {
get { return (this.uniqueNames != null) ? this.uniqueNames.ToArray() : null; }
}
///
/// Add a name filter to the list of unique filters that are used by this query. Return the index of
/// the unique filter in the list.
///
public int DeclareNameFilter(string locName, string nsUri) {
if (this.uniqueFilters == null)
this.uniqueFilters = new UniqueList();
return this.uniqueFilters.Add(new Int32Pair(DeclareName(locName), DeclareName(nsUri)));
}
///
/// Return an array of all name filters, where each name filter is represented as a pair of integer offsets (localName, namespaceUri)
/// into the Names array (null if no name filters).
///
public Int32Pair[] NameFilters {
get { return (this.uniqueFilters != null) ? this.uniqueFilters.ToArray() : null; }
}
///
/// Add a list of QilExpression NamespaceDeclarations to an array of strings (prefix followed by namespace URI).
/// Return index of the prefix mappings within this array.
///
public int DeclarePrefixMappings(IList list) {
StringPair[] prefixMappings;
// Fill mappings array
prefixMappings = new StringPair[list.Count];
for (int i = 0; i < list.Count; i++) {
// Each entry in mappings array must be a constant NamespaceDeclaration
QilBinary ndNmspDecl = (QilBinary) list[i];
Debug.Assert(ndNmspDecl != null);
Debug.Assert(ndNmspDecl.Left is QilLiteral && ndNmspDecl.Right is QilLiteral);
prefixMappings[i] = new StringPair((string) (QilLiteral) ndNmspDecl.Left, (string) (QilLiteral) ndNmspDecl.Right);
}
// Add mappings to list and return index
if (this.prefixMappingsList == null)
this.prefixMappingsList = new List();
this.prefixMappingsList.Add(prefixMappings);
return this.prefixMappingsList.Count - 1;
}
///
/// Return an array of all prefix mappings that are used by the query to compute names (null if no mappings).
///
public StringPair[][] PrefixMappingsList {
get { return (this.prefixMappingsList != null) ? this.prefixMappingsList.ToArray() : null; }
}
///
/// Declare a new global variable or parameter.
///
public int DeclareGlobalValue(string name) {
int idx;
if (this.globalNames == null)
this.globalNames = new List();
idx = this.globalNames.Count;
this.globalNames.Add(name);
return idx;
}
///
/// Return an array containing the names of all global variables and parameters.
///
public string[] GlobalNames {
get { return (this.globalNames != null) ? this.globalNames.ToArray() : null; }
}
///
/// Add early bound information to a list that is used by this query. Return the index of
/// the early bound information in the list.
///
public int DeclareEarlyBound(string namespaceUri, Type ebType) {
if (this.earlyInfo == null)
this.earlyInfo = new UniqueList();
return this.earlyInfo.Add(new EarlyBoundInfo(namespaceUri, ebType));
}
///
/// Return an array of all early bound information that is used by the query (null if none is used).
///
public EarlyBoundInfo[] EarlyBound {
get {
if (this.earlyInfo != null)
return this.earlyInfo.ToArray();
return null;
}
}
///
/// Add "type" to the list of unique types that are used by this query. Return the index of
/// the unique type in the list.
///
public int DeclareXmlType(XmlQueryType type) {
if (this.uniqueXmlTypes == null)
this.uniqueXmlTypes = new UniqueList();
XmlQueryTypeFactory.CheckSerializability(type);
return this.uniqueXmlTypes.Add(type);
}
///
/// Return an array of all types that are used by the query (null if no names).
///
public XmlQueryType[] XmlTypes {
get { return (this.uniqueXmlTypes != null) ? this.uniqueXmlTypes.ToArray() : null; }
}
///
/// Add "collation" to the list of unique collations that are used by this query. Return the index of
/// the unique collation in the list.
///
public int DeclareCollation(string collation) {
if (this.uniqueCollations == null)
this.uniqueCollations = new UniqueList();
return this.uniqueCollations.Add(XmlCollation.Create(collation));
}
///
/// Return an array of all collations that are used by the query (null if no names).
///
public XmlCollation[] Collations {
get { return (this.uniqueCollations != null) ? this.uniqueCollations.ToArray() : null; }
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
// [....]
//-----------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Xml.Xsl.Qil;
using System.Xml.Xsl.Runtime;
namespace System.Xml.Xsl.IlGen {
///
/// This internal class maintains a list of unique values. Each unique value is assigned a unique ID, which can
/// be used to quickly access the value, since it corresponds to the value's position in the list.
///
internal class UniqueList {
private Dictionary lookup = new Dictionary();
private List list = new List();
///
/// If "value" is already in the list, do not add it. Return the unique ID of the value in the list.
///
public int Add(T value) {
int id;
if (!this.lookup.ContainsKey(value)) {
// The value does not yet exist, so add it to the list
id = list.Count;
this.lookup.Add(value, id);
this.list.Add(value);
}
else {
id = this.lookup[value];
}
return id;
}
///
/// Return an array of the unique values.
///
public T[] ToArray() {
return list.ToArray();
}
}
///
/// Manages all static data that is used by the runtime. This includes:
/// 1. All NCName and QName atoms that will be used at run-time
/// 2. All QName filters that will be used at run-time
/// 3. All Xml types that will be used at run-time
/// 4. All global variables and parameters
///
internal class StaticDataManager {
private UniqueList uniqueNames;
private UniqueList uniqueFilters;
private List prefixMappingsList;
private List globalNames;
private UniqueList earlyInfo;
private UniqueList uniqueXmlTypes;
private UniqueList uniqueCollations;
///
/// Add "name" to the list of unique names that are used by this query. Return the index of
/// the unique name in the list.
///
public int DeclareName(string name) {
if (this.uniqueNames == null)
this.uniqueNames = new UniqueList();
return this.uniqueNames.Add(name);
}
///
/// Return an array of all names that are used by the query (null if no names).
///
public string[] Names {
get { return (this.uniqueNames != null) ? this.uniqueNames.ToArray() : null; }
}
///
/// Add a name filter to the list of unique filters that are used by this query. Return the index of
/// the unique filter in the list.
///
public int DeclareNameFilter(string locName, string nsUri) {
if (this.uniqueFilters == null)
this.uniqueFilters = new UniqueList();
return this.uniqueFilters.Add(new Int32Pair(DeclareName(locName), DeclareName(nsUri)));
}
///
/// Return an array of all name filters, where each name filter is represented as a pair of integer offsets (localName, namespaceUri)
/// into the Names array (null if no name filters).
///
public Int32Pair[] NameFilters {
get { return (this.uniqueFilters != null) ? this.uniqueFilters.ToArray() : null; }
}
///
/// Add a list of QilExpression NamespaceDeclarations to an array of strings (prefix followed by namespace URI).
/// Return index of the prefix mappings within this array.
///
public int DeclarePrefixMappings(IList list) {
StringPair[] prefixMappings;
// Fill mappings array
prefixMappings = new StringPair[list.Count];
for (int i = 0; i < list.Count; i++) {
// Each entry in mappings array must be a constant NamespaceDeclaration
QilBinary ndNmspDecl = (QilBinary) list[i];
Debug.Assert(ndNmspDecl != null);
Debug.Assert(ndNmspDecl.Left is QilLiteral && ndNmspDecl.Right is QilLiteral);
prefixMappings[i] = new StringPair((string) (QilLiteral) ndNmspDecl.Left, (string) (QilLiteral) ndNmspDecl.Right);
}
// Add mappings to list and return index
if (this.prefixMappingsList == null)
this.prefixMappingsList = new List();
this.prefixMappingsList.Add(prefixMappings);
return this.prefixMappingsList.Count - 1;
}
///
/// Return an array of all prefix mappings that are used by the query to compute names (null if no mappings).
///
public StringPair[][] PrefixMappingsList {
get { return (this.prefixMappingsList != null) ? this.prefixMappingsList.ToArray() : null; }
}
///
/// Declare a new global variable or parameter.
///
public int DeclareGlobalValue(string name) {
int idx;
if (this.globalNames == null)
this.globalNames = new List();
idx = this.globalNames.Count;
this.globalNames.Add(name);
return idx;
}
///
/// Return an array containing the names of all global variables and parameters.
///
public string[] GlobalNames {
get { return (this.globalNames != null) ? this.globalNames.ToArray() : null; }
}
///
/// Add early bound information to a list that is used by this query. Return the index of
/// the early bound information in the list.
///
public int DeclareEarlyBound(string namespaceUri, Type ebType) {
if (this.earlyInfo == null)
this.earlyInfo = new UniqueList();
return this.earlyInfo.Add(new EarlyBoundInfo(namespaceUri, ebType));
}
///
/// Return an array of all early bound information that is used by the query (null if none is used).
///
public EarlyBoundInfo[] EarlyBound {
get {
if (this.earlyInfo != null)
return this.earlyInfo.ToArray();
return null;
}
}
///
/// Add "type" to the list of unique types that are used by this query. Return the index of
/// the unique type in the list.
///
public int DeclareXmlType(XmlQueryType type) {
if (this.uniqueXmlTypes == null)
this.uniqueXmlTypes = new UniqueList();
XmlQueryTypeFactory.CheckSerializability(type);
return this.uniqueXmlTypes.Add(type);
}
///
/// Return an array of all types that are used by the query (null if no names).
///
public XmlQueryType[] XmlTypes {
get { return (this.uniqueXmlTypes != null) ? this.uniqueXmlTypes.ToArray() : null; }
}
///
/// Add "collation" to the list of unique collations that are used by this query. Return the index of
/// the unique collation in the list.
///
public int DeclareCollation(string collation) {
if (this.uniqueCollations == null)
this.uniqueCollations = new UniqueList();
return this.uniqueCollations.Add(XmlCollation.Create(collation));
}
///
/// Return an array of all collations that are used by the query (null if no names).
///
public XmlCollation[] Collations {
get { return (this.uniqueCollations != null) ? this.uniqueCollations.ToArray() : 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
- SymmetricAlgorithm.cs
- MembershipPasswordException.cs
- StandardOleMarshalObject.cs
- CultureInfo.cs
- LinkLabelLinkClickedEvent.cs
- SqlComparer.cs
- MenuBindingsEditor.cs
- DataSourceDesigner.cs
- UnmanagedMemoryStream.cs
- Point.cs
- EventHandlersDesigner.cs
- ServiceChannelProxy.cs
- ListItemDetailViewAttribute.cs
- HtmlInputSubmit.cs
- IDataContractSurrogate.cs
- StickyNoteAnnotations.cs
- Rotation3DAnimationUsingKeyFrames.cs
- BitmapInitialize.cs
- DataTableCollection.cs
- AnimationException.cs
- TraceHelpers.cs
- InitializationEventAttribute.cs
- JsonReaderDelegator.cs
- XmlSchemaAny.cs
- RefreshPropertiesAttribute.cs
- ObjectSet.cs
- TextReader.cs
- NextPreviousPagerField.cs
- WindowsTokenRoleProvider.cs
- DocumentPageViewAutomationPeer.cs
- ProjectionQueryOptionExpression.cs
- OdbcHandle.cs
- WebPartCancelEventArgs.cs
- SecurityDescriptor.cs
- TimeZone.cs
- OnOperation.cs
- SchemaLookupTable.cs
- DataGridViewSortCompareEventArgs.cs
- BindingNavigator.cs
- SessionPageStateSection.cs
- ArglessEventHandlerProxy.cs
- FixedPage.cs
- ProviderIncompatibleException.cs
- ToolStripEditorManager.cs
- KeyValueConfigurationCollection.cs
- CommandID.cs
- RegexStringValidator.cs
- RTLAwareMessageBox.cs
- Int64.cs
- MissingMemberException.cs
- DeclarativeCatalogPart.cs
- ResourceKey.cs
- RSAOAEPKeyExchangeDeformatter.cs
- RoleGroupCollection.cs
- TagPrefixAttribute.cs
- ControlEvent.cs
- SafeNativeMethods.cs
- ObjectDataProvider.cs
- ExpressionConverter.cs
- WindowsToolbar.cs
- InputLanguageManager.cs
- ResolveNameEventArgs.cs
- ListSortDescriptionCollection.cs
- MetaColumn.cs
- HostedElements.cs
- NavigationExpr.cs
- DataSourceExpression.cs
- AppSettingsExpressionBuilder.cs
- CfgArc.cs
- TraceInternal.cs
- XmlValidatingReaderImpl.cs
- Substitution.cs
- DateTimeOffset.cs
- Cursors.cs
- CommandHelper.cs
- StandardOleMarshalObject.cs
- Block.cs
- ConnectionStringSettings.cs
- RowsCopiedEventArgs.cs
- BufferedGraphicsContext.cs
- BindingManagerDataErrorEventArgs.cs
- RoleManagerEventArgs.cs
- SqlExpressionNullability.cs
- NullableConverter.cs
- SafeLocalAllocation.cs
- AncestorChangedEventArgs.cs
- InvalidCastException.cs
- Resources.Designer.cs
- HttpPostedFileBase.cs
- MetadataItemEmitter.cs
- HandleExceptionArgs.cs
- IntSecurity.cs
- HandleCollector.cs
- UnmanagedMemoryStreamWrapper.cs
- _LocalDataStoreMgr.cs
- PowerModeChangedEventArgs.cs
- UIElement3D.cs
- DateTimeFormatInfo.cs
- StringReader.cs
- XmlHelper.cs