Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / infocard / Service / managed / Microsoft / InfoCards / RpcCryptoContext.cs / 1 / RpcCryptoContext.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace Microsoft.InfoCards { using System; using System.ComponentModel; using System.IO; using System.Runtime.InteropServices; using IDT = Microsoft.InfoCards.Diagnostics.InfoCardTrace; // // Summary: // The context class for perfoming RpcCrypto operations. // internal class RpcCryptoContext : IDisposable { string m_portName; string m_contextKey; IntPtr m_idlHandle; object m_syncRoot; bool m_open; bool m_disposed; // // Summary: // Creates a new RpcCryptoContext // // Arguments: // portName: The name of the port // contextKey: The name of the context // public RpcCryptoContext( string portName, string contextKey ) { m_portName = portName; m_contextKey = contextKey; m_syncRoot = new object(); m_disposed = false; } // // Summary: // DTOR // ~RpcCryptoContext() { if( !m_disposed ) { ((IDisposable)this).Dispose(); } } // // Summary: // Gets the ContextKye. // public string ContextKey { get{ return m_contextKey; } } // // Summary: // Gets the native IdlHandle // public IntPtr InterfaceHandle { get{ return m_idlHandle; } } // // Summary: // Indicates if the context is still open. // public bool IsOpen { get{ return m_open; } } // // Summary: // Opens the context. // public void Open() { ThrowIfDisposed(); if( !m_open ) { try { m_idlHandle = NativeMcppMethods.RpcCryptoOpen( m_portName ); } catch( Win32Exception we ) { throw IDT.ThrowHelperError( new CommunicationException( null, we ) ); } m_open = true; } } // // Summary: // Closes the context. // public void Close() { if( m_open ) { try { NativeMcppMethods.RpcCryptoClose( m_idlHandle, m_contextKey ); } catch( Win32Exception we ) { throw IDT.ThrowHelperError( new CommunicationException( null, we ) ); } m_idlHandle = IntPtr.Zero; m_open = false; } } // // Summary: // Disposes the object if not alreay done. // void IDisposable.Dispose() { if( !m_disposed ) { lock( m_syncRoot ) { if( !m_disposed ) { m_disposed = true; try { Close(); } catch( CommunicationException ie ) { // // In case the RPC interface on the agent had already shutdown, // we will get this exception from Close( ) above. Dispose is NOT // expected to throw, so catch this specific exception here. // string msg = ie.Message; IDT.TraceDebug( "Ignoring failure in RpcCryptoContext Close(): " + msg ); } m_portName = null; m_contextKey = null; m_idlHandle = IntPtr.Zero; GC.SuppressFinalize( this ); } } } } void ThrowIfDisposed() { if( m_disposed ) { throw IDT.ThrowHelperError( new ObjectDisposedException( "RpcCryptoContext" ) ); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- LabelExpression.cs
- InputGestureCollection.cs
- AutomationPropertyInfo.cs
- IsolatedStorageFilePermission.cs
- OracleConnectionString.cs
- TextTabProperties.cs
- CancellationTokenSource.cs
- UmAlQuraCalendar.cs
- XmlIlTypeHelper.cs
- Condition.cs
- SystemIPAddressInformation.cs
- WindowClosedEventArgs.cs
- ManagedCodeMarkers.cs
- BamlBinaryReader.cs
- SingleAnimationUsingKeyFrames.cs
- DeclarativeCatalogPart.cs
- ObjectSecurity.cs
- VisualTreeFlattener.cs
- XPathDocumentIterator.cs
- Parser.cs
- DrawTreeNodeEventArgs.cs
- ToolStripItemTextRenderEventArgs.cs
- ProgressBarRenderer.cs
- ComboBoxRenderer.cs
- FunctionImportMapping.ReturnTypeRenameMapping.cs
- Command.cs
- ReadingWritingEntityEventArgs.cs
- Environment.cs
- UriTemplatePathPartiallyEquivalentSet.cs
- ImageList.cs
- RtfToXamlReader.cs
- ParagraphVisual.cs
- Popup.cs
- ServerValidateEventArgs.cs
- DataTablePropertyDescriptor.cs
- XmlWriterTraceListener.cs
- PageAsyncTaskManager.cs
- BindingExpressionUncommonField.cs
- SRGSCompiler.cs
- EntityClassGenerator.cs
- input.cs
- SqlNotificationEventArgs.cs
- SdlChannelSink.cs
- DesignerTextWriter.cs
- HwndMouseInputProvider.cs
- XmlAtomicValue.cs
- MediaScriptCommandRoutedEventArgs.cs
- EnumerableRowCollectionExtensions.cs
- ConfigXmlWhitespace.cs
- PagePropertiesChangingEventArgs.cs
- LinkArea.cs
- XmlSchema.cs
- ToolStripManager.cs
- OverflowException.cs
- CreateParams.cs
- DrawingVisual.cs
- DeleteHelper.cs
- DetailsViewPagerRow.cs
- FrameworkName.cs
- PropertyInformation.cs
- LineServicesRun.cs
- WindowsSpinner.cs
- ArrayTypeMismatchException.cs
- documentsequencetextpointer.cs
- BitmapFrame.cs
- AspProxy.cs
- MetadataItemEmitter.cs
- ZipFileInfo.cs
- MaskPropertyEditor.cs
- ZipIOCentralDirectoryDigitalSignature.cs
- GeneralTransform3DTo2D.cs
- ColumnMapCopier.cs
- PropertyConverter.cs
- DataGridViewCellToolTipTextNeededEventArgs.cs
- IsolatedStorageException.cs
- SizeF.cs
- PathFigure.cs
- BrowserDefinition.cs
- ControlBuilderAttribute.cs
- WindowsSolidBrush.cs
- _DisconnectOverlappedAsyncResult.cs
- BitmapDecoder.cs
- x509utils.cs
- FormsAuthenticationEventArgs.cs
- ListViewTableCell.cs
- MoveSizeWinEventHandler.cs
- DesignBindingValueUIHandler.cs
- TemplateBaseAction.cs
- SecurityCredentialsManager.cs
- ReadOnlyDataSourceView.cs
- PtsCache.cs
- DirectionalLight.cs
- EntityObject.cs
- TextEditorDragDrop.cs
- ClientBuildManager.cs
- DataGridViewElement.cs
- Propagator.JoinPropagator.JoinPredicateVisitor.cs
- ExpressionDumper.cs
- ImageFormatConverter.cs
- NetworkAddressChange.cs