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


C# GridRegion.ToKVP方法代码示例

本文整理汇总了C#中OpenSim.Services.Interfaces.GridRegion.ToKVP方法的典型用法代码示例。如果您正苦于以下问题:C# GridRegion.ToKVP方法的具体用法?C# GridRegion.ToKVP怎么用?C# GridRegion.ToKVP使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenSim.Services.Interfaces.GridRegion的用法示例。


在下文中一共展示了GridRegion.ToKVP方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RegisterRegion

        public RegisterRegion RegisterRegion(GridRegion regionInfo, UUID oldSessionID, string password)
        {
            Dictionary<string, object> rinfo = regionInfo.ToKVP();
            Dictionary<string, object> sendData = new Dictionary<string, object>();
            foreach (KeyValuePair<string, object> kvp in rinfo)
                sendData[kvp.Key] = kvp.Value.ToString();

            sendData["SCOPEID"] = UUID.Zero.ToString();
            sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
            sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
            sendData["METHOD"] = "register";

            string reqString = WebUtils.BuildQueryString(sendData);
            List<string> serverURIs =
                m_registry.RequestModuleInterface<IConfigurationService>().FindValueOf("GridServerURI");
            foreach (string uri in serverURIs)
            {
                // MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString);
                try
                {
                    string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
                    if (reply != string.Empty)
                    {
                        Dictionary<string, object> replyData = WebUtils.ParseXmlResponse(reply);

                        if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "success"))
                        {
                            return new RegisterRegion() { Error = "" };
                        }
                        else if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "failure"))
                        {
                            MainConsole.Instance.ErrorFormat(
                                "[GRID CONNECTOR]: Registration failed: {0} when contacting {1}", replyData["Message"], uri);

                            return new RegisterRegion() { Error = replyData["Message"].ToString() };
                        }
                        else if (!replyData.ContainsKey("Result"))
                        {
                            MainConsole.Instance.ErrorFormat(
                                "[GRID CONNECTOR]: reply data does not contain result field when contacting {0}", uri);
                        }
                        else
                        {
                            MainConsole.Instance.ErrorFormat(
                                "[GRID CONNECTOR]: unexpected result {0} when contacting {1}", replyData["Result"], uri);

                            return new RegisterRegion() { Error = "Unexpected result " + replyData["Result"].ToString() };
                        }
                    }
                    else
                    {
                        MainConsole.Instance.ErrorFormat(
                            "[GRID CONNECTOR]: RegisterRegion received null reply when contacting grid server at {0}", uri);
                    }
                }
                catch (Exception e)
                {
                    MainConsole.Instance.ErrorFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
                }
            }

            return new RegisterRegion() { Error = string.Format("Error communicating with the grid service") };
        }
开发者ID:samiam123,项目名称:Aurora-Sim,代码行数:63,代码来源:RobustGridServiceConnector.cs

示例2: OldRegisterRegion

        public virtual string OldRegisterRegion(GridRegion region)
        {
            Dictionary<string, object> rinfo = region.ToKVP();
            Dictionary<string, object> sendData = new Dictionary<string, object>();
            foreach (KeyValuePair<string, object> kvp in rinfo)
                sendData[kvp.Key] = kvp.Value;

            sendData["SCOPEID"] = region.ScopeID.ToString();
            sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
            sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
            sendData["METHOD"] = "register";

            string reqString = WebUtils.BuildQueryString(sendData);
            // MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString);
            try
            {
                List<string> serverURIs =
                    m_registry.RequestModuleInterface<IConfigurationService>().FindValueOf("GridServerURI");
                foreach (string mServerUri in serverURIs)
                {
                    string reply = SynchronousRestFormsRequester.MakeRequest("POST", mServerUri, reqString);
                    if (reply != string.Empty)
                    {
                        Dictionary<string, object> replyData = WebUtils.ParseXmlResponse(reply);

                        if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "success"))
                        {
                            return String.Empty;
                        }
                        else if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "failure"))
                        {
                            MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: Registration failed: {0}", replyData["Message"]);
                            return replyData["Message"].ToString();
                        }
                        else if (!replyData.ContainsKey("Result"))
                        {
                            MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: reply data does not contain result field");
                        }
                        else
                        {
                            MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: unexpected result {0}", replyData["Result"]);
                            return "Unexpected result " + replyData["Result"];
                        }
                    }
                    else
                        MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: RegisterRegion received null reply");
                }
            }
            catch (Exception e)
            {
                MainConsole.Instance.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
            }

            return "Error communicating with grid service";
        }
开发者ID:satlanski2,项目名称:Aurora-Sim,代码行数:55,代码来源:GridServiceConnector.cs


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