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
- ADConnectionHelper.cs
- Matrix3D.cs
- SymbolEqualComparer.cs
- RadioButtonList.cs
- EditorAttribute.cs
- SessionSwitchEventArgs.cs
- RuntimeConfig.cs
- ConnectionManagementElementCollection.cs
- TransportSecurityHelpers.cs
- SchemaImporterExtensionElementCollection.cs
- ChameleonKey.cs
- TemplateKey.cs
- DependencyObject.cs
- ToolStripControlHost.cs
- DebugControllerThread.cs
- InfoCardConstants.cs
- KeyFrames.cs
- TraversalRequest.cs
- PenThreadWorker.cs
- BitStack.cs
- DrawingBrush.cs
- Encoder.cs
- ReferenceEqualityComparer.cs
- TextEffect.cs
- PageSettings.cs
- DataGridBoolColumn.cs
- Vector.cs
- listitem.cs
- StaticExtension.cs
- RowParagraph.cs
- BamlResourceSerializer.cs
- TreeNodeMouseHoverEvent.cs
- AutoSizeToolBoxItem.cs
- Int16Converter.cs
- ElasticEase.cs
- SimpleType.cs
- HtmlHead.cs
- TextEditor.cs
- CreateRefExpr.cs
- DataTablePropertyDescriptor.cs
- ByteAnimation.cs
- Section.cs
- Light.cs
- DifferencingCollection.cs
- HttpHandlerAction.cs
- safelink.cs
- RemoteWebConfigurationHost.cs
- DynamicRendererThreadManager.cs
- AuthenticationServiceManager.cs
- CalendarButtonAutomationPeer.cs
- GradientStop.cs
- BrowserCapabilitiesFactory.cs
- UpWmlMobileTextWriter.cs
- DictionarySectionHandler.cs
- Cursor.cs
- MenuBindingsEditorForm.cs
- FormattedText.cs
- QilValidationVisitor.cs
- Storyboard.cs
- XsltContext.cs
- WebPartManager.cs
- ContextStack.cs
- PageStatePersister.cs
- ValueProviderWrapper.cs
- ApplicationHost.cs
- MetadataArtifactLoaderResource.cs
- QueryOperatorEnumerator.cs
- Stream.cs
- OdbcError.cs
- DataSourceProvider.cs
- Vector3DKeyFrameCollection.cs
- Rectangle.cs
- pingexception.cs
- BuilderPropertyEntry.cs
- WindowVisualStateTracker.cs
- PreservationFileReader.cs
- ControlOperationBehavior.cs
- PagedDataSource.cs
- GenerateHelper.cs
- HeaderedItemsControl.cs
- ObjectDataSourceFilteringEventArgs.cs
- Panel.cs
- BamlBinaryReader.cs
- WebPartCatalogAddVerb.cs
- XmlEventCache.cs
- SemanticTag.cs
- RectangleF.cs
- CircleHotSpot.cs
- ClientScriptManagerWrapper.cs
- ParseNumbers.cs
- XmlDocumentSurrogate.cs
- PolicyManager.cs
- ExternalException.cs
- DateTimeConverter2.cs
- TrackingQueryElement.cs
- CodeComment.cs
- DataGridViewRowConverter.cs
- PeerIPHelper.cs
- ApplicationTrust.cs
- XamlSerializerUtil.cs