本文整理汇总了C#中RestClient.AddQueryParameter方法的典型用法代码示例。如果您正苦于以下问题:C# RestClient.AddQueryParameter方法的具体用法?C# RestClient.AddQueryParameter怎么用?C# RestClient.AddQueryParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RestClient
的用法示例。
在下文中一共展示了RestClient.AddQueryParameter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NotifyDataServices
private void NotifyDataServices(string servicesStr, string serviceName)
{
Stream reply = null;
string delimStr = ";";
char [] delimiter = delimStr.ToCharArray();
string[] services = servicesStr.Split(delimiter);
for (int i = 0; i < services.Length; i++)
{
string url = services[i].Trim();
using (RestClient cli = new RestClient(url))
{
cli.AddQueryParameter("service", serviceName);
cli.AddQueryParameter("host", m_hostname);
cli.AddQueryParameter("port", m_listener_port);
cli.AddQueryParameter("secret", m_Secret.ToString());
cli.RequestMethod = "GET";
try
{
reply = cli.Request(null);
}
catch (WebException)
{
m_log.Warn("[DATASNAPSHOT]: Unable to notify " + url);
}
catch (Exception e)
{
m_log.Warn("[DATASNAPSHOT]: Ignoring unknown exception " + e.ToString());
}
byte[] response = new byte[1024];
// int n = 0;
try
{
// n = reply.Read(response, 0, 1024);
reply.Read(response, 0, 1024);
}
catch (Exception e)
{
m_log.WarnFormat("[DATASNAPSHOT]: Unable to decode reply from data service. Ignoring. {0}", e.StackTrace);
}
// This is not quite working, so...
// string responseStr = Util.UTF8.GetString(response);
m_log.Info("[DATASNAPSHOT]: data service " + url + " notified. Secret: " + m_Secret);
}
}
}
示例2: GetAsset
protected override AssetBase GetAsset(AssetRequest req)
{
#if DEBUG
//m_log.DebugFormat("[GRID ASSET CLIENT]: Querying for {0}", req.AssetID.ToString());
#endif
RestClient rc = new RestClient(_assetServerUrl);
rc.AddResourcePath("assets");
rc.AddResourcePath(req.AssetID.ToString());
if (req.IsTexture)
rc.AddQueryParameter("texture");
rc.RequestMethod = "GET";
Stream s = rc.Request();
if (s == null)
return null;
if (s.Length > 0)
{
XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
AssetBase encAsset = (AssetBase)xs.Deserialize(s);
// Try decrypt it
if (DecryptAssetBase(encAsset))
return encAsset;
}
return null;
}