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
- XmlSchemaInfo.cs
- InvokePatternIdentifiers.cs
- InkCanvasSelection.cs
- ModifierKeysConverter.cs
- CollectionEditVerbManager.cs
- NamespaceInfo.cs
- LayoutSettings.cs
- XmlMapping.cs
- WebPartAddingEventArgs.cs
- WebPartDescriptionCollection.cs
- TextDecoration.cs
- GeneralTransform2DTo3D.cs
- BitConverter.cs
- HostedTransportConfigurationBase.cs
- TransportOutputChannel.cs
- EntityUtil.cs
- NavigationWindow.cs
- RemotingSurrogateSelector.cs
- LinearGradientBrush.cs
- LinkTarget.cs
- MSAANativeProvider.cs
- ToolboxDataAttribute.cs
- XPathNodeInfoAtom.cs
- MemoryRecordBuffer.cs
- CaseExpr.cs
- DebugTracing.cs
- PrefixHandle.cs
- LocalizationComments.cs
- PopupRoot.cs
- CommonDialog.cs
- PixelFormatConverter.cs
- MissingMemberException.cs
- XmlDownloadManager.cs
- RequestSecurityTokenResponse.cs
- InputScope.cs
- PropertyGrid.cs
- WindowsRichEdit.cs
- TypedTableBase.cs
- SspiSecurityToken.cs
- Transform3DGroup.cs
- DataRowChangeEvent.cs
- EdmFunction.cs
- Viewport3DVisual.cs
- UniqueEventHelper.cs
- Pens.cs
- PrinterUnitConvert.cs
- Activator.cs
- XmlMtomWriter.cs
- ServiceDiscoveryElement.cs
- ProcessRequestArgs.cs
- DefaultSettingsSection.cs
- MultiBinding.cs
- InstanceBehavior.cs
- BuildDependencySet.cs
- NotifyInputEventArgs.cs
- httpapplicationstate.cs
- RegistryDataKey.cs
- OperationAbortedException.cs
- SystemIPGlobalStatistics.cs
- PostBackTrigger.cs
- CodeRegionDirective.cs
- Wildcard.cs
- SHA512.cs
- DrawingGroup.cs
- Metadata.cs
- Logging.cs
- HttpRequest.cs
- BitmapEffectGroup.cs
- CommandHelpers.cs
- SQLDecimalStorage.cs
- ColorPalette.cs
- PropertyMap.cs
- TextFormatterContext.cs
- TableCellCollection.cs
- WebPartEditorApplyVerb.cs
- OleDbStruct.cs
- Relationship.cs
- ClientTargetSection.cs
- MDIControlStrip.cs
- OutputCacheSettingsSection.cs
- DocumentOrderQuery.cs
- ProtocolInformationWriter.cs
- ConnectionProviderAttribute.cs
- AnnotationComponentChooser.cs
- TreeChangeInfo.cs
- DragDrop.cs
- FlowchartDesigner.Helpers.cs
- WebConfigManager.cs
- SpellerError.cs
- AttachedAnnotation.cs
- GradientSpreadMethodValidation.cs
- ImageSourceValueSerializer.cs
- AdornerDecorator.cs
- WebServiceEnumData.cs
- ContainerCodeDomSerializer.cs
- FontDialog.cs
- QueryAsyncResult.cs
- RunInstallerAttribute.cs
- WinInet.cs
- XhtmlBasicFormAdapter.cs