Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / infocard / Client / System / IdentityModel / Selectors / PolicyChain.cs / 1305376 / PolicyChain.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.IdentityModel.Selectors { using System; using System.Collections.Generic; using System.IO; using System.Runtime.InteropServices; using System.Text; using System.Xml; // // For common // using Microsoft.InfoCards; // // Summary: // This class wraps and manages the lifetime of an array of PolicyElements that are to be Marshaled to // native memory. // internal class PolicyChain : IDisposable { HGlobalSafeHandle m_nativeChain; InternalPolicyElement[] m_chain; public int Length { get { return m_chain.Length; } } public PolicyChain( CardSpacePolicyElement[ ] elements ) { int length = elements.Length; m_chain = new InternalPolicyElement[ length ]; for( int i = 0; i < length; i++ ) { m_chain[ i ] = new InternalPolicyElement( elements[ i ] ); } } public SafeHandle DoMarshal() { if( null == m_nativeChain ) { int elementSize = InternalPolicyElement.Size; int chainLength = m_chain.Length; m_nativeChain = HGlobalSafeHandle.Construct( chainLength * elementSize ); IntPtr pos = m_nativeChain.DangerousGetHandle(); foreach( InternalPolicyElement element in m_chain ) { element.DoMarshal( pos ); unsafe { // // All this just to do pos += elementSize // pos = new IntPtr( (long)( ( (ulong) pos.ToPointer() ) + (ulong) elementSize ) ); } } } return m_nativeChain; } public void Dispose() { Dispose( true ); } ~PolicyChain() { Dispose( false ); } private void Dispose( bool disposing ) { if( disposing ) { GC.SuppressFinalize( this ); } if( null != m_chain ) { foreach( InternalPolicyElement element in m_chain ) { if( null != element ) { element.Dispose(); } } m_chain = null; } if( null != m_nativeChain ) { m_nativeChain.Dispose(); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.IdentityModel.Selectors { using System; using System.Collections.Generic; using System.IO; using System.Runtime.InteropServices; using System.Text; using System.Xml; // // For common // using Microsoft.InfoCards; // // Summary: // This class wraps and manages the lifetime of an array of PolicyElements that are to be Marshaled to // native memory. // internal class PolicyChain : IDisposable { HGlobalSafeHandle m_nativeChain; InternalPolicyElement[] m_chain; public int Length { get { return m_chain.Length; } } public PolicyChain( CardSpacePolicyElement[ ] elements ) { int length = elements.Length; m_chain = new InternalPolicyElement[ length ]; for( int i = 0; i < length; i++ ) { m_chain[ i ] = new InternalPolicyElement( elements[ i ] ); } } public SafeHandle DoMarshal() { if( null == m_nativeChain ) { int elementSize = InternalPolicyElement.Size; int chainLength = m_chain.Length; m_nativeChain = HGlobalSafeHandle.Construct( chainLength * elementSize ); IntPtr pos = m_nativeChain.DangerousGetHandle(); foreach( InternalPolicyElement element in m_chain ) { element.DoMarshal( pos ); unsafe { // // All this just to do pos += elementSize // pos = new IntPtr( (long)( ( (ulong) pos.ToPointer() ) + (ulong) elementSize ) ); } } } return m_nativeChain; } public void Dispose() { Dispose( true ); } ~PolicyChain() { Dispose( false ); } private void Dispose( bool disposing ) { if( disposing ) { GC.SuppressFinalize( this ); } if( null != m_chain ) { foreach( InternalPolicyElement element in m_chain ) { if( null != element ) { element.Dispose(); } } m_chain = null; } if( null != m_nativeChain ) { m_nativeChain.Dispose(); } } } } // 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
- DataServiceHost.cs
- DefaultValueTypeConverter.cs
- TriggerAction.cs
- ErrorLog.cs
- GeometryGroup.cs
- HashMembershipCondition.cs
- ToolStripContentPanelRenderEventArgs.cs
- RemotingConfiguration.cs
- UrlAuthorizationModule.cs
- DataGrid.cs
- MdiWindowListItemConverter.cs
- ActivityTypeResolver.xaml.cs
- XamlDesignerSerializationManager.cs
- EntityException.cs
- ThreadAbortException.cs
- DataObjectMethodAttribute.cs
- StaticDataManager.cs
- RuntimeConfigLKG.cs
- ReadOnlyCollectionBase.cs
- TimeSpanConverter.cs
- SparseMemoryStream.cs
- ListViewInsertEventArgs.cs
- SqlConnectionPoolProviderInfo.cs
- ReceiveSecurityHeader.cs
- GridViewActionList.cs
- DelegatingTypeDescriptionProvider.cs
- StreamProxy.cs
- ExcCanonicalXml.cs
- DynamicActivityXamlReader.cs
- MessageSmuggler.cs
- SafeFileMapViewHandle.cs
- Formatter.cs
- Oid.cs
- HtmlInputPassword.cs
- CodeNamespaceCollection.cs
- SmiXetterAccessMap.cs
- CompositeDataBoundControl.cs
- TraceUtils.cs
- DeviceContext.cs
- SizeAnimationUsingKeyFrames.cs
- InvalidEnumArgumentException.cs
- ExpressionBuilderCollection.cs
- StatusBarItemAutomationPeer.cs
- RoutedEventConverter.cs
- SplitContainerDesigner.cs
- DataGridViewCellLinkedList.cs
- DocumentSchemaValidator.cs
- DataGridViewCellStyleBuilderDialog.cs
- EntityTypeBase.cs
- ITreeGenerator.cs
- EmptyQuery.cs
- UnicodeEncoding.cs
- FreezableDefaultValueFactory.cs
- SafeNativeMethodsCLR.cs
- Translator.cs
- DataGridCommandEventArgs.cs
- LayoutEditorPart.cs
- KeyGestureConverter.cs
- FormatVersion.cs
- SwitchElementsCollection.cs
- StringValueSerializer.cs
- SynchronizedKeyedCollection.cs
- SortFieldComparer.cs
- ColumnReorderedEventArgs.cs
- LinearGradientBrush.cs
- ServicePoint.cs
- RootAction.cs
- AliasedSlot.cs
- HttpStaticObjectsCollectionBase.cs
- SizeConverter.cs
- HyperLinkStyle.cs
- RoutedEventArgs.cs
- OdbcHandle.cs
- ViewPort3D.cs
- Vector3DValueSerializer.cs
- MessageSmuggler.cs
- MetadataArtifactLoaderXmlReaderWrapper.cs
- XmlSchemaRedefine.cs
- LogicalExpr.cs
- VirtualPathProvider.cs
- _TimerThread.cs
- SqlRecordBuffer.cs
- ItemContainerGenerator.cs
- HttpHandlersSection.cs
- OracleRowUpdatedEventArgs.cs
- WebPartVerbCollection.cs
- FontNamesConverter.cs
- RoutedPropertyChangedEventArgs.cs
- WindowCollection.cs
- TypeExtensions.cs
- OdbcConnectionFactory.cs
- EventLogPermission.cs
- Hex.cs
- WebHostedComPlusServiceHost.cs
- NativeMethods.cs
- HttpProfileGroupBase.cs
- CompilationUtil.cs
- CodeAttributeArgumentCollection.cs
- CommentEmitter.cs
- XPathBinder.cs