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
- ExtensibleClassFactory.cs
- Geometry.cs
- WmlListAdapter.cs
- RectAnimation.cs
- GradientStop.cs
- DynamicContractTypeBuilder.cs
- SqlCacheDependencyDatabaseCollection.cs
- EventLogPermission.cs
- OpenFileDialog.cs
- _NegoStream.cs
- SoapMessage.cs
- MetadataFile.cs
- LineSegment.cs
- ToolboxComponentsCreatedEventArgs.cs
- AssemblyResourceLoader.cs
- WebConfigurationManager.cs
- SourceSwitch.cs
- BooleanAnimationBase.cs
- RemoteWebConfigurationHost.cs
- CellConstant.cs
- ManagedFilter.cs
- OutputCacheProviderCollection.cs
- EdmType.cs
- RouteTable.cs
- XPathNodeInfoAtom.cs
- X509CertificateClaimSet.cs
- QuaternionAnimation.cs
- XmlNullResolver.cs
- WindowsAuthenticationModule.cs
- CodeNamespace.cs
- RichTextBox.cs
- SafeFileMapViewHandle.cs
- FutureFactory.cs
- DefaultBinder.cs
- UniqueIdentifierService.cs
- PartManifestEntry.cs
- MTConfigUtil.cs
- GridViewRowCollection.cs
- CodeDirectoryCompiler.cs
- RepeaterCommandEventArgs.cs
- PeerNearMe.cs
- ListBoxItemWrapperAutomationPeer.cs
- ConfigurationLocationCollection.cs
- FixedSOMLineCollection.cs
- XmlSerializer.cs
- SerializerProvider.cs
- FieldValue.cs
- ScrollBar.cs
- DebugViewWriter.cs
- ImageList.cs
- Assert.cs
- PagerSettings.cs
- SqlEnums.cs
- _IPv4Address.cs
- CompilerResults.cs
- PageRanges.cs
- XmlEnumAttribute.cs
- ChooseAction.cs
- AppendHelper.cs
- ObjectDataSourceEventArgs.cs
- StyleSelector.cs
- DecoratedNameAttribute.cs
- MetadataArtifactLoader.cs
- X509Chain.cs
- TraceUtility.cs
- SessionParameter.cs
- QilStrConcatenator.cs
- XmlTextReaderImpl.cs
- DataGridViewRowsRemovedEventArgs.cs
- ModelItem.cs
- CultureMapper.cs
- MetadataArtifactLoaderCompositeFile.cs
- _BasicClient.cs
- TextParentUndoUnit.cs
- RequestTimeoutManager.cs
- COM2EnumConverter.cs
- ImageFormatConverter.cs
- QuaternionAnimation.cs
- StylusCollection.cs
- IdSpace.cs
- ConstructorNeedsTagAttribute.cs
- MultipleViewPatternIdentifiers.cs
- RadioButtonPopupAdapter.cs
- ThousandthOfEmRealPoints.cs
- EncryptedReference.cs
- OutArgumentConverter.cs
- WhitespaceRuleLookup.cs
- MouseButton.cs
- HealthMonitoringSection.cs
- NodeFunctions.cs
- CodeActivity.cs
- CodeExporter.cs
- GridProviderWrapper.cs
- Restrictions.cs
- FontFamilyConverter.cs
- ToolStripScrollButton.cs
- SymbolType.cs
- _Rfc2616CacheValidators.cs
- Converter.cs
- ImageDrawing.cs