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
- SimpleNameService.cs
- DiscreteKeyFrames.cs
- SeparatorAutomationPeer.cs
- _FtpDataStream.cs
- TextRangeEditLists.cs
- SpecularMaterial.cs
- DataGridViewCellFormattingEventArgs.cs
- SqlMetaData.cs
- TextClipboardData.cs
- AttributeXamlType.cs
- ResolveNameEventArgs.cs
- TableCell.cs
- _LazyAsyncResult.cs
- ConstraintStruct.cs
- PublishLicense.cs
- InputManager.cs
- Rotation3DAnimationUsingKeyFrames.cs
- Base64Stream.cs
- Gdiplus.cs
- FreezableOperations.cs
- tibetanshape.cs
- AssemblyAttributes.cs
- RSAPKCS1KeyExchangeFormatter.cs
- SystemNetHelpers.cs
- RelationshipType.cs
- SystemIPInterfaceProperties.cs
- RegexReplacement.cs
- Common.cs
- SafeProcessHandle.cs
- EventLogEntryCollection.cs
- SQLDecimal.cs
- SQLSingle.cs
- Fonts.cs
- CacheChildrenQuery.cs
- VarInfo.cs
- XhtmlBasicLinkAdapter.cs
- CodeEventReferenceExpression.cs
- CodeNamespaceImport.cs
- DataService.cs
- StagingAreaInputItem.cs
- DesignerRegion.cs
- JsonWriterDelegator.cs
- ExpandedWrapper.cs
- SupportsEventValidationAttribute.cs
- StorageScalarPropertyMapping.cs
- RightsManagementPermission.cs
- CodeTypeReferenceExpression.cs
- DataService.cs
- SecurityContextTokenValidationException.cs
- SortedList.cs
- Vector3DIndependentAnimationStorage.cs
- ImageListUtils.cs
- BamlTreeMap.cs
- XmlAttribute.cs
- HexParser.cs
- Number.cs
- NetworkAddressChange.cs
- X509CertificateValidationMode.cs
- UIElementParaClient.cs
- ImplicitInputBrush.cs
- CodeAccessPermission.cs
- ImmutableDispatchRuntime.cs
- SmiEventSink_DeferedProcessing.cs
- TypeInfo.cs
- Base64Decoder.cs
- _PooledStream.cs
- CommunicationException.cs
- Rules.cs
- CultureInfoConverter.cs
- DriveInfo.cs
- SecurityKeyIdentifierClause.cs
- Context.cs
- HttpHandlersSection.cs
- ControlValuePropertyAttribute.cs
- RowUpdatedEventArgs.cs
- GlyphShapingProperties.cs
- MessageQueueInstaller.cs
- DependencyPropertyConverter.cs
- PrimitiveDataContract.cs
- SqlServices.cs
- SessionEndedEventArgs.cs
- OperationParameterInfo.cs
- IndentTextWriter.cs
- TextMessageEncoder.cs
- Rules.cs
- JournalNavigationScope.cs
- AuthenticationModulesSection.cs
- TypeToArgumentTypeConverter.cs
- MailBnfHelper.cs
- PropertiesTab.cs
- SizeF.cs
- GridViewColumnHeaderAutomationPeer.cs
- DataGridItem.cs
- PersonalizablePropertyEntry.cs
- IgnoreFlushAndCloseStream.cs
- TargetInvocationException.cs
- SystemIcmpV6Statistics.cs
- PlatformNotSupportedException.cs
- HttpCacheVaryByContentEncodings.cs
- DbBuffer.cs