本文整理汇总了C#中RestClient.AddResourcePath方法的典型用法代码示例。如果您正苦于以下问题:C# RestClient.AddResourcePath方法的具体用法?C# RestClient.AddResourcePath怎么用?C# RestClient.AddResourcePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RestClient
的用法示例。
在下文中一共展示了RestClient.AddResourcePath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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());
rc.RequestMethod = "GET";
Stream s = rc.Request();
if (s == null)
return null;
if (s.Length > 0)
{
XmlSerializer xs = new XmlSerializer(typeof (AssetBase));
return (AssetBase) xs.Deserialize(s);
}
return null;
}
示例2: GetData
public byte[] GetData(string id)
{
if (m_Cache != null)
{
AssetBase fullAsset = m_Cache.Get(id);
if (fullAsset != null)
return fullAsset.Data;
}
RestClient rc = new RestClient(m_ServerURI);
rc.AddResourcePath("assets");
rc.AddResourcePath(id);
rc.AddResourcePath("data");
rc.RequestMethod = "GET";
Stream s = rc.Request();
if (s == null)
return null;
if (s.Length > 0)
{
byte[] ret = new byte[s.Length];
s.Read(ret, 0, (int)s.Length);
return ret;
}
return null;
}
示例3: Get
public WearableCacheItem[] Get(UUID id)
{
if (m_URL == String.Empty)
return null;
int size = 0;
using (RestClient rc = new RestClient(m_URL))
{
List<WearableCacheItem> ret = new List<WearableCacheItem>();
rc.AddResourcePath("bakes");
rc.AddResourcePath(id.ToString());
rc.RequestMethod = "GET";
try
{
Stream s = rc.Request(m_Auth);
using (XmlTextReader sr = new XmlTextReader(s))
{
sr.ReadStartElement("BakedAppearance");
while (sr.LocalName == "BakedTexture")
{
string sTextureIndex = sr.GetAttribute("TextureIndex");
int lTextureIndex = Convert.ToInt32(sTextureIndex);
string sCacheId = sr.GetAttribute("CacheId");
UUID lCacheId = UUID.Zero;
if (!(UUID.TryParse(sCacheId, out lCacheId)))
{
// ?? Nothing here
}
++size;
sr.ReadStartElement("BakedTexture");
AssetBase a = (AssetBase)m_serializer.Deserialize(sr);
ret.Add(new WearableCacheItem() { CacheId = lCacheId, TextureIndex = (uint)lTextureIndex, TextureAsset = a, TextureID = a.FullID });
sr.ReadEndElement();
}
m_log.DebugFormat("[XBakes]: read {0} textures for user {1}", ret.Count, id);
}
return ret.ToArray();
}
catch (XmlException)
{
return null;
}
}
}
示例4: Store
public void Store(UUID agentId, WearableCacheItem[] data)
{
if (m_URL == String.Empty)
return;
MemoryStream reqStream;
using (MemoryStream bakeStream = new MemoryStream())
using (XmlTextWriter bakeWriter = new XmlTextWriter(bakeStream, null))
{
bakeWriter.WriteStartElement(String.Empty, "BakedAppearance", String.Empty);
for (int i = 0; i < data.Length; i++)
{
if (data[i] != null)
{
bakeWriter.WriteStartElement(String.Empty, "BakedTexture", String.Empty);
bakeWriter.WriteAttributeString(String.Empty, "TextureIndex", String.Empty, data[i].TextureIndex.ToString());
bakeWriter.WriteAttributeString(String.Empty, "CacheId", String.Empty, data[i].CacheId.ToString());
if (data[i].TextureAsset != null)
m_serializer.Serialize(bakeWriter, data[i].TextureAsset);
bakeWriter.WriteEndElement();
}
}
bakeWriter.WriteEndElement();
bakeWriter.Flush();
reqStream = new MemoryStream(bakeStream.ToArray());
}
RestClient rc = new RestClient(m_URL);
rc.AddResourcePath("bakes");
rc.AddResourcePath(agentId.ToString());
rc.RequestMethod = "POST";
Util.FireAndForget(
delegate
{
rc.Request(reqStream, m_Auth);
m_log.DebugFormat("[XBakes]: stored {0} textures for user {1}", data.Length, agentId);
}, null, "XBakesModule.Store"
);
}