本文整理汇总了C#中ResponseType类的典型用法代码示例。如果您正苦于以下问题:C# ResponseType类的具体用法?C# ResponseType怎么用?C# ResponseType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ResponseType类属于命名空间,在下文中一共展示了ResponseType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TSResponse
public TSResponse(XmlElement element)
{
type = (ResponseType)Enum.Parse(typeof(ResponseType), element.GetAttribute("type"), false);
XmlNodeList l = element.GetElementsByTagName("tuple");
id = element.GetAttribute("id");
tuples = new Tuple[l.Count];
for (int i = 0; i < l.Count; i++)
{
XmlElement elTuple = (XmlElement)l[i];
tuples[i] = new Tuple(elTuple);
}
}
示例2: OnBtnSendClicked
protected void OnBtnSendClicked (object sender, EventArgs e)
{
Response = ResponseType.Accept;
this.UserDescription = textview1.Buffer.Text;
this.HideAll ();
Send (ex, sv);
}
示例3: HttpWorker
public HttpWorker(Uri uri, HttpMethod httpMethod = HttpMethod.Get, Dictionary<string, string> headers = null, byte[] data = null)
{
_buffer = new byte[8192];
_bufferIndex = 0;
_read = 0;
_responseType = ResponseType.Unknown;
_uri = uri;
IPAddress ip;
var headersString = string.Empty;
var contentLength = data != null ? data.Length : 0;
if (headers != null && headers.Any())
headersString = string.Concat(headers.Select(h => "\r\n" + h.Key.Trim() + ": " + h.Value.Trim()));
if (_uri.HostNameType == UriHostNameType.Dns)
{
var host = Dns.GetHostEntry(_uri.Host);
ip = host.AddressList.First(i => i.AddressFamily == AddressFamily.InterNetwork);
}
else
{
ip = IPAddress.Parse(_uri.Host);
}
_endPoint = new IPEndPoint(ip, _uri.Port);
_request = Encoding.UTF8.GetBytes($"{httpMethod.ToString().ToUpper()} {_uri.PathAndQuery} HTTP/1.1\r\nAccept-Encoding: gzip, deflate, sdch\r\nHost: {_uri.Host}\r\nContent-Length: {contentLength}{headersString}\r\n\r\n");
if (data == null)
return;
var tmpRequest = new byte[_request.Length + data.Length];
Buffer.BlockCopy(_request, 0, tmpRequest, 0, _request.Length);
Buffer.BlockCopy(data, 0, tmpRequest, _request.Length, data.Length);
_request = tmpRequest;
}
示例4: ResponseEvent
/// <summary>
/// 建構子
/// </summary>
/// <param name="tradeOrder">訂單資訊</param>
/// <param name="symbolId">商品代號</param>
/// <param name="type">回報類型</param>
/// <param name="openTrades">開倉交易單列表</param>
/// <param name="closeTrades">已平倉交易單列表</param>
public ResponseEvent(ITradeOrder tradeOrder, string symbolId, ResponseType type, TradeList<ITrade> openTrades, List<ITrade> closeTrades) {
__cTradeOrder = tradeOrder;
__sSymbolId = symbolId;
__cType = type;
__cOpenTrades = openTrades;
__cCloseTrades = closeTrades;
}
示例5: 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;
}
示例6: OnResponse
protected override void OnResponse(ResponseType response_id)
{
base.OnResponse (response_id);
if (response_id == ResponseType.Cancel)
this.Destroy();
}
示例7: ResponseElement
/// <summary>
/// Creates a new response object with the given XML representation.
/// </summary>
/// <param name="xml">XML representation of this response</param>
public ResponseElement(XmlNode xml) : base(xml)
{
switch(xml.Name)
{
case "success":
type = ResponseType.Success;
break;
case "failure":
type = ResponseType.Failure;
break;
case "stream:error":
type = ResponseType.StreamError;
break;
case "starttls":
type = ResponseType.StartTls;
break;
case "proceed":
type = ResponseType.ProceedTls;
break;
case "challenge":
type = ResponseType.SaslChallenge;
break;
case "response":
type = ResponseType.SaslResponse;
break;
default:
throw new OpenXMPPException("An unknown response element was received.");
}
}
示例8: OnLoginResponse
private void OnLoginResponse(ResponseType responseType, JToken responseData, string callee) {
if (responseType == ResponseType.Success) {
authenticationToken = responseData.Value<string>("token");
if (OnLoggedIn != null) {
OnLoggedIn();
}
} else if (responseType == ResponseType.ClientError) {
if (OnLoginFailed != null) {
OnLoginFailed("Could not reach the server. Please try again later.");
}
} else {
JToken fieldToken = responseData["non_field_errors"];
if (fieldToken == null || !fieldToken.HasValues) {
if (OnLoginFailed != null) {
OnLoginFailed("Login failed: unknown error.");
}
} else {
string errors = "";
JToken[] fieldValidationErrors = fieldToken.Values().ToArray();
foreach (JToken validationError in fieldValidationErrors) {
errors += validationError.Value<string>();
}
if (OnLoginFailed != null) {
OnLoginFailed("Login failed: " + errors);
}
}
}
}
示例9: NetCommand
//RESPONSE
public NetCommand(ResponseType response, int session)
{
Type = CommandType.RESPONSE;
Session = session;
Timestamp = Helper.Now;
Response = response;
}
示例10: BuildAuthorizeUrl
/// <summary>
/// Constructs an authorize url.
/// </summary>
public static string BuildAuthorizeUrl(
string clientId,
string redirectUrl,
IEnumerable<string> scopes,
ResponseType responseType,
DisplayType display,
ThemeType theme,
string locale,
string state)
{
Debug.Assert(!string.IsNullOrEmpty(clientId));
Debug.Assert(!string.IsNullOrEmpty(redirectUrl));
Debug.Assert(!string.IsNullOrEmpty(locale));
IDictionary<string, string> options = new Dictionary<string, string>();
options[AuthConstants.ClientId] = clientId;
options[AuthConstants.Callback] = redirectUrl;
options[AuthConstants.Scope] = BuildScopeString(scopes);
options[AuthConstants.ResponseType] = responseType.ToString().ToLowerInvariant();
options[AuthConstants.Display] = display.ToString().ToLowerInvariant();
options[AuthConstants.Locale] = locale;
options[AuthConstants.ClientState] = EncodeAppRequestState(state);
if (theme != ThemeType.None)
{
options[AuthConstants.Theme] = theme.ToString().ToLowerInvariant();
}
return BuildAuthUrl(AuthEndpointsInfo.AuthorizePath, options);
}
示例11: OnResponse
protected override void OnResponse (ResponseType response)
{
base.OnResponse (response);
if (CurrentFolderUri != null) {
LastFileChooserUri.Set (CurrentFolderUri);
}
}
示例12: OnResponse
protected override void OnResponse(ResponseType response)
{
if (response == ResponseType.Ok) {
int timervalue = sleepHour.ValueAsInt * 60 + sleepMin.ValueAsInt;
service.SleepTimerDuration = timervalue;
service.SetSleepTimer (timervalue);
}
}
示例13: AssessmentItem
/// <summary>
/// Constructor that accepts values for all mandatory fields
/// </summary>
///<param name="refId">A RefId</param>
///<param name="assessmentFormRefId">This RefId points to the assessment form of which the item is a part.</param>
///<param name="responseType">A value that indicates the response type for the item.</param>
///<param name="itemLabel">An item number or other identifier for the item. It may be used to indicate the order or grouping of items.</param>
///
public AssessmentItem( string refId, string assessmentFormRefId, ResponseType responseType, string itemLabel )
: base(Adk.SifVersion, AssessmentDTD.ASSESSMENTITEM)
{
this.RefId = refId;
this.AssessmentFormRefId = assessmentFormRefId;
this.SetResponseType( responseType );
this.ItemLabel = itemLabel;
}
示例14: OnResponse
protected override void OnResponse(ResponseType response)
{
base.OnResponse (response);
if (response == ResponseType.Help)
Help.DisplayUriOnScreen ("ghelp:questar/preferences",
base.Dialog.Screen);
}
示例15: BuildAuthenticateUri
protected Uri BuildAuthenticateUri(AuthenticationPermissions scope, ResponseType responseType)
{
var builder = new HttpUriBuilder(AuthenticationUrl);
builder.AddQueryStringParameter("client_id", this.ClientId);
builder.AddQueryStringParameter("response_type", responseType.ToString().ToLower());
builder.AddQueryStringParameter("scope", scope.GetParameterValue());
builder.AddQueryStringParameter("redirect_uri", RedirectUri);
return builder.Build();
}