public static ChannelBinding DuplicateToken(ChannelBinding source)
 {
     if (source == null)
     {
         return(null);
     }
     return(DuplicatedChannelBinding.CreateCopy(source));
 }
Exemplo n.º 2
0
            internal static ChannelBinding CreateCopy(ChannelBinding source)
            {
                Debug.Assert(source != null, "source ChannelBinding should have been checked for null previously");

                if (source.IsInvalid || source.IsClosed)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ObjectDisposedException(source.GetType().FullName));
                }

                if (source.Size <= 0)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("source.Size", source.Size,
                                                                                                              SR.GetString(SR.ValueMustBePositive)));
                }

                //Instantiate the SafeHandle before trying to allocate the native memory
                DuplicatedChannelBinding duplicate = new DuplicatedChannelBinding();

                //allocate the native memory and make a deep copy of the original.
                duplicate.Initialize(source);

                return(duplicate);
            }
            internal static ChannelBinding CreateCopy(ChannelBinding source)
            {
                Fx.Assert(source != null, "source ChannelBinding should have been checked for null previously");

                if (source.IsInvalid || source.IsClosed)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ObjectDisposedException(source.GetType().FullName));
                }

                if (source.Size <= 0)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("source.Size", source.Size,
                        SR.GetString(SR.ValueMustBePositive)));
                }

                //Instantiate the SafeHandle before trying to allocate the native memory
                DuplicatedChannelBinding duplicate = new DuplicatedChannelBinding();

                //allocate the native memory and make a deep copy of the original.
                duplicate.Initialize(source);

                return duplicate;
            }