Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / infocard / Client / System / IdentityModel / Selectors / InternalPolicyElement.cs / 1305376 / InternalPolicyElement.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; using Microsoft.InfoCards.Diagnostics; using IDT=Microsoft.InfoCards.Diagnostics.InfoCardTrace; // // Summary: // This is the managed representation of the native POLICY_ELEMENT struct. This internal version // knows how to Marshal itself and manages the native memory associated with a marshaled POLICY_ELEMENT. // internal class InternalPolicyElement : IDisposable { CardSpacePolicyElement m_element; NativePolicyElement m_nativeElement; IntPtr m_nativePtr; // // Parameters: // target - The target of the token being described. // parameters - describes the type of token required by the target. // public InternalPolicyElement( CardSpacePolicyElement element ) { m_nativePtr = IntPtr.Zero; if( null == element.Target ) { throw IDT.ThrowHelperArgumentNull( "PolicyElement.Target" ); } m_element = element; } public static int Size { get { return Marshal.SizeOf( typeof( NativePolicyElement ) ); } } // // Summary: // Marshals the PolicyElement to it's native format. // // Parameters: // ptr - A pointer to native memory in which to place the native format of the PolicyElement. Must be // a buffer atleast as large as this.Size. // public void DoMarshal( IntPtr ptr ) { string target = m_element.Target.OuterXml; string issuer = ""; IDT.DebugAssert( IntPtr.Zero == m_nativePtr, "Pointer already assigned" ); m_nativePtr = ptr; if( m_element.Issuer != null ) { issuer = m_element.Issuer.OuterXml; } string tokenParameters = string.Empty; if( null != m_element.Parameters ) { tokenParameters = CardSpaceSelector.XmlToString( m_element.Parameters ); } m_nativeElement.targetEndpointAddress = target; m_nativeElement.issuerEndpointAddress = issuer; m_nativeElement.issuedTokenParameters = tokenParameters; m_nativeElement.policyNoticeLink = null != m_element.PolicyNoticeLink ? m_element.PolicyNoticeLink.ToString() : null ; m_nativeElement.policyNoticeVersion = m_element.PolicyNoticeVersion; m_nativeElement.isManagedCardProvider = m_element.IsManagedIssuer; Marshal.StructureToPtr( m_nativeElement, ptr, false ); return; } public void Dispose() { Dispose( true ); } ~InternalPolicyElement() { Dispose( false ); } private void Dispose( bool disposing ) { if( IntPtr.Zero != m_nativePtr ) { Marshal.DestroyStructure( m_nativePtr, typeof( NativePolicyElement ) ); m_nativePtr = IntPtr.Zero; } if( disposing ) { GC.SuppressFinalize( this ); } } } } // 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; using Microsoft.InfoCards.Diagnostics; using IDT=Microsoft.InfoCards.Diagnostics.InfoCardTrace; // // Summary: // This is the managed representation of the native POLICY_ELEMENT struct. This internal version // knows how to Marshal itself and manages the native memory associated with a marshaled POLICY_ELEMENT. // internal class InternalPolicyElement : IDisposable { CardSpacePolicyElement m_element; NativePolicyElement m_nativeElement; IntPtr m_nativePtr; // // Parameters: // target - The target of the token being described. // parameters - describes the type of token required by the target. // public InternalPolicyElement( CardSpacePolicyElement element ) { m_nativePtr = IntPtr.Zero; if( null == element.Target ) { throw IDT.ThrowHelperArgumentNull( "PolicyElement.Target" ); } m_element = element; } public static int Size { get { return Marshal.SizeOf( typeof( NativePolicyElement ) ); } } // // Summary: // Marshals the PolicyElement to it's native format. // // Parameters: // ptr - A pointer to native memory in which to place the native format of the PolicyElement. Must be // a buffer atleast as large as this.Size. // public void DoMarshal( IntPtr ptr ) { string target = m_element.Target.OuterXml; string issuer = ""; IDT.DebugAssert( IntPtr.Zero == m_nativePtr, "Pointer already assigned" ); m_nativePtr = ptr; if( m_element.Issuer != null ) { issuer = m_element.Issuer.OuterXml; } string tokenParameters = string.Empty; if( null != m_element.Parameters ) { tokenParameters = CardSpaceSelector.XmlToString( m_element.Parameters ); } m_nativeElement.targetEndpointAddress = target; m_nativeElement.issuerEndpointAddress = issuer; m_nativeElement.issuedTokenParameters = tokenParameters; m_nativeElement.policyNoticeLink = null != m_element.PolicyNoticeLink ? m_element.PolicyNoticeLink.ToString() : null ; m_nativeElement.policyNoticeVersion = m_element.PolicyNoticeVersion; m_nativeElement.isManagedCardProvider = m_element.IsManagedIssuer; Marshal.StructureToPtr( m_nativeElement, ptr, false ); return; } public void Dispose() { Dispose( true ); } ~InternalPolicyElement() { Dispose( false ); } private void Dispose( bool disposing ) { if( IntPtr.Zero != m_nativePtr ) { Marshal.DestroyStructure( m_nativePtr, typeof( NativePolicyElement ) ); m_nativePtr = IntPtr.Zero; } if( disposing ) { GC.SuppressFinalize( this ); } } } } // 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
- _BasicClient.cs
- Constants.cs
- DataBindingExpressionBuilder.cs
- TimeStampChecker.cs
- WinInet.cs
- ResXResourceReader.cs
- ConditionCollection.cs
- UpdateProgress.cs
- WebPartExportVerb.cs
- OracleDataReader.cs
- AppSettingsExpressionBuilder.cs
- PlainXmlSerializer.cs
- Calendar.cs
- XamlTypeMapper.cs
- ErrorHandler.cs
- XmlMemberMapping.cs
- ResourceKey.cs
- Line.cs
- DataGridViewCell.cs
- ItemsPanelTemplate.cs
- ImageField.cs
- EntityDataSourceReferenceGroup.cs
- Serializer.cs
- PrincipalPermission.cs
- ByteKeyFrameCollection.cs
- BinarySerializer.cs
- MultiSelectRootGridEntry.cs
- RangeValuePattern.cs
- SymmetricSecurityProtocolFactory.cs
- ButtonBase.cs
- FlowLayoutPanel.cs
- PartialCachingControl.cs
- ResourcePermissionBase.cs
- _SSPISessionCache.cs
- AttachedPropertyDescriptor.cs
- XmlSchemaImporter.cs
- XmlWriterTraceListener.cs
- CaseCqlBlock.cs
- AxParameterData.cs
- HostProtectionException.cs
- SplineKeyFrames.cs
- PackUriHelper.cs
- BaseCodePageEncoding.cs
- SystemBrushes.cs
- PerfService.cs
- TextEditorLists.cs
- QilPatternFactory.cs
- DPTypeDescriptorContext.cs
- UICuesEvent.cs
- ClientSettingsProvider.cs
- glyphs.cs
- SplayTreeNode.cs
- OverrideMode.cs
- VarInfo.cs
- SoapExtensionReflector.cs
- Adorner.cs
- AnnotationStore.cs
- TimeSpanValidatorAttribute.cs
- Path.cs
- ObjectQuery_EntitySqlExtensions.cs
- FormViewUpdateEventArgs.cs
- HttpHandlersSection.cs
- HttpAsyncResult.cs
- PackagePartCollection.cs
- ALinqExpressionVisitor.cs
- HtmlInputButton.cs
- IsolatedStorageFileStream.cs
- CommentGlyph.cs
- CompoundFileDeflateTransform.cs
- CompatibleComparer.cs
- ModelItemDictionaryImpl.cs
- CommandID.cs
- CodeTypeReferenceCollection.cs
- UnsafeNativeMethodsMilCoreApi.cs
- StrokeIntersection.cs
- HttpAsyncResult.cs
- TableStyle.cs
- HwndAppCommandInputProvider.cs
- PlainXmlSerializer.cs
- SchemaInfo.cs
- RtfToXamlReader.cs
- ObjectListDataBindEventArgs.cs
- DefaultTextStoreTextComposition.cs
- StorageModelBuildProvider.cs
- CfgArc.cs
- Converter.cs
- DictionaryManager.cs
- TextEditorContextMenu.cs
- TextEditorCopyPaste.cs
- EncodingTable.cs
- AttributeCollection.cs
- EntityDataSourceUtil.cs
- AppSettingsReader.cs
- ApplicationServicesHostFactory.cs
- CodeAttributeDeclarationCollection.cs
- DocumentAutomationPeer.cs
- BitmapEffectGroup.cs
- DESCryptoServiceProvider.cs
- StatusBarDesigner.cs
- AnimationException.cs