Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / ComIntegration / ComProxy.cs / 1 / ComProxy.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.ComIntegration { using System; using System.Runtime.InteropServices; using System.Collections.Generic; using System.ServiceModel; internal class ComProxy : IDisposable { IntPtr inner; IDisposable ccw; internal static ComProxy Create (IntPtr outer, object obj, IDisposable disp) { if (outer == IntPtr.Zero) { DiagnosticUtility.DebugAssert("Outer cannot be null"); throw DiagnosticUtility.ExceptionUtility.ThrowHelperInternal(false); } IntPtr inner = IntPtr.Zero; inner = Marshal.CreateAggregatedObject (outer, obj); int refCount = Marshal.AddRef (inner); // Workaround for the CLR ref count issue. if (3 == refCount) Marshal.Release (inner); Marshal.Release (inner); return new ComProxy (inner, disp); } internal ComProxy (IntPtr inner, IDisposable disp) { this.inner = inner; ccw = disp; } internal void QueryInterface (ref Guid riid, out IntPtr tearoff) { if (inner == IntPtr.Zero) { DiagnosticUtility.DebugAssert("Inner should not be Null at this point"); throw DiagnosticUtility.ExceptionUtility.ThrowHelperInternal(false); } int hr = Marshal.QueryInterface (inner, ref riid, out tearoff); if (hr != HR.S_OK) { DiagnosticUtility.DebugAssert("QueryInterface should succeed"); throw DiagnosticUtility.ExceptionUtility.ThrowHelperInternal(false); } } void IDisposable.Dispose() { Dispose(true); } void Dispose (bool disposing) { if (inner == IntPtr.Zero) { DiagnosticUtility.DebugAssert("Inner should not be Null at this point"); #pragma warning suppress 56519 // throw DiagnosticUtility.ExceptionUtility.ThrowHelperInternal(false); } Marshal.Release (inner); if (disposing) { if (ccw != null) ccw.Dispose (); } } public ComProxy Clone () { if (inner == IntPtr.Zero) { DiagnosticUtility.DebugAssert("Inner should not be Null at this point"); throw DiagnosticUtility.ExceptionUtility.ThrowHelperInternal(false); } Marshal.AddRef (inner); return new ComProxy (inner, null); } } } // 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
- nulltextcontainer.cs
- MULTI_QI.cs
- SizeAnimationUsingKeyFrames.cs
- Overlapped.cs
- XmlQueryCardinality.cs
- PieceDirectory.cs
- NativeMethodsOther.cs
- DataPagerFieldItem.cs
- QueryContinueDragEvent.cs
- ScriptHandlerFactory.cs
- metadatamappinghashervisitor.cs
- InvalidProgramException.cs
- CustomCredentialPolicy.cs
- DynamicMethod.cs
- DataRowCollection.cs
- Dispatcher.cs
- Select.cs
- InfoCardProofToken.cs
- ClickablePoint.cs
- ListViewItem.cs
- UnauthorizedWebPart.cs
- TimelineGroup.cs
- ObjectIDGenerator.cs
- Cursors.cs
- ReaderWriterLock.cs
- OleDbParameter.cs
- SchemaImporterExtensionElementCollection.cs
- WebPartVerbCollection.cs
- InkCanvasAutomationPeer.cs
- TaskFormBase.cs
- ObjectAnimationUsingKeyFrames.cs
- SmtpReplyReaderFactory.cs
- HttpPostedFile.cs
- SQLMembershipProvider.cs
- DropDownList.cs
- XmlNullResolver.cs
- CompilerInfo.cs
- Instrumentation.cs
- HotCommands.cs
- ErrorStyle.cs
- TextModifier.cs
- WebPartConnectionsDisconnectVerb.cs
- BindingNavigator.cs
- SelectedDatesCollection.cs
- SessionStateItemCollection.cs
- StrokeCollectionDefaultValueFactory.cs
- ReflectionUtil.cs
- Image.cs
- RsaSecurityToken.cs
- VectorConverter.cs
- TimeManager.cs
- Base64Encoder.cs
- FileDialogCustomPlace.cs
- DefaultTextStore.cs
- ExpressionVisitor.cs
- ServiceModelSectionGroup.cs
- PkcsMisc.cs
- Walker.cs
- DesignBindingConverter.cs
- FunctionImportElement.cs
- AccessorTable.cs
- DbParameterHelper.cs
- WebPartCatalogCloseVerb.cs
- MeasurementDCInfo.cs
- MULTI_QI.cs
- QilReference.cs
- TableAdapterManagerMethodGenerator.cs
- XmlNamespaceMappingCollection.cs
- ObjectParameter.cs
- OdbcConnectionHandle.cs
- Component.cs
- NestPullup.cs
- SqlFunctions.cs
- InvalidOperationException.cs
- MutexSecurity.cs
- RequestValidator.cs
- SelectionPattern.cs
- GB18030Encoding.cs
- RuntimeConfig.cs
- RectValueSerializer.cs
- SystemResourceKey.cs
- M3DUtil.cs
- Range.cs
- SystemMulticastIPAddressInformation.cs
- DataColumnSelectionConverter.cs
- EventProvider.cs
- xml.cs
- RemotingService.cs
- WebUtility.cs
- LogicalExpr.cs
- StateBag.cs
- TextParagraphView.cs
- Matrix.cs
- HorizontalAlignConverter.cs
- CodeSubDirectoriesCollection.cs
- TextCharacters.cs
- ProxyWebPartConnectionCollection.cs
- TextTreePropertyUndoUnit.cs
- XmlDataContract.cs
- MappingMetadataHelper.cs