本文整理汇总了C#中OSDMap.TryGetValue方法的典型用法代码示例。如果您正苦于以下问题:C# OSDMap.TryGetValue方法的具体用法?C# OSDMap.TryGetValue怎么用?C# OSDMap.TryGetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSDMap
的用法示例。
在下文中一共展示了OSDMap.TryGetValue方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseInventorySkeleton
public InventoryFolder[] ParseInventorySkeleton(string key, OSDMap reply)
{
List<InventoryFolder> folders = new List<InventoryFolder>();
OSD skeleton;
if (reply.TryGetValue(key, out skeleton) && skeleton.Type == OSDType.Array)
{
OSDArray array = (OSDArray)skeleton;
for (int i = 0; i < array.Count; i++)
{
if (array[i].Type == OSDType.Map)
{
OSDMap map = (OSDMap)array[i];
InventoryFolder folder = new InventoryFolder(map["folder_id"].AsUUID());
folder.Name = map["name"].AsString();
folder.ParentUUID = map["parent_id"].AsUUID();
folder.PreferredType = (AssetType)map["type_default"].AsInteger();
folder.Version = map["version"].AsInteger();
folders.Add(folder);
}
}
}
return folders.ToArray();
}
示例2: ParseVector3
public static Vector3 ParseVector3(string key, OSDMap reply)
{
OSD osd;
if (reply.TryGetValue(key, out osd))
{
if (osd.Type == OSDType.Array)
{
return ((OSDArray)osd).AsVector3();
}
else if (osd.Type == OSDType.String)
{
OSDArray array = (OSDArray)OSDParser.DeserializeLLSDNotation(osd.AsString());
return array.AsVector3();
}
}
return Vector3.Zero;
}
示例3: ParseMappedUUID
public static UUID ParseMappedUUID(string key, string key2, OSDMap reply)
{
OSD folderOSD;
if (reply.TryGetValue(key, out folderOSD) && folderOSD.Type == OSDType.Array)
{
OSDArray array = (OSDArray)folderOSD;
if (array.Count == 1 && array[0].Type == OSDType.Map)
{
OSDMap map = (OSDMap)array[0];
OSD folder;
if (map.TryGetValue(key2, out folder))
return folder.AsUUID();
}
}
return UUID.Zero;
}
示例4: ParseUUID
public static UUID ParseUUID(string key, OSDMap reply)
{
OSD osd;
if (reply.TryGetValue(key, out osd))
return osd.AsUUID();
else
return UUID.Zero;
}
示例5: ParseString
public static string ParseString(string key, OSDMap reply)
{
OSD osd;
if (reply.TryGetValue(key, out osd))
return osd.AsString();
else
return String.Empty;
}
示例6: ParseUInt
public static uint ParseUInt(string key, OSDMap reply)
{
OSD osd;
if (reply.TryGetValue(key, out osd))
return osd.AsUInteger();
else
return 0;
}
示例7: Parse
/// <summary>
/// Parse LLSD Login Reply Data
/// </summary>
/// <param name="reply">An <seealso cref="OSDMap"/>
/// contaning the login response data</param>
/// <remarks>XML-RPC logins do not require this as XML-RPC.NET
/// automatically populates the struct properly using attributes</remarks>
public void Parse(OSDMap reply)
{
try
{
AgentID = ParseUUID("agent_id", reply);
SessionID = ParseUUID("session_id", reply);
SecureSessionID = ParseUUID("secure_session_id", reply);
FirstName = ParseString("first_name", reply).Trim('"');
LastName = ParseString("last_name", reply).Trim('"');
StartLocation = ParseString("start_location", reply);
AgentAccess = ParseString("agent_access", reply);
LookAt = ParseVector3("look_at", reply);
Reason = ParseString("reason", reply);
Message = ParseString("message", reply);
Login = reply["login"].AsString();
Success = reply["login"].AsBoolean();
}
catch (OSDException e)
{
Logger.Log("Login server returned (some) invalid data: " + e.Message, Helpers.LogLevel.Warning);
}
// Home
OSDMap home = null;
OSD osdHome = OSDParser.DeserializeLLSDNotation(reply["home"].AsString());
if (osdHome.Type == OSDType.Map)
{
home = (OSDMap)osdHome;
OSD homeRegion;
if (home.TryGetValue("region_handle", out homeRegion) && homeRegion.Type == OSDType.Array)
{
OSDArray homeArray = (OSDArray)homeRegion;
if (homeArray.Count == 2)
HomeRegion = Utils.UIntsToLong((uint)homeArray[0].AsInteger(), (uint)homeArray[1].AsInteger());
else
HomeRegion = 0;
}
HomePosition = ParseVector3("position", home);
HomeLookAt = ParseVector3("look_at", home);
}
else
{
HomeRegion = 0;
HomePosition = Vector3.Zero;
HomeLookAt = Vector3.Zero;
}
CircuitCode = (int)ParseUInt("circuit_code", reply);
RegionX = (int)ParseUInt("region_x", reply);
RegionY = (int)ParseUInt("region_y", reply);
SimPort = (short)ParseUInt("sim_port", reply);
string simIP = ParseString("sim_ip", reply);
IPAddress.TryParse(simIP, out SimIP);
SeedCapability = ParseString("seed_capability", reply);
// Buddy list
OSD buddyLLSD;
if (reply.TryGetValue("buddy-list", out buddyLLSD) && buddyLLSD.Type == OSDType.Array)
{
List<BuddyListEntry> buddys = new List<BuddyListEntry>();
OSDArray buddyArray = (OSDArray)buddyLLSD;
for (int i = 0; i < buddyArray.Count; i++)
{
if (buddyArray[i].Type == OSDType.Map)
{
BuddyListEntry bud = new BuddyListEntry();
OSDMap buddy = (OSDMap)buddyArray[i];
bud.buddy_id = buddy["buddy_id"].AsString();
bud.buddy_rights_given = (int)ParseUInt("buddy_rights_given", buddy);
bud.buddy_rights_has = (int)ParseUInt("buddy_rights_has", buddy);
buddys.Add(bud);
}
BuddyList = buddys.ToArray();
}
}
SecondsSinceEpoch = (int)ParseUInt("seconds_since_epoch", reply);
InventoryRoot = ParseMappedUUID("inventory-root", "folder_id", reply);
InventorySkeleton = ParseInventorySkeleton("inventory-skeleton", reply);
LibraryOwner = ParseMappedUUID("inventory-lib-owner", "agent_id", reply);
LibraryRoot = ParseMappedUUID("inventory-lib-root", "folder_id", reply);
LibrarySkeleton = ParseInventorySkeleton("inventory-skel-lib", reply);
}
示例8: Parse
public void Parse(OSDMap reply)
{
try
{
AgentID = ParseUUID("agent_id", reply);
SessionID = ParseUUID("session_id", reply);
SecureSessionID = ParseUUID("secure_session_id", reply);
FirstName = ParseString("first_name", reply).Trim('"');
LastName = ParseString("last_name", reply).Trim('"');
StartLocation = ParseString("start_location", reply);
AgentAccess = ParseString("agent_access", reply);
LookAt = ParseVector3("look_at", reply);
AssetServerUri = ParseString("asset_server_address", reply);
}
catch (OSDException e)
{
Logger.DebugLog("Login server returned (some) invalid data: " + e.Message);
}
// Home
OSDMap home = null;
OSD osdHome = OSDParser.DeserializeLLSDNotation(reply["home"].AsString());
if (osdHome.Type == OSDType.Map)
{
home = (OSDMap)osdHome;
OSD homeRegion;
if (home.TryGetValue("region_handle", out homeRegion) && homeRegion.Type == OSDType.Array)
{
OSDArray homeArray = (OSDArray)homeRegion;
if (homeArray.Count == 2)
HomeRegion = Utils.UIntsToLong((uint)homeArray[0].AsInteger(), (uint)homeArray[1].AsInteger());
else
HomeRegion = 0;
}
HomePosition = ParseVector3("position", home);
HomeLookAt = ParseVector3("look_at", home);
}
else
{
HomeRegion = 0;
HomePosition = Vector3.Zero;
HomeLookAt = Vector3.Zero;
}
CircuitCode = ParseUInt("circuit_code", reply);
RegionX = ParseUInt("region_x", reply);
RegionY = ParseUInt("region_y", reply);
SimPort = (ushort)ParseUInt("sim_port", reply);
string simIP = ParseString("sim_ip", reply);
IPAddress.TryParse(simIP, out SimIP);
SeedCapability = ParseString("seed_capability", reply);
// Buddy list
OSD buddyLLSD;
if (reply.TryGetValue("buddy-list", out buddyLLSD) && buddyLLSD.Type == OSDType.Array)
{
OSDArray buddyArray = (OSDArray)buddyLLSD;
BuddyList = new FriendInfo[buddyArray.Count];
for (int i = 0; i < buddyArray.Count; i++)
{
if (buddyArray[i].Type == OSDType.Map)
{
OSDMap buddy = (OSDMap)buddyArray[i];
BuddyList[i] = new FriendInfo(
ParseUUID("buddy_id", buddy),
(FriendRights)ParseUInt("buddy_rights_given", buddy),
(FriendRights)ParseUInt("buddy_rights_has", buddy));
}
}
}
SecondsSinceEpoch = Utils.UnixTimeToDateTime(ParseUInt("seconds_since_epoch", reply));
InventoryRoot = ParseMappedUUID("inventory-root", "folder_id", reply);
InventorySkeleton = ParseInventoryFolders("inventory-skeleton", AgentID, reply);
LibraryRoot = ParseMappedUUID("inventory-lib-root", "folder_id", reply);
LibraryOwner = ParseMappedUUID("inventory-lib-owner", "agent_id", reply);
LibrarySkeleton = ParseInventoryFolders("inventory-skel-lib", LibraryOwner, reply);
}
示例9: ParseMappedGuid
public static Guid ParseMappedGuid(string key, string key2, OSDMap reply)
{
OSD folderOSD;
if (reply.TryGetValue(key, out folderOSD) && folderOSD.Type == OSDType.Array)
{
OSDArray array = (OSDArray)folderOSD;
if (array.Count == 1 && array[0].Type == OSDType.Map)
{
OSDMap map = (OSDMap)array[0];
OSD folder;
if (map.TryGetValue(key2, out folder))
return folder.AsGuid();
}
}
return Guid.Empty;
}
示例10: ParseGuid
public static Guid ParseGuid(string key, OSDMap reply)
{
OSD osd;
if (reply.TryGetValue(key, out osd))
return osd.AsGuid();
else
return Guid.Empty;
}