當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。