本文整理汇总了C#中ResponseType.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# ResponseType.ToString方法的具体用法?C# ResponseType.ToString怎么用?C# ResponseType.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ResponseType
的用法示例。
在下文中一共展示了ResponseType.ToString方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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();
}
示例3: GetRequestUrl
public string GetRequestUrl(string requestUrl,double latitude,double longitude,ResponseType responseType)
{
if (_postArgumentList == null)
_postArgumentList = new List<KeyValuePair<string, object>>();
_postArgumentList.Add(new KeyValuePair<string,object>("lat",latitude));
_postArgumentList.Add(new KeyValuePair<string, object>("long", longitude));
_postArgumentList.Add(new KeyValuePair<string, object>("output", responseType.ToString().ToLower()));
return requestUrl;
}
示例4: GetAuthorizeUrl
public string GetAuthorizeUrl(ResponseType response = ResponseType.Code)
{
Dictionary<string, object> config = new Dictionary<string, object>()
{
{"client_id",ClientID},
{"redirect_uri",CallbackUrl},
{"response_type",response.ToString().ToLower()},
};
UriBuilder builder = new UriBuilder(AuthorizeUrl);
builder.Query = Utility.BuildQueryString(config);
return builder.ToString();
}
示例5: GetWeChatOauthUrl
public string GetWeChatOauthUrl(string requestUrl, string appId, ResponseType responseType, string redirectUrl,
string scope = "post_timeline", string state="")
{
requestUrl += "oauth";
Dictionary<string,object> mergeArgumentDic=new Dictionary<string,object>();
mergeArgumentDic.Add("appid", appId);
mergeArgumentDic.Add("response_type", responseType.ToString().ToLower());
mergeArgumentDic.Add("redirect_uri", redirectUrl);
mergeArgumentDic.Add("scope", scope);
mergeArgumentDic.Add("state", state);
return base.MergeRequestArgument(requestUrl,mergeArgumentDic);
}
示例6: OnCloseSessionsClicked
/// <summary>
/// Ferme la session ouverte dans le menu LoginWindow
/// </summary>
/// <param name="sender">Sender.</param>
/// <param name="e">E.</param>
protected void OnCloseSessionsClicked(object sender, EventArgs e)
{
MessageDialog md = new MessageDialog (this, DialogFlags.Modal, MessageType.Question,
ButtonsType.YesNo, "Êtes-vous sûr de vouloir fermer la session");
ResponseType rt = new ResponseType ();
rt = (ResponseType)md.Run ();
if (rt.ToString () == "Yes") {
md.Destroy ();
this.Destroy ();
LoginWindow lw = new LoginWindow ();
lw.Show ();
} else {
md.Destroy ();
}
}
示例7: GetAuthorizeUrl
public virtual string GetAuthorizeUrl(ResponseType responseType = ResponseType.Code)
{
UriBuilder uriBuilder = new UriBuilder(this.Option.AuthorizeUrl);
List<RequestOption> authorizeOptions = new List<RequestOption>() {
new RequestOption(){ Name= "client_id", Value= this.Option.ClientId},
new RequestOption(){ Name="redirect_uri", Value = this.Option.CallbackUrl},
new RequestOption(){ Name="response_type", Value = responseType.ToString().ToLower()}
};
if (!String.IsNullOrEmpty(this.Option.Display)) authorizeOptions.Add(new RequestOption() { Name = "display", Value = this.Option.Display });
if (!String.IsNullOrEmpty(this.Option.State)) authorizeOptions.Add(new RequestOption() { Name = "state", Value = this.Option.State });
if (!String.IsNullOrEmpty(this.Option.Scope)) authorizeOptions.Add(new RequestOption() { Name = "scope", Value = this.Option.Scope });
List<String> keyValuePairs = new List<String>();
foreach (var item in authorizeOptions)
{
if (item.IsBinary) continue;
var value = String.Format("{0}", item.Value);
if (!String.IsNullOrEmpty(value)) keyValuePairs.Add(String.Format("{0}={1}", Uri.EscapeDataString(item.Name), Uri.EscapeDataString(value)));
}
uriBuilder.Query = String.Join("&", keyValuePairs.ToArray());
return uriBuilder.Uri.ToString();
}
示例8: BuildAuthUri
/// <summary>
/// Build authentication link.
/// </summary>
/// <param name="instagramOAuthUri">The instagram o authentication URI.</param>
/// <param name="clientId">The client identifier.</param>
/// <param name="callbackUri">The callback URI.</param>
/// <param name="scopes">The scopes.</param>
/// <param name="responseType">Type of the response.</param>
/// <returns>The authentication uri</returns>
private static string BuildAuthUri(string instagramOAuthUri, string clientId, string callbackUri, ResponseType responseType, string scopes)
{
return string.Format("{0}?client_id={1}&redirect_uri={2}&response_type={3}&scope={4}", new object[] {
instagramOAuthUri.ToLower(),
clientId.ToLower(),
callbackUri,
responseType.ToString().ToLower(),
scopes.ToLower()
});
}
示例9: MessageBuilder
/// <summary>
/// Creates a new instance of the <see cref="MessageBuilder"/> class
/// used to build a response message.
/// </summary>
/// <param name="messageType">The <see cref="ResponseType"/> of the message</param>
public MessageBuilder(ResponseType messageType)
: this("-" + messageType.ToString(), null, false)
{
}
示例10: GetAuthorizeURL
/// <summary>
/// OAuth2的authorize接口
/// </summary>
/// <param name="response">返回类型,支持code、token,默认值为code。</param>
/// <param name="state">用于保持请求和回调的状态,在回调时,会在Query Parameter中回传该参数。 </param>
/// <param name="display">授权页面的终端类型,取值见下面的说明。
/// default 默认的授权页面,适用于web浏览器。
/// mobile 移动终端的授权页面,适用于支持html5的手机。
/// popup 弹窗类型的授权页,适用于web浏览器小窗口。
/// wap1.2 wap1.2的授权页面。
/// wap2.0 wap2.0的授权页面。
/// js 微博JS-SDK专用授权页面,弹窗类型,返回结果为JSONP回掉函数。
/// apponweibo 默认的站内应用授权页,授权后不返回access_token,只刷新站内应用父框架。
/// </param>
/// <returns></returns>
public string GetAuthorizeURL(ResponseType response= ResponseType.Code,string state=null, DisplayType display = DisplayType.Default)
{
Dictionary<string, string> config = new Dictionary<string, string>()
{
{"client_id",AppKey},
{"redirect_uri",CallbackUrl},
{"response_type",response.ToString().ToLower()},
{"state",state??string.Empty},
{"display",display.ToString().ToLower()},
};
UriBuilder builder = new UriBuilder(AUTHORIZE_URL);
builder.Query = Utility.BuildQueryString(config);
return builder.ToString();
}
示例11: BuildAuthUri
/// <summary>
/// Build authentication link.
/// </summary>
/// <param name="instagramOAuthUri">The instagram o authentication URI.</param>
/// <param name="clientId">The client identifier.</param>
/// <param name="callbackUri">The callback URI.</param>
/// <param name="scopes">The scopes.</param>
/// <param name="responseType">Type of the response.</param>
/// <param name="state">Optional parameter to "carry through a server-specific state"</param>
/// <returns>The authentication uri</returns>
private static string BuildAuthUri(string instagramOAuthUri, string clientId, string callbackUri, ResponseType responseType, string scopes, string state = null)
{
var authUri = string.Format("{0}?client_id={1}&redirect_uri={2}&response_type={3}&scope={4}", new object[] {
instagramOAuthUri.ToLower(),
clientId.ToLower(),
callbackUri,
responseType.ToString().ToLower(),
scopes.ToLower()
});
if (state != null)
{
authUri = $"{authUri}&state={state}";
}
return authUri;
}
示例12: _urlRequest
/* COPY OF _request method START */
/**
* Http Get Request
*
* @param List<string> request of URL directories.
* @return List<object> from JSON response.
*/
private bool _urlRequest(List<string> url_components, ResponseType type, Action<object> usercallback, bool reconnect)
{
List<object> result = new List<object>();
string channelName = getChannelName(url_components, type);
StringBuilder url = new StringBuilder();
// Add Origin To The Request
url.Append(this.ORIGIN);
// Generate URL with UTF-8 Encoding
foreach (string url_bit in url_components)
{
url.Append("/");
url.Append(_encodeURIcomponent(url_bit));
}
if (type == ResponseType.Presence || type == ResponseType.Subscribe)
{
url.Append("?uuid=");
url.Append(this.sessionUUID);
}
if (type == ResponseType.DetailedHistory)
url.Append(parameters);
// Temporary fail if string too long
if (url.Length > this.LIMIT)
{
result.Add(0);
result.Add("Message Too Long.");
// return result;
}
Uri requestUri = new Uri(url.ToString());
// Force canonical path and query
string paq = requestUri.PathAndQuery;
FieldInfo flagsFieldInfo = typeof(Uri).GetField("m_Flags", BindingFlags.Instance | BindingFlags.NonPublic);
ulong flags = (ulong)flagsFieldInfo.GetValue(requestUri);
flags &= ~((ulong)0x30); // Flags.PathNotCanonical|Flags.QueryNotCanonical
flagsFieldInfo.SetValue(requestUri, flags);
try
{
// Create Request
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestUri);
request.Timeout = PUBNUB_WEBREQUEST_CALLBACK_INTERVAL_IN_SEC * 1000;
if ((!_channelSubscription.ContainsKey(channelName) && type == ResponseType.Subscribe)
|| (!_channelPresence.ContainsKey(channelName) && type == ResponseType.Presence))
{
if (appSwitch.TraceInfo)
{
Trace.WriteLine(string.Format("DateTime {0}, Due to Unsubscribe, request aborted for channel={1}", DateTime.Now.ToString(), channelName));
}
request.Abort();
}
if (appSwitch.TraceInfo)
{
Trace.WriteLine(string.Format("DateTime {0}, Request={1}", DateTime.Now.ToString(), requestUri.ToString()));
}
RequestState pubnubRequestState = new RequestState();
pubnubRequestState.request = request;
pubnubRequestState.channel = channelName;
if (type == ResponseType.Subscribe || type == ResponseType.Presence)
{
_channelRequest.AddOrUpdate(channelName, pubnubRequestState, (key, oldState) => pubnubRequestState);
}
// Make request with the following inline Asynchronous callback
IAsyncResult asyncResult = request.BeginGetResponse(new AsyncCallback((asynchronousResult) =>
{
try
{
RequestState asynchRequestState = (RequestState)asynchronousResult.AsyncState;
HttpWebRequest aRequest = (HttpWebRequest)asynchRequestState.request;
if (aRequest != null)
{
using (HttpWebResponse aResponse = (HttpWebResponse)aRequest.EndGetResponse(asynchronousResult))
{
pubnubRequestState.response = aResponse;
using (StreamReader streamReader = new StreamReader(aResponse.GetResponseStream()))
{
// Deserialize the result
string jsonString = streamReader.ReadToEnd();
streamReader.Close();
heartBeatTimer.Change(
//.........这里部分代码省略.........