本文整理汇总了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") };
}
示例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";
}