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
- SectionXmlInfo.cs
- CallContext.cs
- SqlCommandSet.cs
- XamlFigureLengthSerializer.cs
- SecuritySessionSecurityTokenProvider.cs
- DeviceContext2.cs
- ContextBase.cs
- WebPartConnectionsConfigureVerb.cs
- Item.cs
- StateItem.cs
- ResourceReader.cs
- TimeSpan.cs
- ClientScriptManagerWrapper.cs
- DataGridViewHitTestInfo.cs
- ShaperBuffers.cs
- SoapServerMethod.cs
- CodeStatementCollection.cs
- TreeNodeStyle.cs
- CustomCredentialPolicy.cs
- IRCollection.cs
- SafeHandles.cs
- XmlC14NWriter.cs
- TreeNodeStyleCollection.cs
- _SslState.cs
- GregorianCalendar.cs
- HttpTransportSecurityElement.cs
- RegexInterpreter.cs
- TypeRefElement.cs
- EdmSchemaError.cs
- ExcCanonicalXml.cs
- InvalidPrinterException.cs
- XDeferredAxisSource.cs
- DataSourceCacheDurationConverter.cs
- AuthenticationServiceManager.cs
- ImageMetadata.cs
- BoundField.cs
- XmlAnyElementAttribute.cs
- ISFTagAndGuidCache.cs
- KnownColorTable.cs
- TemplateEditingService.cs
- TrustManager.cs
- RuleProcessor.cs
- ConfigurationStrings.cs
- Visual3D.cs
- StorageComplexPropertyMapping.cs
- XmlSchemaGroupRef.cs
- TabletCollection.cs
- AttachedPropertyBrowsableForChildrenAttribute.cs
- WorkflowServiceHostFactory.cs
- ByteKeyFrameCollection.cs
- DataGridViewRowPostPaintEventArgs.cs
- TreeBuilderBamlTranslator.cs
- HttpConfigurationContext.cs
- Automation.cs
- MatrixTransform.cs
- Parser.cs
- XmlLanguageConverter.cs
- ListViewItemSelectionChangedEvent.cs
- ErrorWebPart.cs
- XmlObjectSerializerContext.cs
- ControlAdapter.cs
- ValidationRuleCollection.cs
- XmlResolver.cs
- NameValuePermission.cs
- EncryptedXml.cs
- InvalidWMPVersionException.cs
- Overlapped.cs
- Label.cs
- TaskScheduler.cs
- Sql8ConformanceChecker.cs
- DesignTimeResourceProviderFactoryAttribute.cs
- DrawingCollection.cs
- DataRow.cs
- SafeThemeHandle.cs
- ObjectDataSourceStatusEventArgs.cs
- SessionIDManager.cs
- EDesignUtil.cs
- RegexRunner.cs
- XmlAnyElementAttributes.cs
- MailWebEventProvider.cs
- ToggleButton.cs
- SafeSecurityHelper.cs
- SolidBrush.cs
- LockCookie.cs
- ToolStripOverflow.cs
- ProbeMatchesMessageCD1.cs
- ChildChangedEventArgs.cs
- DBConcurrencyException.cs
- precedingsibling.cs
- WebPartDisplayMode.cs
- _BaseOverlappedAsyncResult.cs
- BitmapEncoder.cs
- GroupBox.cs
- AmbiguousMatchException.cs
- IPGlobalProperties.cs
- CodeTypeParameterCollection.cs
- TypedTableHandler.cs
- TypeToken.cs
- NullReferenceException.cs
- MessageBox.cs