Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Documents / StaticTextPointer.cs / 1305600 / StaticTextPointer.cs
//---------------------------------------------------------------------------- // // File: StaticTextPointer.cs // // Copyright (C) Microsoft Corporation. All rights reserved. // // Description: Optimized minimal version of TextPointer that gets stored on the stack. // //--------------------------------------------------------------------------- namespace System.Windows.Documents { using System; using MS.Internal; using System.Threading; using System.Windows; using System.Collections; internal struct StaticTextPointer { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructors internal StaticTextPointer(ITextContainer textContainer, object handle0) : this(textContainer, handle0, 0) { } internal StaticTextPointer(ITextContainer textContainer, object handle0, int handle1) { _textContainer = textContainer; _generation = (textContainer != null) ? textContainer.Generation : 0; _handle0 = handle0; _handle1 = handle1; } #endregion Constructors //------------------------------------------------------ // // Internal Methods // //----------------------------------------------------- #region Internal Methods internal ITextPointer CreateDynamicTextPointer(LogicalDirection direction) { AssertGeneration(); return _textContainer.CreateDynamicTextPointer(this, direction); } internal TextPointerContext GetPointerContext(LogicalDirection direction) { AssertGeneration(); return _textContainer.GetPointerContext(this, direction); } internal int GetOffsetToPosition(StaticTextPointer position) { AssertGeneration(); return _textContainer.GetOffsetToPosition(this, position); } internal int GetTextInRun(LogicalDirection direction, char[] textBuffer, int startIndex, int count) { AssertGeneration(); return _textContainer.GetTextInRun(this, direction, textBuffer, startIndex, count); } internal object GetAdjacentElement(LogicalDirection direction) { AssertGeneration(); return _textContainer.GetAdjacentElement(this, direction); } internal StaticTextPointer CreatePointer(int offset) { AssertGeneration(); return _textContainer.CreatePointer(this, offset); } internal StaticTextPointer GetNextContextPosition(LogicalDirection direction) { AssertGeneration(); return _textContainer.GetNextContextPosition(this, direction); } internal int CompareTo(StaticTextPointer position) { AssertGeneration(); return _textContainer.CompareTo(this, position); } internal int CompareTo(ITextPointer position) { AssertGeneration(); return _textContainer.CompareTo(this, position); } internal object GetValue(DependencyProperty formattingProperty) { AssertGeneration(); return _textContainer.GetValue(this, formattingProperty); } internal static StaticTextPointer Min(StaticTextPointer position1, StaticTextPointer position2) { position2.AssertGeneration(); return position1.CompareTo(position2) <= 0 ? position1 : position2; } internal static StaticTextPointer Max(StaticTextPointer position1, StaticTextPointer position2) { position2.AssertGeneration(); return position1.CompareTo(position2) >= 0 ? position1 : position2; } // Asserts this StaticTextPointer is synchronized to the current tree generation. internal void AssertGeneration() { if (_textContainer != null) { Invariant.Assert(_generation == _textContainer.Generation, "StaticTextPointer not synchronized to tree generation!"); } } #endregion Internal Methods //------------------------------------------------------ // // Internal Properties // //------------------------------------------------------ #region Internal Properties internal ITextContainer TextContainer { get { return _textContainer; } } internal DependencyObject Parent { get { return _textContainer.GetParent(this); } } internal bool IsNull { get { return (_textContainer == null); } } internal object Handle0 { get { return _handle0; } } internal int Handle1 { get { return _handle1; } } #endregion Internal Properties //----------------------------------------------------- // // Internal Fields // //------------------------------------------------------ #region Internal Fields internal static StaticTextPointer Null = new StaticTextPointer(null, null, 0); #endregion Internal Fields //----------------------------------------------------- // // Private Fields // //----------------------------------------------------- #region Private Fields private readonly ITextContainer _textContainer; private readonly uint _generation; private readonly object _handle0; private readonly int _handle1; #endregion Private Fields } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- // // File: StaticTextPointer.cs // // Copyright (C) Microsoft Corporation. All rights reserved. // // Description: Optimized minimal version of TextPointer that gets stored on the stack. // //--------------------------------------------------------------------------- namespace System.Windows.Documents { using System; using MS.Internal; using System.Threading; using System.Windows; using System.Collections; internal struct StaticTextPointer { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructors internal StaticTextPointer(ITextContainer textContainer, object handle0) : this(textContainer, handle0, 0) { } internal StaticTextPointer(ITextContainer textContainer, object handle0, int handle1) { _textContainer = textContainer; _generation = (textContainer != null) ? textContainer.Generation : 0; _handle0 = handle0; _handle1 = handle1; } #endregion Constructors //------------------------------------------------------ // // Internal Methods // //----------------------------------------------------- #region Internal Methods internal ITextPointer CreateDynamicTextPointer(LogicalDirection direction) { AssertGeneration(); return _textContainer.CreateDynamicTextPointer(this, direction); } internal TextPointerContext GetPointerContext(LogicalDirection direction) { AssertGeneration(); return _textContainer.GetPointerContext(this, direction); } internal int GetOffsetToPosition(StaticTextPointer position) { AssertGeneration(); return _textContainer.GetOffsetToPosition(this, position); } internal int GetTextInRun(LogicalDirection direction, char[] textBuffer, int startIndex, int count) { AssertGeneration(); return _textContainer.GetTextInRun(this, direction, textBuffer, startIndex, count); } internal object GetAdjacentElement(LogicalDirection direction) { AssertGeneration(); return _textContainer.GetAdjacentElement(this, direction); } internal StaticTextPointer CreatePointer(int offset) { AssertGeneration(); return _textContainer.CreatePointer(this, offset); } internal StaticTextPointer GetNextContextPosition(LogicalDirection direction) { AssertGeneration(); return _textContainer.GetNextContextPosition(this, direction); } internal int CompareTo(StaticTextPointer position) { AssertGeneration(); return _textContainer.CompareTo(this, position); } internal int CompareTo(ITextPointer position) { AssertGeneration(); return _textContainer.CompareTo(this, position); } internal object GetValue(DependencyProperty formattingProperty) { AssertGeneration(); return _textContainer.GetValue(this, formattingProperty); } internal static StaticTextPointer Min(StaticTextPointer position1, StaticTextPointer position2) { position2.AssertGeneration(); return position1.CompareTo(position2) <= 0 ? position1 : position2; } internal static StaticTextPointer Max(StaticTextPointer position1, StaticTextPointer position2) { position2.AssertGeneration(); return position1.CompareTo(position2) >= 0 ? position1 : position2; } // Asserts this StaticTextPointer is synchronized to the current tree generation. internal void AssertGeneration() { if (_textContainer != null) { Invariant.Assert(_generation == _textContainer.Generation, "StaticTextPointer not synchronized to tree generation!"); } } #endregion Internal Methods //------------------------------------------------------ // // Internal Properties // //------------------------------------------------------ #region Internal Properties internal ITextContainer TextContainer { get { return _textContainer; } } internal DependencyObject Parent { get { return _textContainer.GetParent(this); } } internal bool IsNull { get { return (_textContainer == null); } } internal object Handle0 { get { return _handle0; } } internal int Handle1 { get { return _handle1; } } #endregion Internal Properties //----------------------------------------------------- // // Internal Fields // //------------------------------------------------------ #region Internal Fields internal static StaticTextPointer Null = new StaticTextPointer(null, null, 0); #endregion Internal Fields //----------------------------------------------------- // // Private Fields // //----------------------------------------------------- #region Private Fields private readonly ITextContainer _textContainer; private readonly uint _generation; private readonly object _handle0; private readonly int _handle1; #endregion Private Fields } } // 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
- PrivilegedConfigurationManager.cs
- ToolStripLocationCancelEventArgs.cs
- CharacterString.cs
- _ShellExpression.cs
- MoveSizeWinEventHandler.cs
- ShaperBuffers.cs
- WCFBuildProvider.cs
- ExpressionBinding.cs
- HwndHostAutomationPeer.cs
- TreeViewEvent.cs
- XmlDocumentType.cs
- CapiHashAlgorithm.cs
- RealProxy.cs
- Parallel.cs
- BookmarkList.cs
- MappedMetaModel.cs
- LineVisual.cs
- GatewayDefinition.cs
- DrawToolTipEventArgs.cs
- RegexStringValidator.cs
- DayRenderEvent.cs
- BitmapMetadataEnumerator.cs
- QuaternionConverter.cs
- HttpHandlerActionCollection.cs
- MultiAsyncResult.cs
- WsrmTraceRecord.cs
- XmlLinkedNode.cs
- DataSvcMapFileSerializer.cs
- COAUTHINFO.cs
- SHA1.cs
- CipherData.cs
- CardSpaceShim.cs
- SchemaDeclBase.cs
- FontCollection.cs
- ParameterToken.cs
- DataGridAddNewRow.cs
- BufferedOutputStream.cs
- ScaleTransform3D.cs
- SemaphoreFullException.cs
- TableAutomationPeer.cs
- InertiaTranslationBehavior.cs
- CardSpaceSelector.cs
- MutexSecurity.cs
- RadioButtonBaseAdapter.cs
- Part.cs
- LateBoundBitmapDecoder.cs
- FileSystemInfo.cs
- FileVersion.cs
- HtmlTableRow.cs
- TransformGroup.cs
- TreeNodeMouseHoverEvent.cs
- ManipulationInertiaStartingEventArgs.cs
- BuildProviderCollection.cs
- ChannelSinkStacks.cs
- ListViewDeleteEventArgs.cs
- DesignerActionPropertyItem.cs
- Win32.cs
- QueryResults.cs
- Int32RectValueSerializer.cs
- CommandBindingCollection.cs
- RequestTimeoutManager.cs
- XamlParser.cs
- KeysConverter.cs
- PeerEndPoint.cs
- CompilationSection.cs
- DBPropSet.cs
- CodeGotoStatement.cs
- AttachedAnnotation.cs
- SelfIssuedAuthRSACryptoProvider.cs
- QuaternionKeyFrameCollection.cs
- HttpStreams.cs
- CardSpacePolicyElement.cs
- SafeNativeMethods.cs
- BoundField.cs
- ExceptionHandler.cs
- NativeMethods.cs
- TemplateEditingService.cs
- TabControl.cs
- ReceiveActivityValidator.cs
- IDictionary.cs
- sqlnorm.cs
- LineServicesRun.cs
- IntPtr.cs
- SettingsProperty.cs
- CannotUnloadAppDomainException.cs
- IgnoreSectionHandler.cs
- XmlnsPrefixAttribute.cs
- TextPointer.cs
- WMIGenerator.cs
- DelayedRegex.cs
- CriticalHandle.cs
- ChooseAction.cs
- BaseAddressElement.cs
- CompilationUnit.cs
- SubMenuStyle.cs
- XsdDateTime.cs
- WebPartConnectVerb.cs
- ExtractorMetadata.cs
- CustomWebEventKey.cs
- WindowsSecurityTokenAuthenticator.cs