本文整理汇总了C#中OpenSim.Framework.InventoryCollection类的典型用法代码示例。如果您正苦于以下问题:C# InventoryCollection类的具体用法?C# InventoryCollection怎么用?C# InventoryCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InventoryCollection类属于OpenSim.Framework命名空间,在下文中一共展示了InventoryCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFolderContent
/// <summary>
/// Gets everything (folders and items) inside a folder
/// </summary>
/// <param name="userId"></param>
/// <param name="folderID"></param>
/// <returns></returns>
public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
{
InventoryFolderImpl folder = null;
InventoryCollection inv = new InventoryCollection();
inv.UserID = m_Library.Owner;
if (folderID != m_Library.ID)
{
folder = m_Library.FindFolder(folderID);
if (folder == null)
{
inv.Folders = new List<InventoryFolderBase>();
inv.Items = new List<InventoryItemBase>();
return inv;
}
}
else
folder = m_Library;
inv.Folders = folder.RequestListOfFolders();
inv.Items = folder.RequestListOfItems();
m_log.DebugFormat("[LIBRARY MODULE]: Got content for folder {0}", folder.Name);
return inv;
}
示例2: GetFolderContent
public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
{
InventoryCollection inv = null;
InventoryCollection c;
if (m_Inventories.TryGetValue(userID, out inv))
{
c = new InventoryCollection();
c.UserID = userID;
c.Folders = inv.Folders.FindAll(delegate(InventoryFolderBase f)
{
return f.ParentID == folderID;
});
c.Items = inv.Items.FindAll(delegate(InventoryItemBase i)
{
return i.Folder == folderID;
});
return c;
}
return null;
}
示例3: GetUserInventory
public virtual InventoryCollection GetUserInventory(UUID userID)
{
InventoryCollection userInventory = new InventoryCollection();
userInventory.UserID = userID;
userInventory.Folders = new List<InventoryFolderBase>();
userInventory.Items = new List<InventoryItemBase>();
List<InventoryFolderBase> skel = GetInventorySkeleton(userID);
if (skel != null)
{
foreach (InventoryFolderBase f in skel)
{
InventoryCollection c = GetFolderContent(userID, f.ID);
if (c != null && c.Items != null && c.Items.Count > 0)
userInventory.Items.AddRange(c.Items);
if (c != null && c.Folders != null && c.Folders.Count > 0)
userInventory.Folders.AddRange(c.Folders);
}
}
m_log.DebugFormat("[XINVENTORY SERVICE]: GetUserInventory for user {0} returning {1} folders and {2} items",
userID, userInventory.Folders.Count, userInventory.Items.Count);
return userInventory;
}
示例4: CheckIDInInventoryCollection
private static InventoryNodeBase CheckIDInInventoryCollection(InventoryCollection ic, UUID uuid)
{
foreach (InventoryFolderBase ifb in ic.Folders)
{
if (ifb.ID == uuid)
return ifb;
}
foreach (InventoryItemBase iib in ic.Items)
{
if (iib.ID == uuid)
return iib;
}
return null;
}
示例5: HandleFetchInventoryDescendentsCAPS
/// <summary>
/// Handle the caps inventory descendents fetch.
///
/// Since the folder structure is sent to the client on login, I believe we only need to handle items.
/// Diva comment 8/13/2009: what if someone gave us a folder in the meantime??
/// </summary>
/// <param name="agentID"></param>
/// <param name="folderID"></param>
/// <param name="ownerID"></param>
/// <param name="fetchFolders"></param>
/// <param name="fetchItems"></param>
/// <param name="sortOrder"></param>
/// <returns>null if the inventory look up failed</returns>
public InventoryCollection HandleFetchInventoryDescendentsCAPS(UUID agentID, UUID folderID, UUID ownerID,
bool fetchFolders, bool fetchItems, int sortOrder, out int version)
{
m_log.DebugFormat(
"[INVENTORY CACHE]: Fetching folders ({0}), items ({1}) from {2} for agent {3}",
fetchFolders, fetchItems, folderID, agentID);
// FIXME MAYBE: We're not handling sortOrder!
// TODO: This code for looking in the folder for the library should be folded back into the
// CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc.
// can be handled transparently).
InventoryFolderImpl fold;
if (LibraryService != null && LibraryService.LibraryRootFolder != null)
if ((fold = LibraryService.LibraryRootFolder.FindFolder(folderID)) != null)
{
version = 0;
InventoryCollection ret = new InventoryCollection();
ret.Folders = new List<InventoryFolderBase>();
ret.Items = fold.RequestListOfItems();
return ret;
}
InventoryCollection contents = new InventoryCollection();
if (folderID != UUID.Zero)
{
contents = InventoryService.GetFolderContent(agentID, folderID);
InventoryFolderBase containingFolder = new InventoryFolderBase();
containingFolder.ID = folderID;
containingFolder.Owner = agentID;
containingFolder = InventoryService.GetFolder(containingFolder);
version = containingFolder.Version;
}
else
{
// Lost itemsm don't really need a version
version = 1;
}
return contents;
}
示例6: DescendantsCallBack
// Shamelessly copied from LLClientView
private void DescendantsCallBack(InventoryCollection inv)
{
// Send InventoryDescendentsPacket(s)
Console.WriteLine("[InventoryClient]: Received InventoryCollection");
InventoryFolderBase fb = null;
bool fetchFolders = false, fetchItems = false;
lock (pendingRequests)
{
fb = pendingRequests[0];
pendingRequests.RemoveAt(0);
fetchFolders = pendingRequestsFetchFoldersFlag[0];
pendingRequestsFetchFoldersFlag.RemoveAt(0);
fetchItems = pendingRequestsFetchItemsFlag[0];
pendingRequestsFetchItemsFlag.RemoveAt(0);
}
if (fb == null)
{
Console.WriteLine("[InventoryClient]: Request not found ??? ");
return;
}
List<InventoryItemBase> items = inv.Items;
List<InventoryFolderBase> folders = inv.Folders;
//// Add them to our local cache -- DON'T, they're already there
//foreach (InventoryItemBase item in items)
//{
// AddToCache(item);
//}
// An inventory descendents packet consists of a single agent section and an inventory details
// section for each inventory item. The size of each inventory item is approximately 550 bytes.
// In theory, UDP has a maximum packet size of 64k, so it should be possible to send descendent
// packets containing metadata for in excess of 100 items. But in practice, there may be other
// factors (e.g. firewalls) restraining the maximum UDP packet size. See,
//
// http://opensimulator.org/mantis/view.php?id=226
//
// for one example of this kind of thing. In fact, the Linden servers appear to only send about
// 6 to 7 items at a time, so let's stick with 6
int MAX_ITEMS_PER_PACKET = 6;
//Ckrinke This variable is not used, so comment out to remove the warning from the compiler (3-21-08)
//Ckrinke uint FULL_MASK_PERMISSIONS = 2147483647;
int itemsSent = 0;
InventoryDescendentsPacket descend = new InventoryDescendentsPacket();
if (fetchItems)
{
descend.Header.Zerocoded = true;
descend.AgentData.AgentID = inv.UserID;
descend.AgentData.OwnerID = inv.UserID;
descend.AgentData.FolderID = fb.ID;
descend.AgentData.Version = 1;
if (items.Count < MAX_ITEMS_PER_PACKET)
{
descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items.Count];
}
else
{
descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[MAX_ITEMS_PER_PACKET];
}
// Descendents must contain the *total* number of descendents (plus folders, whether we
// fetch them or not), not the number of entries we send in this packet. For consistency,
// I'll use it for folder-requests, too, although I wasn't able to get one with
// FetchFolders = true.
// TODO this should be checked with FetchFolders = true
descend.AgentData.Descendents = items.Count + folders.Count;
int count = 0;
int i = 0;
foreach (InventoryItemBase item in items)
{
descend.ItemData[i] = new InventoryDescendentsPacket.ItemDataBlock();
descend.ItemData[i].ItemID = item.ID;
descend.ItemData[i].AssetID = item.AssetID;
descend.ItemData[i].CreatorID = item.CreatorIdAsUuid;
descend.ItemData[i].BaseMask = item.BasePermissions;
descend.ItemData[i].Description = StringToPacketBytes(item.Description);
descend.ItemData[i].EveryoneMask = item.EveryOnePermissions;
descend.ItemData[i].OwnerMask = item.CurrentPermissions;
descend.ItemData[i].FolderID = item.Folder;
descend.ItemData[i].InvType = (sbyte)item.InvType;
descend.ItemData[i].Name = StringToPacketBytes(item.Name);
descend.ItemData[i].NextOwnerMask = item.NextPermissions;
descend.ItemData[i].OwnerID = item.Owner;
descend.ItemData[i].Type = (sbyte)item.AssetType;
descend.ItemData[i].GroupID = item.GroupID;
descend.ItemData[i].GroupOwned = item.GroupOwned;
descend.ItemData[i].GroupMask = item.GroupPermissions;
descend.ItemData[i].CreationDate = item.CreationDate;
descend.ItemData[i].SalePrice = item.SalePrice;
descend.ItemData[i].SaleType = item.SaleType;
descend.ItemData[i].Flags = item.Flags;
//.........这里部分代码省略.........
示例7: GetFolderItems
/// <summary>
/// Gets the items inside a folder
/// </summary>
/// <param name="userID"></param>
/// <param name="folderID"></param>
/// <returns></returns>
public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
{
InventoryCollection inventory = new InventoryCollection();
inventory.UserID = userID;
NameValueCollection requestArgs = new NameValueCollection
{
{ "RequestMethod", "GetInventoryNode" },
{ "ItemID", folderID.ToString() },
{ "OwnerID", userID.ToString() },
{ "IncludeFolders", "0" },
{ "IncludeItems", "1" },
{ "ChildrenOnly", "1" }
};
OSDMap response = WebUtils.PostToService(m_serverUrl, requestArgs);
if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
{
OSDArray items = (OSDArray)response["Items"];
return GetItemsFromResponse(items);
}
else
{
m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Error fetching folder " + folderID + " for " + userID + ": " +
response["Message"].AsString());
return new List<InventoryItemBase>(0);
}
}
示例8: TryCreateInventory
public BackendResponse TryCreateInventory(Uri owner, InventoryFolderWithChildren rootFolder)
{
BackendResponse ret;
lock (inventories)
{
if (!inventories.ContainsKey(owner))
{
InventoryCollection collection = new InventoryCollection();
collection.UserID = rootFolder.Owner;
collection.Folders = new Dictionary<UUID, InventoryFolderWithChildren>();
collection.Folders.Add(rootFolder.ID, rootFolder);
collection.Items = new Dictionary<UUID, InventoryItemBase>();
inventories.Add(owner, collection);
ret = BackendResponse.Success;
}
else
{
ret = BackendResponse.Failure;
}
}
if (ret == BackendResponse.Success)
{
string path = Path.Combine(DEFAULT_INVENTORY_DIR, rootFolder.Owner.ToString());
try
{
// Create the directory for this agent
Directory.CreateDirectory(path);
// Create an index.txt containing the UUID and URI for this agent
string[] index = new string[] { rootFolder.Owner.ToString(), owner.ToString() };
File.WriteAllLines(Path.Combine(path, "index.txt"), index);
// Create the root folder file
SaveFolder(rootFolder);
}
catch (Exception ex)
{
m_log.Error("[SIMPLEINVENTORYSTORAGE]: " + ex.Message);
ret = BackendResponse.Failure;
}
}
server.MetricsProvider.LogInventoryCreateInventory(EXTENSION_NAME, ret, DateTime.Now);
return ret;
}
示例9: TryFetchFolderContents
public BackendResponse TryFetchFolderContents(Uri owner, UUID folderID, out InventoryCollection contents)
{
contents = null;
BackendResponse ret;
InventoryCollection collection;
InventoryFolderWithChildren folder;
if (inventories.TryGetValue(owner, out collection) && collection.Folders.TryGetValue(folderID, out folder))
{
contents = new InventoryCollection();
contents.UserID = collection.UserID;
contents.Folders = new Dictionary<UUID, InventoryFolderWithChildren>();
contents.Items = new Dictionary<UUID, InventoryItemBase>();
foreach (InventoryNodeBase invBase in folder.Children.Values)
{
if (invBase is InventoryItemBase)
{
InventoryItemBase invItem = invBase as InventoryItemBase;
contents.Items.Add(invItem.ID, invItem);
}
else
{
InventoryFolderWithChildren invFolder = invBase as InventoryFolderWithChildren;
contents.Folders.Add(invFolder.ID, invFolder);
}
}
ret = BackendResponse.Success;
}
else
{
ret = BackendResponse.NotFound;
}
server.MetricsProvider.LogInventoryFetchFolderContents(EXTENSION_NAME, ret, owner, folderID, DateTime.Now);
return ret;
}
示例10: GetMultipleFoldersContent
public virtual InventoryCollection[] GetMultipleFoldersContent(UUID principalID, UUID[] folderIDs)
{
InventoryCollection[] invColl = new InventoryCollection[folderIDs.Length];
int i = 0;
foreach (UUID fid in folderIDs)
{
invColl[i++] = GetFolderContent(principalID, fid);
}
return invColl;
}
示例11: GetFolderContent
public InventoryCollection GetFolderContent(UUID principalID, UUID folderID)
{
Dictionary<string,object> ret = MakeRequest("GETFOLDERCONTENT",
new Dictionary<string,object> {
{ "PRINCIPAL", principalID.ToString() },
{ "FOLDER", folderID.ToString() }
});
if (ret == null)
return null;
if (ret.Count == 0)
return null;
InventoryCollection inventory = new InventoryCollection();
inventory.Folders = new List<InventoryFolderBase>();
inventory.Items = new List<InventoryItemBase>();
inventory.UserID = principalID;
Dictionary<string,object> folders =
(Dictionary<string,object>)ret["FOLDERS"];
Dictionary<string,object> items =
(Dictionary<string,object>)ret["ITEMS"];
foreach (Object o in folders.Values)
inventory.Folders.Add(BuildFolder((Dictionary<string,object>)o));
foreach (Object o in items.Values)
inventory.Items.Add(BuildItem((Dictionary<string,object>)o));
return inventory;
}
示例12: GetUserInventory
public InventoryCollection GetUserInventory(UUID userID)
{
m_log.Error("[SIMIAN INVENTORY CONNECTOR]: Obsolete GetUserInventory called for " + userID);
InventoryCollection inventory = new InventoryCollection();
inventory.UserID = userID;
inventory.Folders = new List<InventoryFolderBase>();
inventory.Items = new List<InventoryItemBase>();
return inventory;
}
示例13: GetMultipleItems
public virtual InventoryItemBase[] GetMultipleItems(UUID principalID, UUID[] itemIDs)
{
InventoryItemBase[] itemArr = new InventoryItemBase[itemIDs.Length];
try
{
Dictionary<string, object> resultSet = MakeRequest("GETMULTIPLEITEMS",
new Dictionary<string, object> {
{ "PRINCIPAL", principalID.ToString() },
{ "ITEMS", String.Join(",", itemIDs) },
{ "COUNT", itemIDs.Length.ToString() }
});
if (!CheckReturn(resultSet))
return null;
int i = 0;
foreach (KeyValuePair<string, object> kvp in resultSet)
{
InventoryCollection inventory = new InventoryCollection();
if (kvp.Key.StartsWith("item_"))
{
if (kvp.Value is Dictionary<string, object>)
itemArr[i++] = BuildItem((Dictionary<string, object>)kvp.Value);
else
itemArr[i++] = null;
}
}
}
catch (Exception e)
{
m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: Exception in GetMultipleItems: {0}", e.Message);
}
return itemArr;
}
示例14: WriteObject_InventoryCollection
void WriteObject_InventoryCollection(InventoryCollection ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
{
if (((object)ob) == null)
{
if (isNullable)
WriteNullTagLiteral(element, namesp);
return;
}
System.Type type = ob.GetType();
if (type == typeof(InventoryCollection))
{ }
else
{
throw CreateUnknownTypeException(ob);
}
if (writeWrappingElem)
{
WriteStartElement(element, namesp, ob);
}
if (needType) WriteXsiType("InventoryCollection", "");
if ([email protected] != null)
{
WriteStartElement("Folders", "", [email protected]);
foreach (InventoryFolderWithChildren folder in ob.Folders.Values)
{
WriteObject_InventoryFolder(folder, "InventoryFolderBase", "", true, false, true);
}
WriteEndElement([email protected]);
}
if ([email protected] != null)
{
WriteStartElement("Items", "", [email protected]);
foreach (InventoryItemBase item in ob.Items.Values)
{
WriteObject_InventoryItem(item, "InventoryItemBase", "", true, false, true);
}
WriteEndElement([email protected]);
}
WriteObject_UUID([email protected], "UserID", "", false, false, true);
if (writeWrappingElem) WriteEndElement(ob);
}
示例15: FetchDescendants
public InventoryCollection FetchDescendants(InventoryFolderBase fb)
{
m_log.Info("[HGStandaloneInvService]: Processing request for folder " + fb.ID);
// Uncomment me to simulate a slow responding inventory server
//Thread.Sleep(16000);
InventoryCollection invCollection = new InventoryCollection();
List<InventoryItemBase> items = m_inventoryService.RequestFolderItems(fb.ID);
List<InventoryFolderBase> folders = m_inventoryService.RequestSubFolders(fb.ID);
invCollection.UserID = fb.Owner;
invCollection.Folders = folders;
invCollection.Items = items;
m_log.DebugFormat("[HGStandaloneInvService]: Found {0} items and {1} folders", items.Count, folders.Count);
return invCollection;
}