本文整理汇总了C#中LLSDMap.TryGetValue方法的典型用法代码示例。如果您正苦于以下问题:C# LLSDMap.TryGetValue方法的具体用法?C# LLSDMap.TryGetValue怎么用?C# LLSDMap.TryGetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLSDMap
的用法示例。
在下文中一共展示了LLSDMap.TryGetValue方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseMappedUUID
public static UUID ParseMappedUUID(string key, string key2, LLSDMap reply)
{
LLSD folderLLSD;
if (reply.TryGetValue(key, out folderLLSD) && folderLLSD.Type == LLSDType.Array)
{
LLSDArray array = (LLSDArray)folderLLSD;
if (array.Count == 1 && array[0].Type == LLSDType.Map)
{
LLSDMap map = (LLSDMap)array[0];
LLSD folder;
if (map.TryGetValue(key2, out folder))
return folder.AsUUID();
}
}
return UUID.Zero;
}
示例2: ParseInventoryFolders
public static FolderData[] ParseInventoryFolders(string key, UUID owner, LLSDMap reply)
{
List<FolderData> folders = new List<FolderData>();
LLSD skeleton;
if (reply.TryGetValue(key, out skeleton) && skeleton.Type == LLSDType.Array)
{
LLSDArray array = (LLSDArray)skeleton;
for (int i = 0; i < array.Count; i++)
{
if (array[i].Type == LLSDType.Map)
{
LLSDMap map = (LLSDMap)array[i];
FolderData folder = new FolderData(map["folder_id"].AsUUID());
folder.PreferredType = (AssetType)map["type_default"].AsInteger();
folder.Version = map["version"].AsInteger();
folder.OwnerID = owner;
folder.ParentUUID = map["parent_id"].AsUUID();
folder.Name = map["name"].AsString();
folders.Add(folder);
}
}
}
return folders.ToArray();
}
示例3: ParseString
public static string ParseString(string key, LLSDMap reply)
{
LLSD llsd;
if (reply.TryGetValue(key, out llsd))
return llsd.AsString();
else
return String.Empty;
}
示例4: ParseVector3
public static Vector3 ParseVector3(string key, LLSDMap reply)
{
LLSD llsd;
if (reply.TryGetValue(key, out llsd))
{
if (llsd.Type == LLSDType.Array)
{
Vector3 vec = new Vector3();
vec.FromLLSD(llsd);
return vec;
}
else if (llsd.Type == LLSDType.String)
{
LLSDArray array = (LLSDArray)LLSDParser.DeserializeNotation(llsd.AsString());
Vector3 vec = new Vector3();
vec.FromLLSD(array);
return vec;
}
}
return Vector3.Zero;
}
示例5: ParseUUID
public static UUID ParseUUID(string key, LLSDMap reply)
{
LLSD llsd;
if (reply.TryGetValue(key, out llsd))
return llsd.AsUUID();
else
return UUID.Zero;
}
示例6: ParseUInt
public static uint ParseUInt(string key, LLSDMap reply)
{
LLSD llsd;
if (reply.TryGetValue(key, out llsd))
return (uint)llsd.AsInteger();
else
return 0;
}
示例7: Parse
public void Parse(LLSDMap 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);
}
catch (LLSDException e)
{
// FIXME: sometimes look_at comes back with invalid values e.g: 'look_at':'[r1,r2.0193899999999998204e-06,r0]'
// need to handle that somehow
Logger.DebugLog("login server returned (some) invalid data: " + e.Message);
}
// Home
LLSDMap home = null;
LLSD llsdHome = LLSDParser.DeserializeNotation(reply["home"].AsString());
if (llsdHome.Type == LLSDType.Map)
{
home = (LLSDMap)llsdHome;
LLSD homeRegion;
if (home.TryGetValue("region_handle", out homeRegion) && homeRegion.Type == LLSDType.Array)
{
LLSDArray homeArray = (LLSDArray)homeRegion;
if (homeArray.Count == 2)
HomeRegion = Helpers.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
LLSD buddyLLSD;
if (reply.TryGetValue("buddy-list", out buddyLLSD) && buddyLLSD.Type == LLSDType.Array)
{
LLSDArray buddyArray = (LLSDArray)buddyLLSD;
BuddyList = new FriendInfo[buddyArray.Count];
for (int i = 0; i < buddyArray.Count; i++)
{
if (buddyArray[i].Type == LLSDType.Map)
{
LLSDMap buddy = (LLSDMap)buddyArray[i];
BuddyList[i] = new FriendInfo(
ParseUUID("buddy_id", buddy),
(FriendRights)ParseUInt("buddy_rights_given", buddy),
(FriendRights)ParseUInt("buddy_rights_has", buddy));
}
}
}
SecondsSinceEpoch = Helpers.UnixTimeToDateTime(ParseUInt("seconds_since_epoch", reply));
InventoryRoot = ParseMappedUUID("inventory-root", "folder_id", reply);
InventoryFolders = ParseInventoryFolders("inventory-skeleton", AgentID, reply);
LibraryRoot = ParseMappedUUID("inventory-lib-root", "folder_id", reply);
LibraryOwner = ParseMappedUUID("inventory-lib-owner", "agent_id", reply);
LibraryFolders = ParseInventoryFolders("inventory-skel-lib", LibraryOwner, reply);
}
示例8: Parse
public void Parse(LLSDMap reply)
{
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 = ParseLLVector3("look_at", reply);
// Home
LLSDMap home = (LLSDMap)LLSDParser.DeserializeNotation(reply["home"].AsString());
if (home != null)
{
LLSD homeRegion;
if (home.TryGetValue("region_handle", out homeRegion) && homeRegion.Type == LLSDType.Array)
{
LLSDArray homeArray = (LLSDArray)homeRegion;
if (homeArray.Count == 2)
HomeRegion = Helpers.UIntsToLong((uint)homeArray[0].AsInteger(), (uint)homeArray[1].AsInteger());
else
HomeRegion = 0;
}
HomePosition = ParseLLVector3("position", home);
HomeLookAt = ParseLLVector3("look_at", home);
}
else
{
HomeRegion = 0;
HomePosition = LLVector3.Zero;
HomeLookAt = LLVector3.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
LLSD buddyLLSD;
if (reply.TryGetValue("buddy-list", out buddyLLSD) && buddyLLSD.Type == LLSDType.Array)
{
LLSDArray buddyArray = (LLSDArray)buddyLLSD;
BuddyList = new FriendInfo[buddyArray.Count];
for (int i = 0; i < buddyArray.Count; i++)
{
if (buddyArray[i].Type == LLSDType.Map)
{
LLSDMap buddy = (LLSDMap)buddyArray[i];
BuddyList[i] = new FriendInfo(
ParseUUID("buddy_id", buddy),
(FriendRights)ParseUInt("buddy_rights_given", buddy),
(FriendRights)ParseUInt("buddy_rights_has", buddy));
}
}
}
SecondsSinceEpoch = Helpers.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: ParseVector3
public static Vector3 ParseVector3(string key, LLSDMap reply)
{
LLSD llsd;
if (reply.TryGetValue(key, out llsd))
{
if (llsd.Type == LLSDType.Array)
{
return ((LLSDArray)llsd).AsVector3();
}
else if (llsd.Type == LLSDType.String)
{
LLSDArray array = (LLSDArray)LLSDParser.DeserializeNotation(llsd.AsString());
return array.AsVector3();
}
}
return Vector3.Zero;
}