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
- MailAddressParser.cs
- DataSpaceManager.cs
- TreeViewHitTestInfo.cs
- SqlParameterizer.cs
- UnknownWrapper.cs
- DataServiceBehavior.cs
- ButtonChrome.cs
- DefaultValidator.cs
- CollectionContainer.cs
- RequestValidator.cs
- DiscardableAttribute.cs
- ConnectionOrientedTransportManager.cs
- SupportsPreviewControlAttribute.cs
- FrameDimension.cs
- LinqDataSource.cs
- ProfileService.cs
- HandleValueEditor.cs
- RequestTimeoutManager.cs
- Evidence.cs
- ControlCachePolicy.cs
- BitmapEffectDrawing.cs
- CaretElement.cs
- PropertyPathWorker.cs
- WebRequest.cs
- ConnectionInterfaceCollection.cs
- ActivityDesignerAccessibleObject.cs
- HostVisual.cs
- WindowsBrush.cs
- EncoderNLS.cs
- TextChangedEventArgs.cs
- TransformPatternIdentifiers.cs
- ToolStripContainer.cs
- CodeGroup.cs
- PixelFormats.cs
- SelectedDatesCollection.cs
- SchemeSettingElementCollection.cs
- ToolStripItemEventArgs.cs
- XmlHierarchyData.cs
- IpcClientManager.cs
- DataGridRowHeaderAutomationPeer.cs
- ZoneLinkButton.cs
- SchemaAttDef.cs
- UxThemeWrapper.cs
- SerializerProvider.cs
- CodeAttributeDeclaration.cs
- Token.cs
- MethodExpression.cs
- XmlIncludeAttribute.cs
- DataSourceProvider.cs
- VerificationException.cs
- InternalDuplexChannelFactory.cs
- EntitySqlQueryCacheEntry.cs
- PropertyGridDesigner.cs
- CellCreator.cs
- XMLSyntaxException.cs
- WindowsFormsSectionHandler.cs
- SqlVersion.cs
- PageWrapper.cs
- CroppedBitmap.cs
- TextComposition.cs
- SoapFault.cs
- XmlElementCollection.cs
- BridgeDataRecord.cs
- RawContentTypeMapper.cs
- BitmapCodecInfo.cs
- SystemIPGlobalProperties.cs
- ClientTargetSection.cs
- SoapIgnoreAttribute.cs
- WebServiceMethodData.cs
- DataTableNameHandler.cs
- SqlServices.cs
- JumpTask.cs
- BindableTemplateBuilder.cs
- EtwTrackingParticipant.cs
- Soap12FormatExtensions.cs
- latinshape.cs
- CornerRadius.cs
- MemberInitExpression.cs
- Scene3D.cs
- HijriCalendar.cs
- PathFigureCollectionConverter.cs
- CodeTypeParameter.cs
- ConnectionInterfaceCollection.cs
- XmlObjectSerializerReadContextComplexJson.cs
- Pen.cs
- Size3DConverter.cs
- NullableBoolConverter.cs
- MemberInfoSerializationHolder.cs
- _NativeSSPI.cs
- TraceData.cs
- HttpCookieCollection.cs
- PassportAuthentication.cs
- PathSegmentCollection.cs
- UriParserTemplates.cs
- DataKeyArray.cs
- OracleNumber.cs
- Padding.cs
- StructuralCache.cs
- WebEventTraceProvider.cs
- NumberAction.cs