本文整理汇总了C#中OSDMap.Add方法的典型用法代码示例。如果您正苦于以下问题:C# OSDMap.Add方法的具体用法?C# OSDMap.Add怎么用?C# OSDMap.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSDMap
的用法示例。
在下文中一共展示了OSDMap.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Charge
public bool Charge(UUID agentID, int amount, string text, int daysUntilNextCharge, TransactionType type, string identifer, bool chargeImmediately)
{
IMoneyModule moneyModule = m_registry.RequestModuleInterface<IMoneyModule>();
if (moneyModule != null)
{
if (chargeImmediately)
{
bool success = moneyModule.Charge(agentID, amount, text, type);
if (!success)
return false;
}
IScheduleService scheduler = m_registry.RequestModuleInterface<IScheduleService>();
if (scheduler != null)
{
OSDMap itemInfo = new OSDMap();
itemInfo.Add("AgentID", agentID);
itemInfo.Add("Amount", amount);
itemInfo.Add("Text", text);
itemInfo.Add("Type", (int)type);
SchedulerItem item = new SchedulerItem("ScheduledPayment " + identifer,
OSDParser.SerializeJsonString(itemInfo), false,
DateTime.UtcNow, daysUntilNextCharge, RepeatType.days, agentID);
itemInfo.Add("SchedulerID", item.id);
scheduler.Save(item);
}
}
return true;
}
示例2: Charge
public bool Charge(UUID agentID, int amount, string text, int daysUntilNextCharge)
{
IMoneyModule moneyModule = m_registry.RequestModuleInterface<IMoneyModule>();
if (moneyModule != null)
{
bool success = moneyModule.Charge(agentID, amount, text);
if (!success)
return false;
IScheduleService scheduler = m_registry.RequestModuleInterface<IScheduleService>();
if (scheduler != null)
{
OSDMap itemInfo = new OSDMap();
itemInfo.Add("AgentID", agentID);
itemInfo.Add("Amount", amount);
itemInfo.Add("Text", text);
SchedulerItem item = new SchedulerItem("ScheduledPayment",
OSDParser.SerializeJsonString(itemInfo), false,
DateTime.Now.AddDays(daysUntilNextCharge) - DateTime.Now);
itemInfo.Add("SchedulerID", item.id);
scheduler.Save(item);
}
}
return true;
}
示例3: JsonRpcRequest
/// <summary>
/// Sends json-rpc request with a serializable type.
/// </summary>
/// <returns>
/// OSD Map.
/// </returns>
/// <param name='parameters'>
/// Serializable type .
/// </param>
/// <param name='method'>
/// Json-rpc method to call.
/// </param>
/// <param name='uri'>
/// URI of json-rpc service.
/// </param>
/// <param name='jsonId'>
/// Id for our call.
/// </param>
public bool JsonRpcRequest(ref object parameters, string method, string uri, string jsonId)
{
if (jsonId == null)
throw new ArgumentNullException ("jsonId");
if (uri == null)
throw new ArgumentNullException ("uri");
if (method == null)
throw new ArgumentNullException ("method");
if (parameters == null)
throw new ArgumentNullException ("parameters");
// Prep our payload
OSDMap json = new OSDMap();
json.Add("jsonrpc", OSD.FromString("2.0"));
json.Add("id", OSD.FromString(jsonId));
json.Add("method", OSD.FromString(method));
json.Add("params", OSD.SerializeMembers(parameters));
string jsonRequestData = OSDParser.SerializeJsonString(json);
byte[] content = Encoding.UTF8.GetBytes(jsonRequestData);
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(uri);
webRequest.ContentType = "application/json-rpc";
webRequest.Method = "POST";
//Stream dataStream = webRequest.GetRequestStream();
//dataStream.Write(content, 0, content.Length);
//dataStream.Close();
using (Stream dataStream = webRequest.GetRequestStream())
dataStream.Write(content, 0, content.Length);
WebResponse webResponse = null;
try
{
webResponse = webRequest.GetResponse();
}
catch (WebException e)
{
Console.WriteLine("Web Error" + e.Message);
Console.WriteLine ("Please check input");
return false;
}
using (webResponse)
using (Stream rstream = webResponse.GetResponseStream())
{
OSDMap mret = (OSDMap)OSDParser.DeserializeJson(rstream);
if (mret.ContainsKey("error"))
return false;
// get params...
OSD.DeserializeMembers(ref parameters, (OSDMap)mret["result"]);
return true;
}
}
示例4: ToOSD
public override OSDMap ToOSD()
{
OSDMap map = new OSDMap();
map.Add("MuteName", MuteName);
map.Add("MuteID", MuteID);
map.Add("MuteType", MuteType);
return map;
}
示例5: BuildEvent
// private static byte[] uintToByteArray(uint uIntValue)
// {
// byte[] result = new byte[4];
// Utils.UIntToBytesBig(uIntValue, result, 0);
// return result;
// }
public static OSD BuildEvent(string eventName, OSD eventBody)
{
OSDMap llsdEvent = new OSDMap(2);
llsdEvent.Add("message", new OSDString(eventName));
llsdEvent.Add("body", eventBody);
return llsdEvent;
}
示例6: JsonRpcRequest
/// <summary>
/// Sends json-rpc request with a serializable type.
/// </summary>
/// <returns>
/// OSD Map.
/// </returns>
/// <param name='parameters'>
/// Serializable type .
/// </param>
/// <param name='method'>
/// Json-rpc method to call.
/// </param>
/// <param name='uri'>
/// URI of json-rpc service.
/// </param>
/// <param name='jsonId'>
/// Id for our call.
/// </param>
public bool JsonRpcRequest(ref object parameters, string method, string uri, string jsonId)
{
if (jsonId == null)
throw new ArgumentNullException("jsonId");
if (uri == null)
throw new ArgumentNullException("uri");
if (method == null)
throw new ArgumentNullException("method");
if (parameters == null)
throw new ArgumentNullException("parameters");
OSDMap request = new OSDMap();
request.Add("jsonrpc", OSD.FromString("2.0"));
request.Add("id", OSD.FromString(jsonId));
request.Add("method", OSD.FromString(method));
request.Add("params", OSD.SerializeMembers(parameters));
OSDMap response;
try
{
response = WebUtil.PostToService(uri, request, 10000, true);
}
catch (Exception e)
{
m_log.Debug(string.Format("JsonRpc request '{0}' failed", method), e);
return false;
}
if (!response.ContainsKey("_Result"))
{
m_log.DebugFormat("JsonRpc request '{0}' returned an invalid response: {1}",
method, OSDParser.SerializeJsonString(response));
return false;
}
response = (OSDMap)response["_Result"];
OSD data;
if (response.ContainsKey("error"))
{
data = response["error"];
m_log.DebugFormat("JsonRpc request '{0}' returned an error: {1}",
method, OSDParser.SerializeJsonString(data));
return false;
}
if (!response.ContainsKey("result"))
{
m_log.DebugFormat("JsonRpc request '{0}' returned an invalid response: {1}",
method, OSDParser.SerializeJsonString(response));
return false;
}
data = response["result"];
OSD.DeserializeMembers(ref parameters, (OSDMap)data);
return true;
}
示例7: UpdateEstateInfo
public static OSDMap UpdateEstateInfo(uint EstateID, UUID RegionID)
{
OSDMap llsdBody = new OSDMap();
llsdBody.Add("EstateID", EstateID);
llsdBody.Add("RegionID", RegionID);
return buildEvent("UpdateEstateInfo", llsdBody, UUID.Zero, 0);
}
示例8: ArrivedAtDestination
public static OSDMap ArrivedAtDestination(UUID AgentID, int DrawDistance, AgentCircuitData circuit, ulong requestingRegion)
{
OSDMap llsdBody = new OSDMap();
llsdBody.Add("AgentID", AgentID);
llsdBody.Add("DrawDistance", DrawDistance);
llsdBody.Add("Circuit", circuit.PackAgentCircuitData());
return buildEvent("ArrivedAtDestination", llsdBody, AgentID, requestingRegion);
}
示例9: AgentStatusChange
/// <summary>
/// Tells the region to tell the given agent that the other agent is online
/// </summary>
/// <param name="AgentID">Agent that is either logging in or logging out</param>
/// <param name="FriendToInformID">Friend that will be told of the incoming/outgoing user</param>
/// <param name="newStatus">Whether they are logged in or out</param>
/// <returns></returns>
public static OSDMap AgentStatusChange(UUID AgentID, UUID FriendToInformID, bool newStatus)
{
OSDMap llsdBody = new OSDMap();
llsdBody.Add("AgentID", AgentID);
llsdBody.Add("FriendToInformID", FriendToInformID);
llsdBody.Add("NewStatus", newStatus);
return buildEvent("AgentStatusChange", llsdBody, AgentID, 0);
}
示例10: SerializeMapTest
public void SerializeMapTest() {
OSDMap capsMap = new OSDMap();
capsMap.Add("FetchInventoryDescendents2", "d5cb3302-2db8-4881-94de-161ce09df1a6");
capsMap.Add("FetchInventory2", "e1563faf-a081-4410-b160-ea1639aef192");
capsMap.Add("GetTexture", "26cecb27-ea2c-4152-b319-d06dd0b516ae");
capsMap.Add("GetMesh", "24f57f22-59b0-4c4a-a2c2-95a8858de972");
String result = OSDParser.SerializeJsonString(capsMap);
String jsonString = "{\"FetchInventoryDescendents2\":\"d5cb3302-2db8-4881-94de-161ce09df1a6\",\"FetchInventory2\":\"e1563faf-a081-4410-b160-ea1639aef192\",\"GetTexture\":\"26cecb27-ea2c-4152-b319-d06dd0b516ae\",\"GetMesh\":\"24f57f22-59b0-4c4a-a2c2-95a8858de972\"}";
Assert.That(jsonString.Equals(result));
}
示例11: DeserializeJson
public static OSD DeserializeJson(JsonData json)
{
switch (json.GetJsonType())
{
case JsonType.Boolean:
return OSD.FromBoolean((bool)json);
case JsonType.Int:
return OSD.FromInteger((int)json);
case JsonType.Long:
return OSD.FromLong((long)json);
case JsonType.Double:
return OSD.FromReal((double)json);
case JsonType.String:
string str = (string)json;
if (String.IsNullOrEmpty(str))
return new OSD();
else
return OSD.FromString(str);
case JsonType.Array:
OSDArray array = new OSDArray(json.Count);
for (int i = 0; i < json.Count; i++)
array.Add(DeserializeJson(json[i]));
return array;
case JsonType.Object:
OSDMap map = new OSDMap(json.Count);
foreach (KeyValuePair<string, JsonData> kvp in json)
map.Add(kvp.Key, DeserializeJson(kvp.Value));
return map;
case JsonType.None:
default:
return new OSD();
}
}
示例12: DeserializeJson
public static OSD DeserializeJson(JsonData json)
{
switch (json.GetJsonType())
{
case JsonType.Boolean:
return OSD.FromBoolean((bool)json);
case JsonType.Int:
return OSD.FromInteger((int)json);
case JsonType.Long:
return OSD.FromLong((long)json);
case JsonType.Double:
return OSD.FromReal((double)json);
case JsonType.String:
string str = (string)json;
if (String.IsNullOrEmpty(str))
return new OSD();
else
return OSD.FromString(str);
case JsonType.Array:
OSDArray array = new OSDArray(json.Count);
for (int i = 0; i < json.Count; i++)
array.Add(DeserializeJson(json[i]));
return array;
case JsonType.Object:
OSDMap map = new OSDMap(json.Count);
IDictionaryEnumerator e = ((IOrderedDictionary)json).GetEnumerator();
while (e.MoveNext())
map.Add((string)e.Key, DeserializeJson((JsonData)e.Value));
return map;
case JsonType.None:
default:
return new OSD();
}
}
示例13: EnableSimulator
public static OSD EnableSimulator(ulong handle, IPEndPoint endPoint)
{
OSDMap llsdSimInfo = new OSDMap(3);
llsdSimInfo.Add("Handle", new OSDBinary(ulongToByteArray(handle)));
llsdSimInfo.Add("IP", new OSDBinary(endPoint.Address.GetAddressBytes()));
llsdSimInfo.Add("Port", new OSDInteger(endPoint.Port));
OSDArray arr = new OSDArray(1);
arr.Add(llsdSimInfo);
OSDMap llsdBody = new OSDMap(1);
llsdBody.Add("SimulatorInfo", arr);
return BuildEvent("EnableSimulator", llsdBody);
}
示例14: GetExternalCaps
public OSDMap GetExternalCaps(UUID agentID, GridRegion region)
{
if (m_registry == null) return new OSDMap();
OSDMap resp = new OSDMap();
if (m_registry.RequestModuleInterface<IGridServerInfoService>() != null)
{
m_servers = m_registry.RequestModuleInterface<IGridServerInfoService>().GetGridURIs("SyncMessageServerURI");
OSDMap req = new OSDMap();
req["AgentID"] = agentID;
req["Region"] = region.ToOSD();
req["Method"] = "GetCaps";
List<ManualResetEvent> events = new List<ManualResetEvent>();
foreach (string uri in m_servers)
{
ManualResetEvent even = new ManualResetEvent(false);
m_syncPoster.Get(uri, req, (r) =>
{
if (r == null)
return;
foreach (KeyValuePair<string, OSD> kvp in r)
resp.Add(kvp.Key, kvp.Value);
even.Set();
});
events.Add(even);
}
ManualResetEvent.WaitAll(events.ToArray());
}
foreach (var h in GetHandlers(agentID, region.RegionID))
{
if (m_allowedCapsModules.Contains(h.Name))
h.IncomingCapsRequest(agentID, region, m_registry.RequestModuleInterface<ISimulationBase>(), ref resp);
}
return resp;
}
示例15: ToOSD
public override OSDMap ToOSD()
{
OSDMap map = new OSDMap();
map = base.ToOSD();
map.Add("Point", m_Point);
return map;
}