public bool ProcessRequestAsync(IRequest request, ISchemeHandlerResponse response, OnRequestCompletedHandler requestCompletedCallback)
        {
            // The 'host' portion is entirely ignored by this scheme handler.
            var uri = new Uri(request.Url);
            var fileName = uri.AbsolutePath;

            string resource;
            if (resources.TryGetValue(fileName, out resource) && !String.IsNullOrEmpty(resource)) {
                var bytes = Encoding.UTF8.GetBytes(resource);
                response.ResponseStream = new MemoryStream(bytes);
                response.MimeType = GetMimeType(fileName);

                //Execute in async fashion
                requestCompletedCallback.BeginInvoke(requestCompletedCallback.EndInvoke, null);

                return true;
            }

            return false;
        }
Esempio n. 2
0
        public bool ProcessRequestAsync(IRequest request, ISchemeHandlerResponse response, OnRequestCompletedHandler requestCompletedCallback)
        {
            // The 'host' portion is entirely ignored by this scheme handler.
            var uri      = new Uri(request.Url);
            var fileName = uri.AbsolutePath;

            string resource;

            if (resources.TryGetValue(fileName, out resource) && !String.IsNullOrEmpty(resource))
            {
                var bytes = Encoding.UTF8.GetBytes(resource);
                response.ResponseStream = new MemoryStream(bytes);
                response.MimeType       = GetMimeType(fileName);

                //Execute in async fashion
                requestCompletedCallback.BeginInvoke(requestCompletedCallback.EndInvoke, null);

                return(true);
            }

            return(false);
        }
Esempio n. 3
0
        public bool ProcessRequestAsync(IRequest request, ISchemeHandlerResponse response, OnRequestCompletedHandler requestCompletedCallback)
        {
            //gapp:// ignore this
            // The 'host' portion is entirely ignored by this scheme handler.
            try
            {
                var uri      = new Uri(request.Url);
                var fileName = uri.ToString().Substring(7).Replace('/', '\\').Insert(1, ":");
                if (System.IO.File.Exists(fileName))
                {
                    response.ResponseStream = System.IO.File.OpenRead(fileName);
                    response.MimeType       = GetMimeType(fileName);
                    requestCompletedCallback.BeginInvoke(requestCompletedCallback.EndInvoke, null);

                    return(true);
                }
            }
            catch
            {
            }
            return(false);
        }
Esempio n. 4
0
        public bool ProcessRequestAsync(IRequest request, ISchemeHandlerResponse response, OnRequestCompletedHandler requestCompletedCallback)
        {
            //gapp:// ignore this
            // The 'host' portion is entirely ignored by this scheme handler.
            try
            {
                var uri = new Uri(request.Url);
                var fileName = uri.ToString().Substring(7).Replace('/', '\\').Insert(1, ":");
                if (System.IO.File.Exists(fileName))
                {
                    response.ResponseStream = System.IO.File.OpenRead(fileName);
                    response.MimeType = GetMimeType(fileName);
                    requestCompletedCallback.BeginInvoke(requestCompletedCallback.EndInvoke, null);

                    return true;
                }
            }
            catch
            {
            }
            return false;
        }