本文整理汇总了C#中RequestData类的典型用法代码示例。如果您正苦于以下问题:C# RequestData类的具体用法?C# RequestData怎么用?C# RequestData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RequestData类属于命名空间,在下文中一共展示了RequestData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddListen
public void AddListen(String Request, RequestData rd)
{
modelData md = new modelData();
md.Request = Request;
md.rd = rd;
listmode.Add(md);
}
示例2: Request
public Task<ResponseData> Request(RequestData request, CancellationToken token)
{
this.EnsureIsRunning();
var requestId = this.NextId();
var callback = new TaskCompletionSource<ResponseData>();
this.requestCallbacks[requestId] = callback;
Task.Run(() =>
{
var zmqRequest = new ZmqRequest(requestId, request);
var zmqRequestBytes = zmqRequest.ToBinary();
this.requestsQueue.TryAdd(zmqRequestBytes);
});
if (token != CancellationToken.None)
{
token.Register(() =>
{
TaskCompletionSource<ResponseData> _;
this.requestCallbacks.TryRemove(requestId, out _);
});
}
return callback.Task;
}
示例3: GetSitecoreData
private RequestData GetSitecoreData()
{
var data = new RequestData();
data.Add(DataKey.Request, GetRequest());
data.Add(DataKey.Diagnostics, GetDiagnostics());
data.Add(DataKey.PageMode, GetPageMode());
data.Add(DataKey.Culture, GetCulture());
data.Add(DataKey.Language, GetLanguage());
data.Add(DataKey.Domain, GetDomain());
data.Add(DataKey.Device, GetDevice());
data.Add(DataKey.User, GetUser());
data.Add(DataKey.Database, GetDatabase());
data.Add(DataKey.Site, GetSite());
data.Add(DataKey.ItemVisualization, GetItemVisualization());
data.Add(DataKey.ItemTemplate, GetItemTemplate());
data.Add(DataKey.Item, GetItem());
data.Add(DataKey.VersionInfo, GetVersionInfo());
data.Add(DataKey.License, GetLicense());
data.Add(DataKey.Services, _serviceClients.ToArray());
data.Add(DataKey.Controllers, _controllers.ToArray());
data.Add(DataKey.UserList, _users.ToArray());
return data;
}
示例4: AddEqualToDataAttr
public void AddEqualToDataAttr(IEnumerable<PropertyValidatorResult> propertyValidators, HtmlTag htmlTag, RequestData request)
{
var result = propertyValidators.FirstOrDefault(x => x.PropertyValidator is EqualValidator);
if (result != null)
{
var equal = result.PropertyValidator.As<EqualValidator>();
MessageFormatter formatter = new MessageFormatter()
.AppendPropertyName(result.DisplayName)
.AppendArgument("ComparisonValue", equal.ValueToCompare);
string message = formatter.BuildMessage(equal.ErrorMessageSource.GetString());
if (_msUnobtrusive)
{
htmlTag.Data("val", true);
htmlTag.Data("val-equalto", message);
if (request.Accessor.PropertyNames.Length > 1)
htmlTag.Data("val-equalto-other", request.Id.Replace("_" + request.Accessor.Name, "") + "_" + equal.MemberToCompare.Name);
else
htmlTag.Data("val-equalto-other", "*." + equal.MemberToCompare.Name);
}
else
{
htmlTag.Data("msg-equalto", message);
if (request.Accessor.PropertyNames.Length > 1)
htmlTag.Data("rule-equalto", "#" + request.Id.Replace("_" + request.Accessor.Name, "") + "_" + equal.MemberToCompare.Name);
else
htmlTag.Data("rule-equalto", "#" + equal.MemberToCompare.Name);
}
}
}
示例5: ServeWebRequest
public bool ServeWebRequest(RawRequestData aRawRequest, IWebRequestResponder aResponder)
{
string browserClass = aRawRequest.Cookies["xappbrowser"].FirstOrDefault();
if (String.IsNullOrEmpty(browserClass) &&
aRawRequest.Path.PathSegments.Count == 0)
{
//Console.WriteLine("Serving browser discrimination page.");
Console.WriteLine("Serve {0} with discriminator.", String.Join("/", aRawRequest.Path.PathSegments));
aResponder.SendPage("200 OK", PageSource.MakeSourceFromString(StringType.Html, IndexPage));
return true;
}
string userName = aRawRequest.Cookies["xappuser"].FirstOrDefault();
User user = null;
if (!String.IsNullOrEmpty(userName))
{
iUserList.TryGetUserById(userName, out user);
}
RequestData requestData = new RequestData(aRawRequest.Path, aRawRequest.Method, user, browserClass);
if (user == null)
{
Console.WriteLine("Serve {0} from login app.", String.Join("/", aRawRequest.Path.PathSegments));
return iLoginApp.ServeWebRequest(requestData, aResponder);
}
Console.WriteLine("Serve {0} from base app.", String.Join("/", aRawRequest.Path.PathSegments));
return iBaseApp.ServeWebRequest(requestData, aResponder);
}
示例6: Request
public Task<ResponseData> Request(RequestData request, CancellationToken _)
{
var cancellation = new CancellationTokenSource(this.timeout);
var responseTask = this.client.Request(request, cancellation.Token);
var completion = new TaskCompletionSource<ResponseData>();
//when the token reaches timeout, tries to set the timeoutResponse as the result
//if the responseTask already completed, this is ignored
cancellation.Token.Register(() => completion.TrySetResult(this.timeoutResponse));
//when the responseTask completes, tries to apply its exception/result properties as long as the timeout isn't reached
responseTask.ContinueWith(t =>
{
if (!cancellation.IsCancellationRequested)
{
if (responseTask.Exception != null)
{
completion.TrySetException(responseTask.Exception.InnerException);
}
else
{
completion.TrySetResult(responseTask.Result);
}
}
});
return completion.Task;
}
示例7: Execute
// Remote Handler
// Key information of interest here is the Parameters array, each
// entry represents an element of the URI, with element zero being
// the
public void Execute(RequestData rdata)
{
if (!enabled) return;
// If we can't relate to what's there, leave it for others.
if (rdata.Parameters.Length == 0 || rdata.Parameters[PARM_TESTID] != "remote")
return;
Rest.Log.DebugFormat("{0} REST Remote handler ENTRY", MsgId);
// Remove the prefix and what's left are the parameters. If we don't have
// the parameters we need, fail the request. Parameters do NOT include
// any supplied query values.
if (rdata.Parameters.Length > 1)
{
switch (rdata.Parameters[PARM_COMMAND].ToLower())
{
case "move" :
DoMove(rdata);
break;
default :
DoHelp(rdata);
break;
}
}
else
{
DoHelp(rdata);
}
}
示例8: Request
public Task<ResponseData> Request(RequestData request, CancellationToken token)
{
var svc = this.serviceFactory.CreateService(request.Service);
var responseTask = svc.Process(request);
return responseTask;
}
示例9: open
public void open(JObject options, ICallback callback)
{
if (options != null)
{
var requestData = new RequestData
{
Title = options.Value<string>("title"),
Text = options.Value<string>("share_text"),
Url = options.Value<string>("share_URL"),
};
if (requestData.Text == null && requestData.Title == null && requestData.Url == null)
{
return;
}
RunOnDispatcher(() =>
{
lock (_queue)
{
_queue.Enqueue(requestData);
}
try
{
DataTransferManager.ShowShareUI();
callback.Invoke("OK");
}
catch
{
callback.Invoke("not_available");
}
});
}
}
示例10: AddEqualToDataAttr
public void AddEqualToDataAttr(IEnumerable<ValidationAttribute> propertyValidators, HtmlTag htmlTag, RequestData request)
{
var equal = propertyValidators.OfType<CompareAttribute>().FirstOrDefault();
if (equal != null)
{
var formatErrorMessage = equal.FormatErrorMessage(request.Accessor.Name);
if (_msUnobtrusive)
{
htmlTag.Data("val", true);
htmlTag.Data("val-equalto", formatErrorMessage);
if (request.Accessor.PropertyNames.Length > 1)
{
htmlTag.Data("val-equalto-other", request.Id.Replace("_" + request.Accessor.Name, "") + "_" + equal.OtherProperty);
}
else
{
htmlTag.Data("val-equalto-other", "*." + equal.OtherProperty);
}
}
else
{
htmlTag.Data("msg-equalto", formatErrorMessage);
if (request.Accessor.PropertyNames.Length > 1)
htmlTag.Data("rule-equalto", "#" + request.Id.Replace("_" + request.Accessor.Name, "") + "_" + equal.OtherProperty);
else
htmlTag.Data("rule-equalto", "#" + equal.OtherProperty);
}
}
}
示例11: DownloadEventArgs
public DownloadEventArgs(string fileLocation, Guid taskGuid, RequestData request, string errorDescription = null)
{
FileLocation = fileLocation;
TaskGuid = taskGuid;
ErrorDescription = errorDescription;
Request = request;
}
示例12: BuildOAuthHeader
private string BuildOAuthHeader(RequestData requestData, string fullUrl, IDictionary<string, string> parameters, RequestPayload requestBody)
{
var httpMethod = requestData.HttpMethod.ToString().ToUpperInvariant();
var oauthRequest = new OAuthRequest
{
Type = OAuthRequestType.ProtectedResource,
RequestUrl = fullUrl,
Method = httpMethod,
ConsumerKey = _oAuthCredentials.ConsumerKey,
ConsumerSecret = _oAuthCredentials.ConsumerSecret,
};
if (!string.IsNullOrEmpty(requestData.OAuthToken))
{
oauthRequest.Token = requestData.OAuthToken;
oauthRequest.TokenSecret = requestData.OAuthTokenSecret;
}
if (ShouldReadParamsFromBody(parameters, requestBody))
{
var bodyParams = HttpUtility.ParseQueryString(requestBody.Data);
var keys = bodyParams.AllKeys.Where(x => !string.IsNullOrEmpty(x));
foreach (var key in keys)
{
parameters.Add(key, bodyParams[key]);
}
}
return oauthRequest.GetAuthorizationHeader(parameters);
}
示例13: HandleGetRequest
public override void HandleGetRequest(HttpProcessor p)
{
Log.Debug(@"request: {0}", p.HttpUrl);
LastRequestData = new RequestData(p.HttpMethod, p.HttpUrl, p.HttpProtocolVersionstring, p.HttpHeaders);
SendResponse(p);
}
示例14: SetUp
public void SetUp()
{
dictionary = new Dictionary<string, object>();
aggregate = new AggregateDictionary();
aggregate.AddLocator(RequestDataSource.Route, key => dictionary.ContainsKey(key) ? dictionary[key] : null);
request = new RequestData(aggregate);
}
示例15: SetUp
public void SetUp()
{
dictionary = new Dictionary<string, object>();
aggregate = new AggregateDictionary();
aggregate.AddDictionary(dictionary);
request = new RequestData(aggregate);
}