Exemplo n.º 1
0
        /// <summary>
        /// Clone a stream and move the clone's seek pointer to the beginning of the stream.
        /// The clone stream uses the same data as the original, so the changes made in one are immediately visible in the other.
        /// </summary>
        /// <param name="original">The stream to clone.</param>
        /// <returns>A clone of the original stream with its seek pointer pointing to the beginning of the stream.</returns>
        public static IStream CloneAndResetStream(IStream original)
        {
            IStream clone;

            original.Clone(out clone);
            IStream_Reset(clone);
            return(clone);
        }
Exemplo n.º 2
0
            private static Result CloneImpl(IntPtr thisPtr, out IntPtr streamPointer)
            {
                Result result = Result.Ok;

                streamPointer = IntPtr.Zero;

                try
                {
                    IStreamShadow shadow   = ToShadow <IStreamShadow>(thisPtr);
                    IStream       callback = ((IStream)shadow.Callback);
                    IStream       clone    = callback.Clone();
                    streamPointer = ToCallbackPtr <IStream>(clone);
                }
                catch (SharpGenException exception)
                {
                    result = exception.ResultCode;
                }
                catch (Exception)
                {
                    result = Result.Fail.Code;
                }
                return(result);
            }