Exemplo n.º 1
0
        public override int Read(char[] buffer, int index, int count)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer", EnvironmentEx2.GetResourceString("ArgumentNull_Buffer"));
            }
            if (index < 0)
            {
                throw new ArgumentOutOfRangeException("index", EnvironmentEx2.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
            }
            if (count < 0)
            {
                throw new ArgumentOutOfRangeException("count", EnvironmentEx2.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
            }
            if (buffer.Length - index < count)
            {
                throw new ArgumentException(EnvironmentEx2.GetResourceString("Argument_InvalidOffLen"));
            }
            if (!_pendingC.HasValue)
            {
                return(R.Read(buffer, index, count));
            }
            var c = _pendingC.Value; _pendingC = null;

            if (c == -1)
            {
                return(0);
            }
            buffer[index] = (char)c;
            return(true ? R.Read(buffer, index + 1, count - 1) + 1 : 1);
        }
Exemplo n.º 2
0
 private void VerifyIntegrity()
 {
     if (_invalid)
     {
         throw new InvalidOperationException(EnvironmentEx2.GetResourceString("CollectionCorrupted"));
     }
 }
Exemplo n.º 3
0
        internal static void Redirect(this HttpResponse t, string url, bool endResponse, bool permanent)
        {
            var @this = This.Get(t);

            if (url == null)
            {
                throw new ArgumentNullException("url");
            }
            if (url.IndexOf('\n') >= 0)
            {
                throw new ArgumentException(EnvironmentEx2.GetResourceString("Cannot_redirect_to_newline"));
            }
            //if (_headersWritten)
            //    throw new HttpException(EnvironmentEx.GetResourceString("Cannot_redirect_after_headers_sent"));
            var page = (@this._context.Handler as Page);

            if ((page != null) && page.IsCallback)
            {
                throw new ApplicationException(EnvironmentEx2.GetResourceString("Redirect_not_allowed_in_callback"));
            }
            //url = t.ApplyRedirectQueryStringIfRequired(url);
            //url = t.ApplyAppPathModifier(url);
            //url = t.ConvertToFullyQualifiedRedirectUrlIfRequired(url);
            //url = t.UrlEncodeRedirect(url);
            t.Clear();
            if ((page != null) && page.IsPostBack && page.SmartNavigation && (@this.Request["__smartNavPostBack"] == "true"))
            {
                t.Write("<BODY><ASP_SMARTNAV_RDIR url=\"");
                t.Write(HttpUtility.HtmlEncode(url));
                t.Write("\"></ASP_SMARTNAV_RDIR>");
                t.Write("</BODY>");
            }
            else
            {
                t.StatusCode       = (permanent ? 301 : 302);
                t.RedirectLocation = url;
                url = (HttpContextEx.GetIsAbsoluteUrl(url) ? HttpUtility.HtmlAttributeEncode(url) : HttpUtility.HtmlAttributeEncode(HttpUtility.UrlEncode(url)));
                t.Write("<html><head><title>Object moved</title></head><body>\r\n");
                t.Write("<h2>Object moved to <a href=\"" + url + "\">here</a>.</h2>\r\n");
                t.Write("</body></html>\r\n");
            }
            @this._isRequestBeingRedirected = true;
            //var redirecting = httpResponse.Redirecting;
            //if (redirecting != null)
            //    redirecting(this, EventArgs.Empty);
            if (endResponse)
            {
                t.End();
            }
        }
Exemplo n.º 4
0
        private static void RedirectToRoute(this HttpResponse t, string routeName, RouteValueDictionary routeValues, bool permanent)
        {
            var    @this       = This.Get(t);
            string virtualPath = null;
            var    httpRequest = HttpContext.Current.Request;
            var    data        = RouteTable.Routes.GetVirtualPath(@this.Request.get_RequestContext(), routeName, routeValues);

            if (data != null)
            {
                virtualPath = data.VirtualPath;
            }
            if (string.IsNullOrEmpty(virtualPath))
            {
                throw new InvalidOperationException(EnvironmentEx2.GetResourceString("No_Route_Found_For_Redirect"));
            }
            t.Redirect(virtualPath, false, permanent);
        }
Exemplo n.º 5
0
 internal static int GetPrime(int min)
 {
     if (min < 0)
     {
         throw new ArgumentException(EnvironmentEx2.GetResourceString("Arg_HTCapacityOverflow"));
     }
     for (int i = 0; i < primes.Length; i++)
     {
         int num2 = primes[i];
         if (num2 >= min)
         {
             return(num2);
         }
     }
     for (int j = min | 1; j < 0x7fffffff; j += 2)
     {
         if (IsPrime(j))
         {
             return(j);
         }
     }
     return(min);
 }