当前位置: 首页>>代码示例>>C#>>正文


C# RestClient.AddResourcePath方法代码示例

本文整理汇总了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;
        }
开发者ID:ChrisD,项目名称:opensim,代码行数:26,代码来源:GridAssetClient.cs

示例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;
        }
开发者ID:MAReantals,项目名称:opensim,代码行数:32,代码来源:AssetServicesConnector.cs

示例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;
                }
            }
        }
开发者ID:szielins,项目名称:opensim,代码行数:53,代码来源:XBakesModule.cs

示例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"
            );
        }
开发者ID:szielins,项目名称:opensim,代码行数:46,代码来源:XBakesModule.cs


注:本文中的RestClient.AddResourcePath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。