ComProxy IProxyCreator.CreateProxy(IntPtr outer, ref Guid riid)
 {
     if ((riid != typeof(IMoniker).GUID) && (riid != typeof(IParseDisplayName).GUID))
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCastException(System.ServiceModel.SR.GetString("NoInterface", new object[] { (Guid)riid })));
     }
     if (outer == IntPtr.Zero)
     {
         throw Fx.AssertAndThrow("OuterProxy cannot be null");
     }
     if (this.comProxy == null)
     {
         ServiceMonikerInternal internal2 = null;
         try
         {
             internal2     = new ServiceMonikerInternal();
             this.comProxy = ComProxy.Create(outer, internal2, internal2);
             return(this.comProxy);
         }
         finally
         {
             if ((this.comProxy == null) && (internal2 != null))
             {
                 ((IDisposable)internal2).Dispose();
             }
         }
     }
     return(this.comProxy.Clone());
 }
Beispiel #2
0
        ComProxy IProxyCreator.CreateProxy(IntPtr outer, ref Guid riid)
        {
            ComProxy proxy3;

            if (outer == IntPtr.Zero)
            {
                throw Fx.AssertAndThrow("OuterProxy cannot be null");
            }
            if (this.contractType == null)
            {
                TypeCacheManager.Provider.FindOrCreateType(riid, out this.contractType, true, false);
            }
            if ((this.contractType.GUID != riid) && !this.CheckDispatch(ref riid))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCastException(System.ServiceModel.SR.GetString("NoInterface", new object[] { (Guid)riid })));
            }
            System.Type  proxiedType = EmitterCache.TypeEmitter.FindOrCreateType(this.contractType);
            ComProxy     proxy       = null;
            TearOffProxy disp        = null;

            try
            {
                disp   = new TearOffProxy(this, proxiedType);
                proxy  = ComProxy.Create(outer, disp.GetTransparentProxy(), disp);
                proxy3 = proxy;
            }
            finally
            {
                if ((proxy == null) && (disp != null))
                {
                    ((IDisposable)disp).Dispose();
                }
            }
            return(proxy3);
        }
Beispiel #3
0
        ComProxy IProxyCreator.CreateProxy(IntPtr outer, ref Guid riid)
        {
            if ((riid != typeof(IMoniker).GUID) && (riid != typeof(IParseDisplayName).GUID))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCastException(SR.GetString(SR.NoInterface, riid)));
            }
            if (outer == IntPtr.Zero)
            {
                throw Fx.AssertAndThrow("OuterProxy cannot be null");
            }

            if (comProxy == null)
            {
                ServiceMonikerInternal moniker = null;
                try
                {
                    moniker  = new ServiceMonikerInternal();
                    comProxy = ComProxy.Create(outer, moniker, moniker);
                    return(comProxy);
                }
                finally
                {
                    if ((comProxy == null) && (moniker != null))
                    {
                        ((IDisposable)moniker).Dispose();
                    }
                }
            }
            else
            {
                return(comProxy.Clone());
            }
        }
        internal static ComProxy Create(IntPtr outer, IProvideChannelBuilderSettings channelBuilderSettings)
        {
            if (channelBuilderSettings == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.CannotCreateChannelOption)));
            }


            ChannelCredentials ChannelCredentials = null;
            ComProxy           proxy = null;

            try
            {
                ChannelCredentials = new ChannelCredentials(channelBuilderSettings);
                proxy = ComProxy.Create(outer, ChannelCredentials, ChannelCredentials);
                return(proxy);
            }
            finally
            {
                if (proxy == null)
                {
                    if (ChannelCredentials != null)
                    {
                        ((IDisposable)ChannelCredentials).Dispose();
                    }
                }
            }
        }
Beispiel #5
0
        internal static ComProxy Create(IntPtr outer, IProvideChannelBuilderSettings channelBuilderSettings)
        {
            ComProxy proxy2;

            if (channelBuilderSettings == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("CannotCreateChannelOption")));
            }
            ChannelCredentials credentials = null;
            ComProxy           proxy       = null;

            try
            {
                credentials = new ChannelCredentials(channelBuilderSettings);
                proxy       = ComProxy.Create(outer, credentials, credentials);
                proxy2      = proxy;
            }
            finally
            {
                if ((proxy == null) && (credentials != null))
                {
                    ((IDisposable)credentials).Dispose();
                }
            }
            return(proxy2);
        }
 ComProxy IProxyCreator.CreateProxy(IntPtr outer, ref Guid riid)
 {
     if (riid != typeof(ITransactionProxy).GUID)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCastException(System.ServiceModel.SR.GetString("NoInterface", new object[] { (Guid)riid })));
     }
     if (outer == IntPtr.Zero)
     {
         DiagnosticUtility.FailFast("OuterProxy cannot be null");
     }
     if (this.comProxy == null)
     {
         this.comProxy = ComProxy.Create(outer, this.txProxy, null);
         return(this.comProxy);
     }
     return(this.comProxy.Clone());
 }
Beispiel #7
0
        ComProxy IProxyCreator.CreateProxy(IntPtr outer, ref Guid riid)
        {
            if ((riid != typeof(ITransactionProxy).GUID))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCastException(SR.GetString(SR.NoInterface, riid)));
            }
            if (outer == IntPtr.Zero)
            {
                // transactions require failfasts to prevent corruption
                DiagnosticUtility.FailFast("OuterProxy cannot be null");
            }

            if (comProxy == null)
            {
                comProxy = ComProxy.Create(outer, txProxy, null);
                return(comProxy);
            }
            else
            {
                return(comProxy.Clone());
            }
        }
Beispiel #8
0
        ComProxy IProxyCreator.CreateProxy(IntPtr outer, ref Guid riid)
        {
            if (outer == IntPtr.Zero)
            {
                throw Fx.AssertAndThrow("OuterProxy cannot be null");
            }

            // No contract Fault on in
            if (contractType == null)
            {
                TypeCacheManager.Provider.FindOrCreateType(riid, out contractType, true, false);
            }

            if ((contractType.GUID != riid) && !(CheckDispatch(ref riid)))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCastException(SR.GetString(SR.NoInterface, riid)));
            }

            Type         proxiedType  = EmitterCache.TypeEmitter.FindOrCreateType(contractType);
            ComProxy     comProxy     = null;
            TearOffProxy tearoffProxy = null;

            try
            {
                tearoffProxy = new TearOffProxy(this, proxiedType);
                comProxy     = ComProxy.Create(outer, tearoffProxy.GetTransparentProxy(), tearoffProxy);
                return(comProxy);
            }
            finally
            {
                if ((comProxy == null) && (tearoffProxy != null))
                {
                    ((IDisposable)tearoffProxy).Dispose();
                }
            }
        }