当前位置: 首页>>代码示例>>C#>>正文


C# RequestState类代码示例

本文整理汇总了C#中RequestState的典型用法代码示例。如果您正苦于以下问题:C# RequestState类的具体用法?C# RequestState怎么用?C# RequestState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RequestState类属于命名空间,在下文中一共展示了RequestState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ObsRequestNode

 public ObsRequestNode(XPathNavigator nav)
 {
     ID = nav.SelectSingleNode ("@id").Value;
     Description = nav.SelectSingleNode ("description").Value;
     State = new RequestState (nav.SelectSingleNode ("state"));
     Action = new RequestAction (nav.SelectSingleNode ("action"));
 }
开发者ID:abock,项目名称:obs-tree-analyzer,代码行数:7,代码来源:ObsRequestNode.cs

示例2: GetStream

        public virtual Task<Stream> GetStream()
        {
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(ServiceUrl);
            request.UserAgent = ApiConstants.UserAgentHeaderValue;
            TaskCompletionSource<Stream> tcs = new TaskCompletionSource<Stream>();
            RequestState state = new RequestState { Manager = this, TaskCompletionSource = tcs, Request = request };

            if (Credentials != null)
            {
                NetworkCredential networkCred = Credentials.GetCredential(
                    Client.BaseAddress,
                    ApiConstants.BasicAuthorization);
                string credParameter = Convert.ToBase64String(Encoding.ASCII.GetBytes(networkCred.UserName + ":" + networkCred.Password));
                request.Headers[ApiConstants.AuthorizationHeaderName] = string.Format(
                    "{0} {1}",
                    ApiConstants.BasicAuthorization, credParameter);
            }

            LogRequest(request);
            IAsyncResult result = request.BeginGetResponse(RemoteLogStreamManager.OnGetResponse, state);
            
            if (result.CompletedSynchronously)
            {
                state.Response = (HttpWebResponse)request.EndGetResponse(result);
                OnGetResponse(state);
            }

            return tcs.Task;
        }
开发者ID:takekazuomi,项目名称:azure-sdk-tools,代码行数:29,代码来源:RemoteLogStreamManager.cs

示例3: TestUrl_Async

        public static HttpWebRequest TestUrl_Async(string url, int index, UrlTestUser caller)
        {
            if (!url.StartsWith("http://") && !url.StartsWith("https://"))
                url = url.Insert(0, "http://");

            RequestState requestState = new RequestState();
            requestState.index = index;
            requestState.caller = caller;
            HttpWebRequest request = null;
            try
            {
                request = (HttpWebRequest)WebRequest.Create(url);
                System.Net.Cache.HttpRequestCachePolicy policy =
                    new System.Net.Cache.HttpRequestCachePolicy(System.Net.Cache.HttpRequestCacheLevel.BypassCache);
                request.CachePolicy = policy;
                request.UserAgent = user_agent;
                request.AllowAutoRedirect = false;
                requestState.request = request;

                IAsyncResult result = (IAsyncResult)request.BeginGetResponse(new AsyncCallback(TestUrl_AsyncCallback), requestState);
            }
            catch (WebException we)
            {
                requestState.connectionFailure = true;
                if (we.Status != WebExceptionStatus.RequestCanceled) // old requests that are invalid now shouldn't write into the ListView
                    ResolveUrlTestResult(requestState);
            }
            catch (Exception e)
            {
                requestState.connectionFailure = true;
                ResolveUrlTestResult(requestState);
            }
            return request;
        }
开发者ID:ggmod,项目名称:WordSyntaxHighlighter,代码行数:34,代码来源:UrlTester.cs

示例4: ConnectAsync

        public async Task<WebSocket> ConnectAsync(Uri uri, CancellationToken cancellationToken)
        {
            var state = new RequestState(uri, _pathBase, cancellationToken, _application);

            if (ConfigureRequest != null)
            {
                ConfigureRequest(state.Context.HttpContext.Request);
            }

            // Async offload, don't let the test code block the caller.
            var offload = Task.Factory.StartNew(async () =>
            {
                try
                {
                    await _application.ProcessRequestAsync(state.Context);
                    state.PipelineComplete();
                    state.ServerCleanup(exception: null);
                }
                catch (Exception ex)
                {
                    state.PipelineFailed(ex);
                    state.ServerCleanup(ex);
                }
                finally
                {
                    state.Dispose();
                }
            });

            return await state.WebSocketTask;
        }
开发者ID:leloulight,项目名称:Hosting,代码行数:31,代码来源:WebSocketClient.cs

示例5: ActionStatusEventArgs

 public ActionStatusEventArgs(RequestState state, string msg)
 {
     State = state;
     Message = msg;
     Time = DateTime.Now;
     IsDetail = false;
 }
开发者ID:karmamule,项目名称:ReconRunner,代码行数:7,代码来源:ActionStatusEvent.cs

示例6: Run

  //public Run()
  public void Run()
  {/*{{{*/
    allDone = new ManualResetEvent(false);
    // Create an instance of the RequestState class.
    RequestState myRequestState = new RequestState();

    // Begin an asynchronous request for information like host name, IP addresses, or 
    // aliases for specified the specified URI.
    IAsyncResult asyncResult = Dns.BeginGetHostEntry("www.contiioso.com", new AsyncCallback(RespCallback), myRequestState );

    // Wait until asynchronous call completes.
    allDone.WaitOne();
    //asyncResult.AsyncWaitHandle.WaitOne();
    if(myRequestState.host == null) return;
    if(asyncResult.IsCompleted) Console.WriteLine("Get IPs!!");
    Console.WriteLine("Host name : " + myRequestState.host.HostName);
    Console.WriteLine("\nIP address list : ");
    for(int index=0; index < myRequestState.host.AddressList.Length; index++)
    {
      Console.WriteLine(myRequestState.host.AddressList[index]);
    }
    Console.WriteLine("\nAliases : ");
    for(int index=0; index < myRequestState.host.Aliases.Length; index++)
    {
      Console.WriteLine(myRequestState.host.Aliases[index]);
    }
  }/*}}}*/
开发者ID:FirstProgramingStudy301-B,项目名称:another,代码行数:28,代码来源:MultiPing.cs

示例7: Update

        // This method is called by the timer delegate.
        public void Update(Object stateInfo)
        {
            try
            {
                logger.Info(string.Format("start update categories..."));
                string url = ConfigurationManager.AppSettings["cat_update_url"];
                HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(string.Format(@"{0}", url));

                RequestState requestState = new RequestState();
                requestState.request = httpWebRequest;
                IAsyncResult result = (IAsyncResult)httpWebRequest.BeginGetResponse(new AsyncCallback(RespCallback), requestState);
                ThreadPool.RegisterWaitForSingleObject(result.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), httpWebRequest, DefaultTimeout, true);

                // The response came in the allowed time. The work processing will happen in the callback function.
                allDone.WaitOne();

                // Release the HttpWebResponse resource.
                if (requestState != null && requestState.response != null)
                    requestState.response.Close();

                AutoResetEvent autoEvent = (AutoResetEvent)stateInfo;
            }
            catch (Exception ex)
            {
                logger.Error("update rates error", ex);
            }
        }
开发者ID:Naviam,项目名称:Home-Accounting-Old,代码行数:28,代码来源:CategoriesMerchantsUpdater.cs

示例8: Download

        public void Download()
        {
            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(this.uri);
                request.Timeout = 500; // Wait for .5 sec only

                RequestState state = new RequestState();
                state.Request = request;
                state.Completed = this.completed;
                state.OriginalUri = this.uri;
                state.Properties = this.properties;

                IAsyncResult result = (IAsyncResult)request.BeginGetResponse(
                    new AsyncCallback(ResponseCallback), state);

                ThreadPool.RegisterWaitForSingleObject(result.AsyncWaitHandle,
                    new WaitOrTimerCallback(TimeoutCallback), state,
                    DEFAULT_TIMEOUT, true);
            }
            catch (Exception ex)
            {
                completed(new WebDownloaderEventArgs
                {
                    Exception = ex,
                    Stream = null,
                    ResponseUri = this.uri,
                    IsTimeout = false,
                    Properties = this.properties,
                    Status = HttpStatusCode.Unused
                });
            }
        }
开发者ID:quartz12345,项目名称:c,代码行数:33,代码来源:WebDownloader.cs

示例9: SendRequest

        internal void SendRequest(RestRequestArgs args, Action<XElement> success, Failed failed)
        {
            if (args == null)
                throw new ArgumentNullException("args");
            if (success == null)
                throw new ArgumentNullException("success");
            if (failed == null)
                throw new ArgumentNullException("failed");

            // create a request state...
            RequestState state = new RequestState()
            {
                Owner = this,
                Args = args,
                Success = success,
                Failed = failed
            };

            // are we authenticated?  if we're not, we need to call that first...
            if (!(IsAuthenticated))
            {
                // call the authenticate routine, and ask it to call the state we just setup
                // if authentication works...
                ApiService.Authenticate(new Action(state.DoRequest), failed);
            }
            else
            {
                // call the method directly...
                state.DoRequest();
            }
        }
开发者ID:mbrit,项目名称:AmxMobile.Phone7.SixBookmarks-1.2,代码行数:31,代码来源:RestServiceProxy.cs

示例10: ControlAddSliceToNodesSlice

        /// <summary>
        /// Creates a new control instance.
        /// </summary>
        public ControlAddSliceToNodesSlice()
        {
            // Initialize the component.
            this.InitializeComponent();

            // Create the request states.
            this.requestStateSlices = new RequestState(null, this.OnSitesRequestResult, null, null, null);
            this.requestStateNodes = new RequestState(null, this.OnNodesRequestResult, null, null, null);
        }
开发者ID:alexbikfalvi,项目名称:InetAnalytics,代码行数:12,代码来源:ControlAddSliceToNodesSlice.cs

示例11: Store

        /// <summary>
        /// Stores the specified request <paramref name="state"/>, overriding 
        /// any previous state with the same key
        /// </summary>
        /// <param name="state">Request state</param>
        public void Store(RequestState state)
        {
            if (state == null)
                throw new ArgumentNullException("state");

            lock (this.SyncRoot)
            {
                HttpContext.Current.Session[GetStringKey(state.Key)] = state;
            }
        }
开发者ID:rpmcpp,项目名称:oauth-dot-net,代码行数:15,代码来源:SessionRequestStateStore.cs

示例12: Store

        /// <summary>
        /// Stores the specified request <paramref name="state"/>, overriding 
        /// any previous state with the same key
        /// </summary>
        /// <param name="state">Request state</param>
        public void Store(RequestState state)
        {
            if (state == null)
                throw new ArgumentNullException("state");

            lock (this.SyncRoot)
            {
                this.states[state.Key] = state;
            }
        }
开发者ID:rpmcpp,项目名称:oauth-dot-net,代码行数:15,代码来源:InMemoryRequestStateStore.cs

示例13: login

        public void login(string username, string password)
        {
            HttpWebRequest request = createLoginRequest();

            RequestState state = new RequestState(request, new creds(username, password), this, url.LoginUrl);

            request.BeginGetRequestStream(
                new AsyncCallback(GetRequestStreamCallback),
                state);
        }
开发者ID:bigfathippie,项目名称:jujubee,代码行数:10,代码来源:reddit.cs

示例14: DownloadDataAsync

        public void DownloadDataAsync(HttpWebRequest request, byte[] d,  int millisecondsTimeout,
           RequestCompletedEventHandler completedCallback)
        {
            RequestState state = new RequestState(request, d, millisecondsTimeout, completedCallback, null);

            IAsyncResult result = request.BeginGetResponse(GetResponse, state);

#if !NETFX_CORE
            ThreadPool.RegisterWaitForSingleObject(result.AsyncWaitHandle, TimeoutCallback, state, millisecondsTimeout, true);
#endif
        }
开发者ID:nextropia,项目名称:GoogleMusicAPI.NET,代码行数:11,代码来源:HTTP.cs

示例15: DownloadDataAsync

        public static void DownloadDataAsync(HttpWebRequest request, int millisecondsTimeout,
            DownloadProgressEventHandler downloadProgressCallback, RequestCompletedEventHandler completedCallback)
        {
            // Create an object to hold all of the state for this request
            RequestState state = new RequestState(request, null, millisecondsTimeout, null, downloadProgressCallback,
                completedCallback);

            // Start the request for the remote server response
            IAsyncResult result = request.BeginGetResponse(GetResponse, state);
            // Register a timeout for the request
            ThreadPool.RegisterWaitForSingleObject(result.AsyncWaitHandle, TimeoutCallback, state, millisecondsTimeout, true);
        }
开发者ID:justincc,项目名称:libopenmetaverse,代码行数:12,代码来源:CapsBase.cs


注:本文中的RequestState类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。