• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# RequestState类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: Fetch

        public void Fetch(ExternalResource resource)
        {
            if (resource != null)
            {
                var wr = WebRequest.Create(resource.Uri);
                var rs = new RequestState { Request = wr, Resource = resource };
                var ar = wr.BeginGetResponse(ResponseCallback, rs);

                ThreadPool.RegisterWaitForSingleObject(ar.AsyncWaitHandle, TimeoutCallback,
                    rs, Settings.Default.ExternalResourceTimeout * 1000, true);
            }
        }
开发者ID:jo5ef,项目名称:netzlib,代码行数:12,代码来源:ExternalResourceFetcher.cs


示例17: Get

        /// <summary>
        /// Gets the request state stored for the specified <paramref name="key"/>,
        /// creating a new state object if none is stored.
        /// </summary>
        /// <param name="key">State key</param>
        /// <returns>State</returns>
        public RequestState Get(RequestStateKey key)
        {
            if (key == null)
                throw new ArgumentNullException("key");

            lock (this.SyncRoot)
            {
                if (this.states.ContainsKey(key))
                    return this.states[key];

                var state = new RequestState(key);
                this.Store(state);
                return state;
            }
        }
开发者ID:rpmcpp,项目名称:oauth-dot-net,代码行数:21,代码来源:InMemoryRequestStateStore.cs


示例18: BeginExecuteQuery

 public void BeginExecuteQuery(String uriString, QueryExecutedCallback callback, Object tag)
 {
     try
     {
         RequestState state = new RequestState();
         state.callback = callback;
         state.tag = tag;
         state.request = HttpWebRequest.Create(uriString);
         state.request.BeginGetResponse(new AsyncCallback(this.GotResponseCallback), state);
     }
     catch (Exception e)
     {
         callback(new QueryResult(this, e, tag));
     }
 }
开发者ID:kamilk,项目名称:WikipediaSentinel,代码行数:15,代码来源:HttpFetcher.cs


示例19: Cancel

        public IOperationResult Cancel()
        {
            if (this.State == RequestState.Waiting)
            {
                messaging.Publish(this.Requestor.Room, Tuple.Create(this, RequestState.Cancelled));
                this.State = RequestState.Cancelled;
            }

            if (this.State == RequestState.Cancelled)
            {
                return new OperationResult(ResultValue.Success, "");
            }

            return new OperationResult(ResultValue.Fail, "No puede cancelar, porque la batalla ya ha empezado!");
        }
开发者ID:marcel-valdez,项目名称:dot_net_cop_example,代码行数:15,代码来源:BattleRequest.cs


示例20: Get

        /// <summary>
        /// Gets the request state stored for the specified <paramref name="key"/>,
        /// creating a new state object if none is stored.
        /// </summary>
        /// <param name="key">State key</param>
        /// <returns>State</returns>
        public RequestState Get(RequestStateKey key)
        {
            if (key == null)
                throw new ArgumentNullException("key");

            lock (this.SyncRoot)
            {
                var state = HttpContext.Current.Session[GetStringKey(key)] as RequestState;
                if (state != null)
                    return state;

                state = new RequestState(key);
                this.Store(state);
                return state;
            }
        }
开发者ID:rpmcpp,项目名称:oauth-dot-net,代码行数:22,代码来源:SessionRequestStateStore.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# RequestType类代码示例发布时间:2022-05-24
下一篇:
C# RequestSettings类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap