Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / MS / Internal / Controls / EnumUnknown.cs / 1305600 / EnumUnknown.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // // // // Description: Helper object implementing IEnumUnknown for enumerating controls // // Source copied from AxContainer.cs // // History // 04/17/05 KusumaV Created // //----------------------------------------------------------------------------- using System; using System.Collections; using System.Diagnostics; using System.Runtime.InteropServices; using Microsoft.Win32; using System.Security; using MS.Win32; namespace MS.Internal.Controls { #region class EnumUnknown internal class EnumUnknown : UnsafeNativeMethods.IEnumUnknown { private Object[] arr; private int loc; private int size; internal EnumUnknown(Object[] arr) { this.arr = arr; this.loc = 0; this.size = (arr == null) ? 0 : arr.Length; } private EnumUnknown(Object[] arr, int loc) : this(arr) { this.loc = loc; } ////// Critical: Takes arbitrary pointers, writes to memory /// [SecurityCritical] unsafe int UnsafeNativeMethods.IEnumUnknown.Next(int celt, IntPtr rgelt, IntPtr pceltFetched) { if (pceltFetched != IntPtr.Zero) Marshal.WriteInt32(pceltFetched, 0, 0); if (celt < 0) { return NativeMethods.E_INVALIDARG; } int fetched = 0; if (this.loc >= this.size) { fetched = 0; } else { for (; this.loc < this.size && fetched < celt; ++(this.loc)) { if (this.arr[this.loc] != null) { Marshal.WriteIntPtr(rgelt, Marshal.GetIUnknownForObject(this.arr[this.loc])); rgelt = (IntPtr)((long)rgelt + (long)sizeof(IntPtr)); ++fetched; } } } if (pceltFetched != IntPtr.Zero) Marshal.WriteInt32(pceltFetched, 0, fetched); if (fetched != celt) { return (NativeMethods.S_FALSE); } return NativeMethods.S_OK; } int UnsafeNativeMethods.IEnumUnknown.Skip(int celt) { this.loc += celt; if (this.loc >= this.size) { return (NativeMethods.S_FALSE); } return NativeMethods.S_OK; } void UnsafeNativeMethods.IEnumUnknown.Reset() { this.loc = 0; } void UnsafeNativeMethods.IEnumUnknown.Clone(out UnsafeNativeMethods.IEnumUnknown ppenum) { ppenum = new EnumUnknown(this.arr, this.loc); } } #endregion class EnumUnknown } // 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
- StartUpEventArgs.cs
- DoubleAnimationBase.cs
- ZipIOFileItemStream.cs
- LocalBuilder.cs
- TypeSchema.cs
- WriteFileContext.cs
- ConfigurationManager.cs
- PopupRootAutomationPeer.cs
- XmlEventCache.cs
- ImageDrawing.cs
- StringArrayEditor.cs
- CharacterBufferReference.cs
- WindowShowOrOpenTracker.cs
- XmlMembersMapping.cs
- QuotedStringFormatReader.cs
- CharUnicodeInfo.cs
- util.cs
- CipherData.cs
- SqlBuilder.cs
- GlobalizationAssembly.cs
- XhtmlBasicCommandAdapter.cs
- ServiceMetadataContractBehavior.cs
- SqlUtils.cs
- SpeechAudioFormatInfo.cs
- PageThemeBuildProvider.cs
- HijriCalendar.cs
- TrailingSpaceComparer.cs
- FileDataSourceCache.cs
- ListBoxChrome.cs
- OleDbFactory.cs
- LiteralControl.cs
- nulltextcontainer.cs
- RemoteHelper.cs
- AdapterUtil.cs
- CodeCommentStatement.cs
- ModifierKeysValueSerializer.cs
- FileVersionInfo.cs
- HttpPostLocalhostServerProtocol.cs
- AppDomainInfo.cs
- CommentEmitter.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- XmlDictionaryReader.cs
- PageFunction.cs
- GlobalizationSection.cs
- AttachmentCollection.cs
- GridViewItemAutomationPeer.cs
- GZipUtils.cs
- StateWorkerRequest.cs
- CursorInteropHelper.cs
- SerializationAttributes.cs
- Soap.cs
- XPathNode.cs
- TableLayoutCellPaintEventArgs.cs
- InkPresenter.cs
- GridViewAutomationPeer.cs
- BitmapEffectGroup.cs
- SystemParameters.cs
- OledbConnectionStringbuilder.cs
- FilePrompt.cs
- RenderDataDrawingContext.cs
- VirtualizedItemPattern.cs
- CalendarDay.cs
- InfiniteIntConverter.cs
- PointCollectionValueSerializer.cs
- ReservationNotFoundException.cs
- StateDesigner.LayoutSelectionGlyph.cs
- ToolStripRendererSwitcher.cs
- Column.cs
- EpmHelper.cs
- CompilerError.cs
- HttpWebRequestElement.cs
- CancelRequestedQuery.cs
- CfgParser.cs
- SystemPens.cs
- Attributes.cs
- RelationshipNavigation.cs
- WebPartConnectionsEventArgs.cs
- RenamedEventArgs.cs
- TagPrefixAttribute.cs
- RemotingService.cs
- NotFiniteNumberException.cs
- TimelineCollection.cs
- RadioButtonStandardAdapter.cs
- AgileSafeNativeMemoryHandle.cs
- IssuedTokenClientBehaviorsElementCollection.cs
- DropSource.cs
- FixUpCollection.cs
- PassportAuthentication.cs
- StructuralType.cs
- LassoHelper.cs
- Rotation3D.cs
- Margins.cs
- ContainerControl.cs
- Item.cs
- TreeView.cs
- Point4DConverter.cs
- ButtonStandardAdapter.cs
- MessageRpc.cs
- SimpleHandlerFactory.cs
- MethodRental.cs