OpenSim.Services.Interfaces.GridRegion.ToKeyValuePairs C# (CSharp) Method

ToKeyValuePairs() public method

public ToKeyValuePairs ( ) : object>.Dictionary
return object>.Dictionary
        public Dictionary<string, object> ToKeyValuePairs()
        {
            Dictionary<string, object> kvp = new Dictionary<string, object>();
            kvp["uuid"] = RegionID.ToString();
            kvp["locX"] = RegionLocX.ToString();
            kvp["locY"] = RegionLocY.ToString();
            kvp["regionName"] = RegionName;
            kvp["serverIP"] = ExternalHostName; //ExternalEndPoint.Address.ToString();
            kvp["serverHttpPort"] = HttpPort.ToString();
            kvp["serverURI"] = ServerURI;
            kvp["serverPort"] = InternalEndPoint.Port.ToString();
            kvp["regionMapTexture"] = TerrainImage.ToString();
            kvp["access"] = Access.ToString();
            kvp["regionSecret"] = RegionSecret;
            kvp["owner_uuid"] = EstateOwner.ToString();
            kvp["Token"] = Token.ToString();
            // Maturity doesn't seem to exist in the DB
            return kvp;
        }

Usage Example

        public virtual string RegisterRegion(UUID scopeID, GridRegion regionInfo, UUID SecureSessionID, out UUID SessionID)
        {
            SessionID = UUID.Zero;
            Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs();
            Dictionary<string, object> sendData = new Dictionary<string,object>();
            foreach (KeyValuePair<string, object> kvp in rinfo)
                sendData[kvp.Key] = (string)kvp.Value;

            sendData["SCOPEID"] = scopeID.ToString();
            sendData["SESSIONID"] = SecureSessionID.ToString();
            sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
            sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
            sendData["METHOD"] = "register";

            string reqString = WebUtils.BuildQueryString(sendData);
            // m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString);
            try
            {
                string reply = SynchronousRestFormsRequester.MakeRequest("POST",
                        m_ServerURI + "/grid",
                        reqString);
                if (reply != string.Empty)
                {
                    Dictionary<string, object> replyData = WebUtils.ParseXmlResponse(reply);

                    if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "success"))
                    {
                        if (replyData.ContainsKey("Message"))
                        {
                            SessionID = UUID.Parse(replyData["Message"].ToString());
                        }
                        m_log.Info("[GridService]: Successfully registered region " + regionInfo.RegionName + " at " + regionInfo.RegionLocX + "," + regionInfo.RegionLocY + " to the grid server @ " + m_ServerURI);
                        return String.Empty;
                    }
                    else if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "failure"))
                    {
                        //m_log.DebugFormat("[GRID CONNECTOR]: Registration failed: {0}", replyData["Message"].ToString());
                        return replyData["Message"].ToString();
                    }
                    else if (!replyData.ContainsKey("Result"))
                    {
                        m_log.DebugFormat("[GRID CONNECTOR]: reply data does not contain result field");
                    }
                    else
                    {
                        m_log.DebugFormat("[GRID CONNECTOR]: unexpected result {0}", replyData["Result"].ToString());
                        return "Unexpected result "+replyData["Result"].ToString();
                    }
                }
                else
                    m_log.DebugFormat("[GRID CONNECTOR]: RegisterRegion received null reply from " + m_ServerURI);
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server " + m_ServerURI + " : {0}", e.Message);
            }

            return "Error communicating with grid service";
        }
All Usage Examples Of OpenSim.Services.Interfaces.GridRegion::ToKeyValuePairs