Exemplo n.º 1
0
 /// <summary>
 /// 小数据流转换
 /// </summary>
 /// <param name="stream"></param>
 /// <returns></returns>
 public static System.IO.Stream ToTinyStream(this Java.IO.InputStream stream)
 {
     using (stream)
         using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream())
         {
             byte[] buffer = fastCSharp.memoryPool.TinyBuffers.Get();
             try
             {
                 do
                 {
                     int length = stream.Read(buffer);
                     if (length == -1)
                     {
                         break;
                     }
                     if (length != 0)
                     {
                         memoryStream.Write(buffer, 0, length);
                     }
                 }while (true);
             }
             finally { fastCSharp.memoryPool.TinyBuffers.Push(ref buffer); }
             return(new System.IO.MemoryStream(memoryStream.GetBuffer(), 0, (int)memoryStream.Position, false));
         }
 }
Exemplo n.º 2
0
        InputStreamInvoker GetResourceStream(int resId, Android.Util.TypedValue outValue)
        {
            Application.Context.Resources.GetValue(resId, outValue, true);
            IntPtr sp = OpenNonAsset(Application.Context.Resources.Assets, outValue.AssetCookie, outValue.String.ToString(), 2 /* AssetManager.ACCESS_STREAMING */);

            Java.IO.InputStream s = Java.Lang.Object.GetObject <Java.IO.InputStream> (sp, JniHandleOwnership.TransferLocalRef);
            return(new InputStreamInvoker(s));
        }
Exemplo n.º 3
0
 protected override void Dispose(bool disposing)
 {
     if (disposing && BaseInputStream != null)
     {
         BaseInputStream.Dispose();
         BaseInputStream = null;
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public JavaInputStreamWrapper(JInputStream stream)
 {
     if (stream == null)
     {
         throw new ArgumentNullException("stream");
     }
     this.stream = stream;
 }
Exemplo n.º 5
0
        public InputStreamInvoker(Java.IO.InputStream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            this.BaseInputStream = stream;
        }
Exemplo n.º 6
0
 //
 // Exception audit:
 //
 //  Verdict
 //    Exception wrapping is required.
 //
 //  Rationale
 //    `java.io.InputStream.close()` throws an exception, see:
 //
 //     https://developer.android.com/reference/java/io/InputStream?hl=en
 //
 protected override void Dispose(bool disposing)
 {
     if (disposing && BaseInputStream != null)
     {
         try {
             BaseInputStream.Close();
             BaseInputStream.Dispose();
             BaseInputStream = null;
         } catch (Java.IO.IOException ex) when(JNIEnv.ShouldWrapJavaException(ex))
         {
             throw new IOException(ex.Message, ex);
         }
     }
 }
Exemplo n.º 7
0
        public InputStreamInvoker(Java.IO.InputStream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            BaseInputStream = stream;

            Java.IO.FileInputStream?fileStream = stream as Java.IO.FileInputStream;
            if (fileStream != null)
            {
                BaseFileChannel = fileStream.Channel;
            }
        }
Exemplo n.º 8
0
 public InputStreamInvoker(Java.IO.InputStream stream)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 9
0
        /// <summary>
        /// Default ctor
        /// </summary>
	    public JavaInputStreamWrapper(JInputStream stream)
        {
            if (stream == null)
                throw new ArgumentNullException("stream");
	        this.stream = stream;
	    }
Exemplo n.º 10
0
 public InputStreamInvoker(Java.IO.InputStream stream)
 {
     this.BaseInputStream = stream;
 }
Exemplo n.º 11
0
 public static int read(this Java.IO.InputStream stream, byte[] b)
 {
     return(stream.Read(b));
 }
Exemplo n.º 12
0
 public static void close(this Java.IO.InputStream stream)
 {
     stream.Close();
 }