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


C# RequestType类代码示例

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


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

示例1: SendAsync

        public Task<Response> SendAsync(object data, RequestType type)
        {
            Request req = new Request()
            {
                Data = data,
                RequestType = type
            };

            return Task.Run(() =>
            {
                try
                {
                    this.Formatter.Serialize(this.SocketStream, req);
                    var response = this.Formatter.Deserialize(this.SocketStream) as Response;
                    return response;
                }
                catch
                {
                    return new Response()
                    {
                        ResponseType = ResponseType.Error,
                        Message = "Server not responding. Try later."
                    };
                }
            });
        }
开发者ID:ivailok,项目名称:BankCardsTokenization,代码行数:26,代码来源:Client.cs

示例2: createGetRequest

        public static WebRequest createGetRequest(RequestType requestType, Authentication authentication, int? id, int? type, bool? unread, int? fromId)
        {
            HttpRequestAttr requestAttrs = (HttpRequestAttr)requestType.GetAttr();
            WebRequest request;
            string url = requestAttrs.URL;
            if (id.HasValue)
            {
                url += ("/" + id);
            }

            url += "?username=" + authentication.Username + "&secretKey=" + authentication.SecretKey;

            if (type.HasValue)
            {
                url += "&type=" + type.Value;
            }

            if (unread.HasValue)
            {
                url += "&unread=" + unread.Value;
            }

            if (fromId.HasValue)
            {
                url += "&fromId=" + fromId.Value;
            }

            request = WebRequest.Create(url);
            request.Method = requestAttrs.Method;
            request.Timeout = CONNECTION_TIMEOUT;

            return request;
        }
开发者ID:phieudu241,项目名称:NotifierMobileService,代码行数:33,代码来源:HttpHelper.cs

示例3: ExecuteRequestAsync

        protected async Task<string> ExecuteRequestAsync(string url, RequestType type, Dictionary<string, string> @params)
        {
            string result;

            using (var client = new HttpClient())
            {
                if (type == RequestType.POST)
                {
                    var content = new FormUrlEncodedContent(@params);
                    var response = await client.PostAsync(url, content);
                    result = await response.Content.ReadAsStringAsync();
                }
                else
                {
                    // append guid to prevent http requests caching 
                    StringBuilder args = new StringBuilder("?nocache=" + Guid.NewGuid() + "&");

                    // build params string
                    foreach (var pair in @params)
                    {
                        args.AppendFormat("{0}={1}&", pair.Key, pair.Value);
                    }

                    // append params to url
                    url = url + args;

                    // remove last '&' symbol and execute request
                    result = await client.GetStringAsync(url.Remove(url.Length - 1));
                }

            }

            return result;
        }
开发者ID:Pawlyha,项目名称:FsProject,代码行数:34,代码来源:HttpSender.cs

示例4: ConflictRequest

        public static void ConflictRequest(RequestType firstRequest, RequestType secondRequest)
        {
            // For RequestType.Lease, only containg one request (Create with Lease context)
            // for the second client, so DeleteAfter is not applicable.
            Condition.IfThen(firstRequest == RequestType.UncommitedDelete, secondRequest != RequestType.Lease);

            // DeleteAfter is the same as Delete for second request
            Condition.IsTrue(secondRequest != RequestType.UncommitedDelete);
            switch (firstRequest)
            {
                case RequestType.ExclusiveLock:
                    State = FileState.Locked;
                    break;
                case RequestType.Lease:
                    State = FileState.LeaseGranted;
                    break;
                case RequestType.UncommitedDelete:
                    State = FileState.ToBeDeleted;
                    break;
                case RequestType.Delete:
                    State = FileState.Deleted;
                    break;
                // No state changed
                case RequestType.Write:
                case RequestType.Read:
                default:
                    break;
            }

            SecondRequest = secondRequest;
        }
开发者ID:gitter-badger,项目名称:WindowsProtocolTestSuites,代码行数:31,代码来源:ConflictModel.cs

示例5: RequestBuilder

 public RequestBuilder(RequestType requestType, string action)
 {
     this.RequestType = requestType;
     this.Action = action;
     this._urlSegments = new List<string>();
     this._queryStringParameters = new Dictionary<string, string>();
 }
开发者ID:laisee,项目名称:API-V1-DotNet,代码行数:7,代码来源:RequestBuilder.cs

示例6: C

 private Command C(string path, RequestType requestType = RequestType.Get)
 {
     return Cmd(path, requestType)
         .WithParameter(@"login", _login)
         .WithParameter(@"apiKey", _apiKey)
         .WithParameter(@"format", @"json");
 }
开发者ID:acropolium,项目名称:Rest4Net,代码行数:7,代码来源:BitLyProvider.cs

示例7: Request

        public static RequestReply Request(RequestType type, string title, string message, List<string> choices, string default_choice)
        {
            RequestReply request = new RequestReply();

            if(type== RequestType.Choice&&choices==null)
                throw new MException("NeedInfo Error","A choice was requested, but no options provided",true);

            RequestEventArgs e = new RequestEventArgs(type,title,message,choices,default_choice,request);

            ICommunicationReceiver receiver = getReceiver();

            if(receiver==null) {
                request.cancelled =true;
                return request;
            }

            if(receiver.context!=null) {
                receiver.context.Post(new SendOrPostCallback(delegate(object state) {
                    RequestEventHandler handler = receiver.requestInformation;
                    if(handler!=null) {
                        handler(e);
                    }
                }),null);
            } else {
                receiver.requestInformation(e);
            }

            waitForResponse(e);

            if(e.response== ResponseType.Cancel||e.response== ResponseType.No)
                e.result.cancelled = true;

            return e.result;
        }
开发者ID:elkine,项目名称:MASGAU,代码行数:34,代码来源:RequestHandler.cs

示例8: InstrumentationToken

 private InstrumentationToken(RequestType type, ExecutionFlags executionFlags, string cql)
 {
     Id = Guid.NewGuid();
     Type = type;
     ExecutionFlags = executionFlags;
     Cql = cql;
 }
开发者ID:Hamdiakoguz,项目名称:cassandra-sharp,代码行数:7,代码来源:InstrumentationToken.cs

示例9: ExcuteAsyncRequest

        /// <summary>
        /// Excute request async method operator [httpclient version]
        /// </summary>
        /// <param name="requestUrl">Request Url</param>
        /// <param name="requestType">Request Type</param>
        /// <param name="postArguemntList">Post Argument List</param>
        public void ExcuteAsyncRequest(string requestUrl, RequestType requestType,List<KeyValuePair<string,object>> postArguemntList=null)
        {
            HttpClient requestClient = new HttpClient();
            if (requestType == RequestType.GET)
                requestClient.GetAsync(requestUrl).ContinueWith((postback) =>
                {
                    postback.Result.EnsureSuccessStatusCode();
                    if (AsyncResponseComplated != null)
                        AsyncResponseComplated(postback.Result.Content.ReadAsStringAsync().Result, null);

                });
            else if (requestType == RequestType.POST)
            {     
                HttpContent content=null;
                if (postArguemntList != null)
                {
                    List<KeyValuePair<string, string>> argumentList = null;
                    postArguemntList.ForEach(queryArgument => { argumentList.Add(new KeyValuePair<string,string>(queryArgument.Key,queryArgument.Value.ToString())); });
                    content = new FormUrlEncodedContent(argumentList);
                }
                requestClient.PostAsync(requestUrl, content).ContinueWith((postback) =>
                {
                    postback.Result.EnsureSuccessStatusCode();
                    if (AsyncResponseComplated != null)
                        AsyncResponseComplated(postback.Result.Content.ReadAsStringAsync().Result, null);
                });
            }
        }
开发者ID:rodmanwu,项目名称:dribbble-for-windows-phone-8,代码行数:34,代码来源:DataRequestHelper.cs

示例10: Service

        public static object Service(this Uri url, RequestType requestType, ResponseType responseType, out int resultCode, string outputFilename, IDictionary<string, string> formData) {
            object result = null;
            resultCode = -1;

            var webRequest = (HttpWebRequest)WebRequest.Create(url);
            webRequest.Proxy = GetProxy();

            webRequest.CookieContainer = Cookies.GetCookieContainer();

            switch (requestType) {
                case RequestType.POST:
                    webRequest.Method = "POST";
                    webRequest.ContentType = "application/x-www-form-urlencoded";

                    var encodedFormData = Encoding.UTF8.GetBytes(GetFormData(formData).ToString());
                    using (var requestStream = webRequest.GetRequestStream()) {
                        requestStream.Write(encodedFormData, 0, encodedFormData.Length);
                    }
                    break;
                case RequestType.GET:
                    webRequest.Method = "GET";
                    if (formData != null) {
                        var ub = new UriBuilder(url) {
                            Query = GetFormData(formData).ToString()
                        };
                        url = ub.Uri;
                    }
                    break;
            }

            try {
                if (credentialCache != null) {
                    webRequest.Credentials = credentialCache;
                    webRequest.PreAuthenticate = true;
                }
                var webResponse = webRequest.GetResponse();

                if (!KeepCookiesClean) {
                    Cookies.AddCookies(webRequest.CookieContainer.GetCookies(webResponse.ResponseUri));
                }

                switch (responseType) {
                    case ResponseType.String:
                        result = GetStringResponse(webResponse);
                        resultCode = 200;
                        break;
                    case ResponseType.Binary:
                        result = GetBinaryResponse(webResponse);
                        resultCode = 200;
                        break;
                    case ResponseType.File:
                        result = GetBinaryFileResponse(webResponse, outputFilename);
                        resultCode = 200;
                        break;
                }
            } catch {
                resultCode = 0;
            }
            return result;
        }
开发者ID:roomaroo,项目名称:coapp.powershell,代码行数:60,代码来源:WebExtensions.cs

示例11: CreateRequest

 /// <summary>
 /// Creates the request of the specified type.
 /// </summary>
 /// <param name="requestType">Type of the request.</param>
 /// <param name="args">The args needed to create the request.</param>
 /// <returns>the request instance</returns>
 public IRequest CreateRequest(RequestType requestType, object[] args)
 {
     string requestName = GetRequestClassNameFromType(requestType);
      Type type = Type.GetType(requestName);
      IRequest request = (IRequest) Activator.CreateInstance(type, args);
      return request;
 }
开发者ID:AnnieBougie,项目名称:CVS-Library-Net,代码行数:13,代码来源:PServerFactory.cs

示例12: _0x34GetPlayerStatus

 public _0x34GetPlayerStatus(int Serial,RequestType reqtype)
     : base(0x34)
 {
     Data.WriteUInt(0xedededed);
     Data.WriteBit((byte)reqtype);
     Data.WriteInt(Serial);
 }
开发者ID:DarkLotus,项目名称:UOProxyNet,代码行数:7,代码来源:0x34GetPlayerStatus.cs

示例13: RequestResourceContext

 public RequestResourceContext(IAdapter adapter, IAdaptee adaptee,
     RequestType resource)
 {
     Adaptee = adaptee;
     Adapter = adapter;
     ReqType = resource;
 }
开发者ID:shasso,项目名称:cdp,代码行数:7,代码来源:ResortSystemCaseStudy.cs

示例14: Request

        public Request(string clientAddress, RequestType type, string path, double version, Dictionary<string, string> headers)
        {
            ClientAddress = clientAddress;
            Type = type;
            Path = path;
            Version = version;
            Headers = headers;
            string lengthString;
            if (Headers.TryGetValue("Content-Length", out lengthString))
            {
                try
                {
                    ContentLength = Convert.ToInt32(lengthString);
                }
                catch (FormatException)
                {
                    throw new ClientException("Invalid content length specified");
                }
            }
            else
                ContentLength = null;

            Headers.TryGetValue("X-Real-IP", out ClientAddress);

            Content = new Dictionary<string, string>();

            //Arguments are null until set by a non-default Handler
            Arguments = null;

            RequestHandler = null;
        }
开发者ID:LeeSeungSoo,项目名称:Blighttp,代码行数:31,代码来源:Request.cs

示例15: ChangeRequest

 public ChangeRequest(string path, string target, RequestType requestType, ItemType itemType)
 {
     this.item = new ItemSpec(path, RecursionType.None);
     this.target = target;
     this.requestType = requestType;
     this.itemType = itemType;
 }
开发者ID:Jeff-Lewis,项目名称:opentf,代码行数:7,代码来源:ChangeRequest.cs


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