Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Framework / MS / Internal / Controls / EnumUnknown.cs / 1 / 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. //------------------------------------------------------------------------------ //// 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
- CompiledXpathExpr.cs
- StandardCommands.cs
- SafeBitVector32.cs
- VScrollProperties.cs
- SynchronizingStream.cs
- DynamicResourceExtension.cs
- AtomMaterializer.cs
- ReliableSessionElement.cs
- HashSet.cs
- XhtmlBasicPanelAdapter.cs
- SHA256Managed.cs
- DirectoryNotFoundException.cs
- DynamicValidator.cs
- DelayedRegex.cs
- BatchParser.cs
- Header.cs
- SystemUdpStatistics.cs
- DataSourceXmlAttributeAttribute.cs
- CompensationDesigner.cs
- HttpCachePolicyElement.cs
- FontDifferentiator.cs
- ApplicationCommands.cs
- DeclaredTypeValidatorAttribute.cs
- ControlCachePolicy.cs
- RequestTimeoutManager.cs
- AsymmetricKeyExchangeFormatter.cs
- pingexception.cs
- SmiTypedGetterSetter.cs
- BevelBitmapEffect.cs
- WebControl.cs
- EditorZone.cs
- CodeExporter.cs
- ColumnBinding.cs
- HttpApplicationFactory.cs
- SecurityContextSecurityTokenAuthenticator.cs
- EqualityComparer.cs
- Select.cs
- ConnectionManagementElement.cs
- webproxy.cs
- SetterBaseCollection.cs
- AnonymousIdentificationSection.cs
- BitmapEffectState.cs
- Int64AnimationUsingKeyFrames.cs
- CodeCatchClauseCollection.cs
- BigInt.cs
- FileUpload.cs
- HtmlHead.cs
- DataObjectAttribute.cs
- DBSchemaRow.cs
- RSACryptoServiceProvider.cs
- odbcmetadatacolumnnames.cs
- DataBoundControlAdapter.cs
- TableCellAutomationPeer.cs
- OAVariantLib.cs
- XmlSchemaAll.cs
- XmlNamedNodeMap.cs
- AffineTransform3D.cs
- MimeMultiPart.cs
- SHA256.cs
- XamlSerializerUtil.cs
- IriParsingElement.cs
- WindowCollection.cs
- TextWriter.cs
- XmlTextReaderImpl.cs
- controlskin.cs
- Timer.cs
- FixedSchema.cs
- ChtmlTextWriter.cs
- OdbcFactory.cs
- RC2.cs
- Splitter.cs
- ScriptingSectionGroup.cs
- FontFamilyValueSerializer.cs
- XamlReaderHelper.cs
- Lease.cs
- XPathAxisIterator.cs
- NavigationPropertyEmitter.cs
- streamingZipPartStream.cs
- SystemColorTracker.cs
- HyperLinkField.cs
- ExpressionBuilder.cs
- OdbcConnectionOpen.cs
- SelectedGridItemChangedEvent.cs
- CodeDomSerializerBase.cs
- _NegotiateClient.cs
- StorageEntityContainerMapping.cs
- IItemProperties.cs
- ClientType.cs
- PropertyManager.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- SHA1.cs
- PrivilegeNotHeldException.cs
- RijndaelManaged.cs
- ControlType.cs
- DashStyle.cs
- DotExpr.cs
- Rule.cs
- DiagnosticTrace.cs
- ToolboxBitmapAttribute.cs
- SqlConnectionPoolGroupProviderInfo.cs