Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Markup / ParserStack.cs / 1305600 / ParserStack.cs
/****************************************************************************\ * * File: ParserStack.cs * * Purpose: ParserStack...once was in XamlReaderHelper.cs * * History: * 11/21/08: [....] Moved from XamlReaderHelper.cs as we were replacing the parser. * * Copyright (C) 2008 by Microsoft Corporation. All rights reserved. * \***************************************************************************/ using System; using System.Xml; using System.Xml.Serialization; using System.IO; using System.Text; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Reflection; using System.Globalization; using MS.Utility; using System.Collections.Specialized; using Microsoft.Win32; using System.Runtime.InteropServices; using MS.Internal; using System.Windows.Markup; #if !PBTCOMPILER using System.Windows; using System.Windows.Documents; using System.Windows.Media; using System.Windows.Shapes; #endif #if PBTCOMPILER namespace MS.Internal.Markup #else namespace System.Windows.Markup #endif { ////// Parser Context stack /// The built-in Stack class doesn't let you do things like look at nodes beyond the top of the stack... /// so we'll use this instead. Note that this is not a complete stack implementation -- if you try to /// convert to array or some such, you'll be missing a couple elements. But this is plenty for our purposes. /// Main goal is to track current/parent context with a minimum of overhead. /// This class is internal so it can be shared with the BamlRecordReader /// internal class ParserStack : ArrayList { ////// Creates a default ParserStack /// internal ParserStack() : base() { } ////// Creates a clone. /// private ParserStack(ICollection collection) : base(collection) { } #region StackOverrides public void Push(object o) { Add(o); } public object Pop() { object o = this[Count - 1]; RemoveAt(Count - 1); return o; } #if !PBTCOMPILER public object Peek() { // Die if peeking on empty stack return this[Count - 1]; } #endif public override object Clone() { return new ParserStack(this); } #endregion // StackOverrides #region Properties ////// Returns the Current Context on the stack /// internal object CurrentContext { get { return Count > 0 ? this[Count - 1] : null; } } ////// Returns the Parent of the Current Context /// internal object ParentContext { get { return Count > 1 ? this[Count - 2] : null; } } ////// Returns the GrandParent of the Current Context /// internal object GrandParentContext { get { return Count > 2 ? this[Count - 3] : null; } } #if !PBTCOMPILER ////// Returns the GreatGrandParent of the Current Context /// internal object GreatGrandParentContext { get { return Count > 3 ? this[Count - 4] : null; } } #endif #endregion // Properties } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. /****************************************************************************\ * * File: ParserStack.cs * * Purpose: ParserStack...once was in XamlReaderHelper.cs * * History: * 11/21/08: [....] Moved from XamlReaderHelper.cs as we were replacing the parser. * * Copyright (C) 2008 by Microsoft Corporation. All rights reserved. * \***************************************************************************/ using System; using System.Xml; using System.Xml.Serialization; using System.IO; using System.Text; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Reflection; using System.Globalization; using MS.Utility; using System.Collections.Specialized; using Microsoft.Win32; using System.Runtime.InteropServices; using MS.Internal; using System.Windows.Markup; #if !PBTCOMPILER using System.Windows; using System.Windows.Documents; using System.Windows.Media; using System.Windows.Shapes; #endif #if PBTCOMPILER namespace MS.Internal.Markup #else namespace System.Windows.Markup #endif { ////// Parser Context stack /// The built-in Stack class doesn't let you do things like look at nodes beyond the top of the stack... /// so we'll use this instead. Note that this is not a complete stack implementation -- if you try to /// convert to array or some such, you'll be missing a couple elements. But this is plenty for our purposes. /// Main goal is to track current/parent context with a minimum of overhead. /// This class is internal so it can be shared with the BamlRecordReader /// internal class ParserStack : ArrayList { ////// Creates a default ParserStack /// internal ParserStack() : base() { } ////// Creates a clone. /// private ParserStack(ICollection collection) : base(collection) { } #region StackOverrides public void Push(object o) { Add(o); } public object Pop() { object o = this[Count - 1]; RemoveAt(Count - 1); return o; } #if !PBTCOMPILER public object Peek() { // Die if peeking on empty stack return this[Count - 1]; } #endif public override object Clone() { return new ParserStack(this); } #endregion // StackOverrides #region Properties ////// Returns the Current Context on the stack /// internal object CurrentContext { get { return Count > 0 ? this[Count - 1] : null; } } ////// Returns the Parent of the Current Context /// internal object ParentContext { get { return Count > 1 ? this[Count - 2] : null; } } ////// Returns the GrandParent of the Current Context /// internal object GrandParentContext { get { return Count > 2 ? this[Count - 3] : null; } } #if !PBTCOMPILER ////// Returns the GreatGrandParent of the Current Context /// internal object GreatGrandParentContext { get { return Count > 3 ? this[Count - 4] : null; } } #endif #endregion // Properties } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PasswordDeriveBytes.cs
- HttpHostedTransportConfiguration.cs
- XmlSchemaDocumentation.cs
- TextServicesManager.cs
- RightsManagementEncryptedStream.cs
- ClientCultureInfo.cs
- PeerApplication.cs
- XmlLanguageConverter.cs
- FrameworkElement.cs
- AtomParser.cs
- EditorZone.cs
- IdentityValidationException.cs
- DependentList.cs
- XsdBuilder.cs
- CroppedBitmap.cs
- ResourceDisplayNameAttribute.cs
- HitTestParameters.cs
- ProxyGenerator.cs
- RtType.cs
- OleDbRowUpdatedEvent.cs
- PlainXmlSerializer.cs
- SingleBodyParameterMessageFormatter.cs
- NavigatingCancelEventArgs.cs
- XPathNodeHelper.cs
- EdmFunctions.cs
- SafeNativeHandle.cs
- AnnotationComponentChooser.cs
- DocumentSequenceHighlightLayer.cs
- TrimSurroundingWhitespaceAttribute.cs
- PanelStyle.cs
- FilteredDataSetHelper.cs
- MarkupExtensionParser.cs
- ClientSideQueueItem.cs
- MimeXmlImporter.cs
- SoapIgnoreAttribute.cs
- LoadedOrUnloadedOperation.cs
- TextRangeAdaptor.cs
- CalloutQueueItem.cs
- InvokeHandlers.cs
- SelfIssuedAuthAsymmetricKey.cs
- VarInfo.cs
- DbDataSourceEnumerator.cs
- VisualState.cs
- WebPartUtil.cs
- LinkButton.cs
- OpenTypeLayoutCache.cs
- HebrewCalendar.cs
- LicenseProviderAttribute.cs
- DataGridViewCellStyleConverter.cs
- ProfileManager.cs
- ResourcesChangeInfo.cs
- ScrollPattern.cs
- ScrollProviderWrapper.cs
- SatelliteContractVersionAttribute.cs
- ThreadPoolTaskScheduler.cs
- DocumentPageTextView.cs
- ImmComposition.cs
- TextEditorThreadLocalStore.cs
- DefaultIfEmptyQueryOperator.cs
- ControlParameter.cs
- SchemaTableColumn.cs
- Permission.cs
- ProfileSection.cs
- XmlSchemaNotation.cs
- ProjectionPruner.cs
- RecognizedAudio.cs
- MailAddressParser.cs
- DictionaryGlobals.cs
- Binding.cs
- ResourceReferenceExpression.cs
- MergeLocalizationDirectives.cs
- HttpUnhandledOperationInvoker.cs
- AndCondition.cs
- UnsafeNativeMethods.cs
- ObservableCollection.cs
- WebConfigurationHostFileChange.cs
- BigInt.cs
- WindowsFormsHostAutomationPeer.cs
- EventLogQuery.cs
- TextBox.cs
- ResourcePermissionBase.cs
- DataSetFieldSchema.cs
- IApplicationTrustManager.cs
- FunctionGenerator.cs
- Freezable.cs
- DataGridCommandEventArgs.cs
- TabItemWrapperAutomationPeer.cs
- StylusCollection.cs
- WorkflowDebuggerSteppingAttribute.cs
- CodeTypeOfExpression.cs
- ApplicationFileParser.cs
- PrincipalPermission.cs
- WpfKnownMemberInvoker.cs
- InputReport.cs
- MD5HashHelper.cs
- ServiceBusyException.cs
- LinearGradientBrush.cs
- VersionedStreamOwner.cs
- LocalFileSettingsProvider.cs
- BinaryFormatterWriter.cs