Inheritance: WrapperStream
Exemplo n.º 1
0
        public static Stream OpenRead(IOConnectionInfo ioc)
        {
            RaiseIOAccessPreEvent(ioc, IOAccessType.Read);
            Console.WriteLine("opening");

            Console.WriteLine("the path is " + ioc.ToString());
            if (StrUtil.IsDataUri(ioc.Path))
            {
                byte[] pbData = StrUtil.DataUriToData(ioc.Path);
                if (pbData != null)
                {
                    return(new MemoryStream(pbData, false));
                }
            }

            if (ioc.IsLocalFile())
            {
                return(OpenReadLocal(ioc));
            }
            byte[] filebytes = File.ReadAllBytes(ioc.ToString());


            return(IocStream.WrapIfRequired(CreateWebClient(ioc).OpenRead(
                                                new Uri(ioc.Path))));
        }
Exemplo n.º 2
0
        public static Stream OpenWrite(IOConnectionInfo ioc)
        {
            if (ioc == null)
            {
                Debug.Assert(false); return(null);
            }

            RaiseIOAccessPreEvent(ioc, IOAccessType.Write);

            if (ioc.IsLocalFile())
            {
                return(OpenWriteLocal(ioc));
            }

            Uri    uri = new Uri(ioc.Path);
            Stream s;

            // Mono does not set HttpWebRequest.Method to POST for writes,
            // so one needs to set the method to PUT explicitly
            if (NativeLib.IsUnix() && IsHttpWebRequest(uri))
            {
                s = CreateWebClient(ioc).OpenWrite(uri, WebRequestMethods.Http.Put);
            }
            else
            {
                s = CreateWebClient(ioc).OpenWrite(uri);
            }

            return(IocStream.WrapIfRequired(s));
        }
Exemplo n.º 3
0
        public static Stream OpenRead(IOConnectionInfo ioc)
        {
            RaiseIOAccessPreEvent(ioc, IOAccessType.Read);

            if (StrUtil.IsDataUri(ioc.Path))
            {
                byte[] pbData = StrUtil.DataUriToData(ioc.Path);
                if (pbData != null)
                {
                    return(new MemoryStream(pbData, false));
                }
            }

            if (ioc.IsLocalFile())
            {
                return(OpenReadLocal(ioc));
            }

            return(IocStream.WrapIfRequired(CreateWebClient(ioc).OpenRead(new Uri(ioc.Path))));
        }