本文整理汇总了C#中QueryParameters.Add方法的典型用法代码示例。如果您正苦于以下问题:C# QueryParameters.Add方法的具体用法?C# QueryParameters.Add怎么用?C# QueryParameters.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryParameters
的用法示例。
在下文中一共展示了QueryParameters.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DirectUserToServiceProvider
public void DirectUserToServiceProvider()
{
UriBuilder ub = new UriBuilder(provider.UserLoginEndpoint);
try
{
QueryParameters oauthParams = new QueryParameters();
oauthParams.Add("client_id", provider.Consumerkey);
oauthParams.Add("redirect_uri", connectionToken.ProviderCallbackUrl);
oauthParams.Add("response_type", "code");
oauthParams.Add("scope", provider.GetScope());
//ub.SetQueryparameter("client_id", provider.Consumerkey);
//ub.SetQueryparameter("redirect_uri", connectionToken.ProviderCallbackUrl);
//ub.SetQueryparameter("response_type", "code");
//ub.SetQueryparameter("scope", provider.GetScope());
BeforeDirectingUserToServiceProvider(oauthParams);
logger.Debug("Redirecting user for login to " + ub.ToString() + "?" + oauthParams.ToEncodedString());
SocialAuthUser.Redirect(ub.ToString() + "?" + oauthParams.ToEncodedString());
}
catch (Exception ex)
{
logger.Error(ErrorMessages.UserLoginRedirectionError(ub.ToString()), ex);
throw new OAuthException(ErrorMessages.UserLoginRedirectionError(ub.ToString()), ex);
}
}
示例2: TestNegateMultiQuery
public void TestNegateMultiQuery()
{
var query = new QueryParameters<Artist>();
query.Add("artist", "stones");
query.Add("tag", "rock", true);
Assert.AreEqual("artist:stones AND NOT tag:rock", query.ToString());
}
示例3: TestInlineMultiQuery
public void TestInlineMultiQuery()
{
var query = new QueryParameters<Artist>();
query.Add("artist", "\"rolling stones\" OR jagger");
query.Add("tag", "rock", true);
Assert.AreEqual("artist:(\"rolling stones\" OR jagger) AND NOT tag:rock", query.ToString());
}
示例4: GetLoginUrl
public override string GetLoginUrl(string returnUrl)
{
var ub = new UriBuilder(provider.UserLoginEndpoint);
var oauthParams = new QueryParameters();
oauthParams.Add("client_id", provider.Consumerkey);
oauthParams.Add("redirect_uri", returnUrl);
oauthParams.Add("response_type", "code");
oauthParams.Add("scope", provider.GetScope());
BeforeDirectingUserToServiceProvider(oauthParams);
return ub.ToString() + "?" + oauthParams.ToEncodedString();
}
示例5: TestNegateSimpleQuery
public void TestNegateSimpleQuery()
{
var query = new QueryParameters<Artist>();
query.Add("arid", "1", true);
Assert.AreEqual("NOT arid:1", query.ToString());
}
示例6: TestInlineSimpleQuery
public void TestInlineSimpleQuery()
{
var query = new QueryParameters<Artist>();
query.Add("artist", "\"rolling stones\" OR jagger");
Assert.AreEqual("artist:(\"rolling stones\" OR jagger)", query.ToString());
}
示例7: TestAlreadyQuotedSimpleQuery
public void TestAlreadyQuotedSimpleQuery()
{
var query = new QueryParameters<Artist>();
query.Add("artist", "\"rolling stones\"");
Assert.AreEqual("artist:\"rolling stones\"", query.ToString());
}
示例8: GetLoginUrl
public override string GetLoginUrl(string returnUrl)
{
var oauthParameters = new QueryParameters();
string processedUrl = "";
if(string.IsNullOrEmpty(provider.UserLoginEndpoint))
PerformDiscovery();
oauthParameters.Add("openid.ns", "http://specs.openid.net/auth/2.0");
oauthParameters.Add("openid.claimed_id", "http://specs.openid.net/auth/2.0/identifier_select");
oauthParameters.Add("openid.identity", "http://specs.openid.net/auth/2.0/identifier_select");
oauthParameters.Add("openid.return_to", returnUrl);
oauthParameters.Add("openid.realm", ConnectionToken.Domain);
oauthParameters.Add("openid.mode", "checkid_setup");
oauthParameters.Add("openid.ns.pape", "http://specs.openid.net/extensions/pape/1.0");
oauthParameters.Add("openid.ns.max_auth_age", "0");
oauthParameters.Add("openid.ns.ax", "http://openid.net/srv/ax/1.0");
oauthParameters.Add("openid.ax.mode", "fetch_request");
oauthParameters.Add("openid.ax.type.country", "http://axschema.org/contact/country/home");
oauthParameters.Add("openid.ax.type.email", "http://axschema.org/contact/email");
oauthParameters.Add("openid.ax.type.firstname", "http://axschema.org/namePerson/first");
oauthParameters.Add("openid.ax.type.language", "http://axschema.org/pref/language");
oauthParameters.Add("openid.ax.type.lastname", "http://axschema.org/namePerson/last");
oauthParameters.Add("openid.ax.required", "country,email,firstname,language,lastname");
//ADDING OAUTH PROTOCOLS
oauthParameters.Add("openid.ns.oauth", "http://specs.openid.net/extensions/oauth/1.0");
oauthParameters.Add("openid.oauth.consumer", provider.Consumerkey);
BeforeDirectingUserToServiceProvider(oauthParameters);
processedUrl = oauthParameters.ToEncodedString();
return provider.UserLoginEndpoint + "?" + processedUrl;
}
示例9: ExecuteFeed
public override System.Net.WebResponse ExecuteFeed(string feedURL, IProvider provider, BusinessObjects.Token connectionToken, BusinessObjects.TRANSPORT_METHOD transportMethod, byte[] content = null, Dictionary<string, string> headers = null)
{
string signature = "";
OAuthHelper oauthHelper = new OAuthHelper();
string timestamp = oauthHelper.GenerateTimeStamp();
QueryParameters oauthParams = new QueryParameters();
oauthParams.Add("oauth_consumer_key", provider.Consumerkey);
oauthParams.Add("oauth_nonce", oauthHelper.GenerateNonce());
oauthParams.Add("oauth_signature_method", provider.SignatureMethod.ToString());
oauthParams.Add("oauth_timestamp", timestamp);
oauthParams.Add("oauth_token", connectionToken.AccessToken);
oauthParams.Add("oauth_version", "1.0");
signature = oauthHelper.GenerateSignature(new Uri(feedURL), oauthParams, provider.Consumerkey, provider.Consumersecret, provider.SignatureMethod, TRANSPORT_METHOD.POST, connectionToken.TokenSecret);
oauthParams.Add("oauth_signature", signature);
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(feedURL);
request.Method = transportMethod.ToString();
if (headers != null)
{
foreach (var header in headers)
{
switch (header.Key)
{
case "ContentLength":
{
request.ContentLength = long.Parse(header.Value);
break;
}
case "ContentType":
{
request.ContentType = header.Value;
break;
}
default:
{
request.Headers[header.Key] = header.Value;
break;
}
}
}
}
request.ContentLength = (content == null) ? 0 : content.Length;
request.Headers.Add("Authorization", oauthHelper.GetAuthorizationHeader(oauthParams));
request.GetRequestStream().Write(content, 0, content.Length);
WebResponse wr = null;
try
{
logger.Debug("Executing " + feedURL + " using " + transportMethod.ToString() + Environment.NewLine + "Request Parameters: " + oauthParams.ToString());
wr = (WebResponse)request.GetResponse();
logger.Info("Successfully executed " + feedURL + " using " + transportMethod.ToString());
}
catch (Exception ex)
{
logger.Error(ErrorMessages.CustomFeedExecutionError(feedURL, oauthParams), ex);
throw new OAuthException(ErrorMessages.CustomFeedExecutionError(feedURL, oauthParams), ex);
}
return wr;
}
示例10: RequestForAccessToken
public void RequestForAccessToken()
{
QueryParameters oauthParameters = new QueryParameters();
string signature = "";
OAuthHelper oauthHelper = new OAuthHelper();
////1. Generate Signature
oauthParameters.Add("oauth_consumer_key", provider.Consumerkey);
oauthParameters.Add("oauth_token", Utility.UrlEncode(ConnectionToken.RequestToken));
oauthParameters.Add("oauth_signature_method", provider.SignatureMethod.ToString());
oauthParameters.Add("oauth_timestamp", oauthHelper.GenerateTimeStamp());
oauthParameters.Add("oauth_nonce", oauthHelper.GenerateNonce());
oauthParameters.Add("oauth_version", "1.0");
BeforeRequestingAccessToken(oauthParameters); // hook called
signature = oauthHelper.GenerateSignature(new Uri(provider.AccessTokenEndpoint), oauthParameters, provider.Consumerkey, provider.Consumersecret, provider.SignatureMethod, provider.TransportName, string.Empty);
oauthParameters.Add("oauth_signature", Utility.UrlEncode(signature));
//2. Notify Consumer (if applicable)
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(provider.AccessTokenEndpoint + "?" + oauthParameters.ToString().Replace("HMACSHA1", "HMAC-SHA1"));
request.Method = "GET";// always get irrespective of provider.TransportName.ToString();
request.ContentLength = 0;
string response = "";
try
{
logger.Debug("Requesting Access Token at: " + request.RequestUri + Environment.NewLine + "Request Parameters: " + oauthParameters.ToString());
using (HttpWebResponse webResponse = (HttpWebResponse)request.GetResponse())
using (Stream responseStream = webResponse.GetResponseStream())
using (StreamReader reader = new StreamReader(responseStream))
{
response = reader.ReadToEnd();
HandleAccessTokenResponse(Utility.GetQuerystringParameters(response));
}
}
catch (Exception ex)
{
logger.Debug(ErrorMessages.AccessTokenRequestError(request.RequestUri.ToString(), oauthParameters), ex);
throw new OAuthException(ErrorMessages.AccessTokenRequestError(request.RequestUri.ToString(), oauthParameters), ex);
}
}
示例11: HandleRequestToken
public void HandleRequestToken(QueryParameters responseCollection)
{
//In Hybrid protocol, OAuth may not be necessary. In such case flow ends
//But some providers may have scope black as scope is defined at provider directly (like Yahoo)
if (responseCollection.HasName("openid.mode"))
{
if (responseCollection["openid.mode"].Contains("cancel"))
throw new UserDeniedPermissionException(provider.ProviderType);
}
if (!string.IsNullOrEmpty(provider.GetScope()) || provider.IsScopeDefinedAtProvider)
if (responseCollection.HasName("openid.oauth.request_token"))
ConnectionToken.RequestToken = responseCollection["openid.oauth.request_token"];
else if (responseCollection.HasName("openid.ext2.request_token"))
ConnectionToken.RequestToken = responseCollection["openid.ext2.request_token"];
else
{
logger.Error(ErrorMessages.RequestTokenResponseInvalid(responseCollection));
throw new OAuthException(ErrorMessages.RequestTokenResponseInvalid(responseCollection));
}
QueryParameters openIDValues = new QueryParameters();
if (responseCollection.HasName("openid.ns.ext1"))
{
if (responseCollection.HasName("openid.ext1.value.email"))
openIDValues.Add(new QueryParameter("openid.ext1.value.email", responseCollection["openid.ext1.value.email"]));
if (responseCollection.HasName("openid.ext1.value.firstname"))
openIDValues.Add(new QueryParameter("openid.ext1.value.firstname", responseCollection["openid.ext1.value.firstname"]));
if (responseCollection.HasName("openid.ext1.value.lastname"))
openIDValues.Add(new QueryParameter("openid.ext1.value.lastname", responseCollection["openid.ext1.value.lastname"]));
if (responseCollection.HasName("openid.ext1.value.language"))
openIDValues.Add(new QueryParameter("openid.ext1.value.language", responseCollection["openid.ext1.value.language"]));
if (responseCollection.HasName("openid.ext1.value.country"))
openIDValues.Add(new QueryParameter("openid.ext1.value.country", responseCollection["openid.ext1.value.country"]));
if (responseCollection.HasName("openid.identity"))
openIDValues.Add(new QueryParameter("openid.identity", responseCollection["openid.identity"]));
ConnectionToken.ResponseCollection.AddRange(openIDValues, true);
}
else if (responseCollection.HasName("openid.ns.ax"))
{
if (responseCollection.HasName("openid.ax.value.email"))
openIDValues.Add(new QueryParameter("openid.ax.value.email", responseCollection["openid.ax.value.email"]));
if (responseCollection.HasName("openid.ax.value.firstname"))
openIDValues.Add(new QueryParameter("openid.ax.value.firstname", responseCollection["openid.ax.value.firstname"]));
if (responseCollection.HasName("openid.ax.value.lastname"))
openIDValues.Add(new QueryParameter("openid.ax.value.lastname", responseCollection["openid.ax.value.lastname"]));
if (responseCollection.HasName("openid.ax.value.language"))
openIDValues.Add(new QueryParameter("openid.ax.value.language", responseCollection["openid.ax.value.language"]));
if (responseCollection.HasName("openid.ax.value.country"))
openIDValues.Add(new QueryParameter("openid.ax.value.country", responseCollection["openid.ax.value.country"]));
ConnectionToken.ResponseCollection.AddRange(openIDValues, true);
}
logger.Info("User successfully logged in and returned with Authorization Token");
}
示例12: DirectUserToServiceProvider
public void DirectUserToServiceProvider()
{
QueryParameters oauthParameters = new QueryParameters();
try
{
oauthParameters.Add(new QueryParameter("oauth_token", connectionToken.RequestToken));
BeforeDirectingUserToServiceProvider(oauthParameters);
logger.Debug("redirecting user for login to: " + provider.UserLoginEndpoint + "?" + oauthParameters.ToString());
SocialAuthUser.Redirect(provider.UserLoginEndpoint + "?" + oauthParameters.ToString());
}
catch (Exception ex)
{
logger.Error(ErrorMessages.UserLoginRedirectionError(provider.UserLoginEndpoint + "?" + oauthParameters.ToString()), ex);
throw new OAuthException(ErrorMessages.UserLoginRedirectionError(provider.UserLoginEndpoint + "?" + oauthParameters.ToString()), ex);
}
}
示例13: RetrieveAnnotationsInformationForStudy
private static StudyItemList RetrieveAnnotationsInformationForStudy(string studyInstanceUID)
{
QueryParameters queryParams = new QueryParameters();
queryParams.Add("PatientsName", "");
queryParams.Add("ReferringPhysiciansName", "");
queryParams.Add("PatientId", "");
queryParams.Add("AccessionNumber", "");
queryParams.Add("StudyDescription", "");
queryParams.Add("ModalitiesInStudy", "SR");
queryParams.Add("StudyDate", "");
queryParams.Add("StudyInstanceUid", studyInstanceUID);
ServerTree serverTree = new ServerTree();
List<KeyValuePair<string, Exception>> failedServerInfo = new List<KeyValuePair<string, Exception>>();
List<IServerTreeNode> localDataStoreList = new List<IServerTreeNode>();
// TODO - retrieve annotations from remote host as well. Maybe, when streaming is in use only?
localDataStoreList.Add(serverTree.RootNode.LocalDataStoreNode);
return Query(queryParams, failedServerInfo, localDataStoreList);
}
示例14: TestQuoteSimpleQuery
public void TestQuoteSimpleQuery()
{
var query = new QueryParameters<Artist>();
query.Add("artist", "bob dylan");
Assert.AreEqual("artist:\"bob dylan\"", query.ToString());
}
示例15: TestQuoteMultiQuery
public void TestQuoteMultiQuery()
{
var query = new QueryParameters<Artist>();
query.Add("artist", "rolling stones");
query.Add("tag", "rock");
Assert.AreEqual("artist:\"rolling stones\" AND tag:rock", query.ToString());
}