CachedUserInfo.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSim Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections.Generic;
  29. using System.Reflection;
  30. using System.Threading;
  31. using libsecondlife;
  32. using log4net;
  33. namespace OpenSim.Framework.Communications.Cache
  34. {
  35. internal delegate void AddItemDelegate(InventoryItemBase itemInfo);
  36. internal delegate void UpdateItemDelegate(InventoryItemBase itemInfo);
  37. internal delegate void DeleteItemDelegate(LLUUID itemID);
  38. internal delegate void CreateFolderDelegate(string folderName, LLUUID folderID, ushort folderType, LLUUID parentID);
  39. internal delegate void MoveFolderDelegate(LLUUID folderID, LLUUID parentID);
  40. internal delegate void PurgeFolderDelegate(LLUUID folderID);
  41. internal delegate void UpdateFolderDelegate(string name, LLUUID folderID, ushort type, LLUUID parentID);
  42. internal delegate void SendInventoryDescendentsDelegate(
  43. IClientAPI client, LLUUID folderID, bool fetchFolders, bool fetchItems);
  44. /// <summary>
  45. /// Stores user profile and inventory data received from backend services for a particular user.
  46. /// </summary>
  47. public class CachedUserInfo
  48. {
  49. private static readonly ILog m_log
  50. = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  51. /// <summary>
  52. /// The comms manager holds references to services (user, grid, inventory, etc.)
  53. /// </summary>
  54. private readonly CommunicationsManager m_commsManager;
  55. public UserProfileData UserProfile { get { return m_userProfile; } }
  56. private readonly UserProfileData m_userProfile;
  57. /// <summary>
  58. /// Has we received the user's inventory from the inventory service?
  59. /// </summary>
  60. private bool m_hasInventory;
  61. /// <summary>
  62. /// Inventory requests waiting for receipt of this user's inventory from the inventory service.
  63. /// </summary>
  64. private readonly IList<IInventoryRequest> m_pendingRequests = new List<IInventoryRequest>();
  65. /// <summary>
  66. /// Has this user info object yet received its inventory information from the invetnroy service?
  67. /// </summary>
  68. public bool HasInventory { get { return m_hasInventory; } }
  69. private InventoryFolderImpl m_rootFolder;
  70. public InventoryFolderImpl RootFolder { get { return m_rootFolder; } }
  71. /// <summary>
  72. /// FIXME: This could be contained within a local variable - it doesn't need to be a field
  73. /// </summary>
  74. private IDictionary<LLUUID, IList<InventoryFolderImpl>> pendingCategorizationFolders
  75. = new Dictionary<LLUUID, IList<InventoryFolderImpl>>();
  76. /// <summary>
  77. /// Constructor
  78. /// </summary>
  79. /// <param name="commsManager"></param>
  80. /// <param name="userProfile"></param>
  81. public CachedUserInfo(CommunicationsManager commsManager, UserProfileData userProfile)
  82. {
  83. m_commsManager = commsManager;
  84. m_userProfile = userProfile;
  85. }
  86. /// <summary>
  87. /// This allows a request to be added to be processed once we receive a user's inventory
  88. /// from the inventory service. If we already have the inventory, the request
  89. /// is executed immediately instead.
  90. /// </summary>
  91. /// <param name="parent"></param>
  92. public void AddRequest(IInventoryRequest request)
  93. {
  94. lock (m_pendingRequests)
  95. {
  96. if (m_hasInventory)
  97. {
  98. request.Execute();
  99. }
  100. else
  101. {
  102. m_pendingRequests.Add(request);
  103. }
  104. }
  105. }
  106. /// <summary>
  107. /// Store a folder pending arrival of its parent
  108. /// </summary>
  109. /// <param name="folder"></param>
  110. private void AddPendingFolder(InventoryFolderImpl folder)
  111. {
  112. LLUUID parentFolderId = folder.ParentID;
  113. if (pendingCategorizationFolders.ContainsKey(parentFolderId))
  114. {
  115. pendingCategorizationFolders[parentFolderId].Add(folder);
  116. }
  117. else
  118. {
  119. IList<InventoryFolderImpl> folders = new List<InventoryFolderImpl>();
  120. folders.Add(folder);
  121. pendingCategorizationFolders[parentFolderId] = folders;
  122. }
  123. }
  124. /// <summary>
  125. /// Add any pending folders which were received before the given folder
  126. /// </summary>
  127. /// <param name="parentId">
  128. /// A <see cref="LLUUID"/>
  129. /// </param>
  130. private void ResolvePendingFolders(InventoryFolderImpl newFolder)
  131. {
  132. if (pendingCategorizationFolders.ContainsKey(newFolder.ID))
  133. {
  134. foreach (InventoryFolderImpl folder in pendingCategorizationFolders[newFolder.ID])
  135. {
  136. // m_log.DebugFormat(
  137. // "[INVENTORY CACHE]: Resolving pending received folder {0} {1} into {2} {3}",
  138. // folder.name, folder.folderID, parent.name, parent.folderID);
  139. lock (newFolder.SubFolders)
  140. {
  141. if (!newFolder.SubFolders.ContainsKey(folder.ID))
  142. {
  143. newFolder.SubFolders.Add(folder.ID, folder);
  144. }
  145. }
  146. }
  147. }
  148. }
  149. /// <summary>
  150. /// Callback invoked when the inventory is received from an async request to the inventory service
  151. /// </summary>
  152. /// <param name="userID"></param>
  153. /// <param name="inventoryCollection"></param>
  154. public void InventoryReceive(ICollection<InventoryFolderImpl> folders, ICollection<InventoryItemBase> items)
  155. {
  156. // FIXME: Exceptions thrown upwards never appear on the console. Could fix further up if these
  157. // are simply being swallowed
  158. try
  159. {
  160. foreach (InventoryFolderImpl folder in folders)
  161. {
  162. FolderReceive(folder);
  163. }
  164. foreach (InventoryItemBase item in items)
  165. {
  166. ItemReceive(item);
  167. }
  168. }
  169. catch (Exception e)
  170. {
  171. m_log.ErrorFormat("[INVENTORY CACHE]: Error processing inventory received from inventory service, {0}", e);
  172. }
  173. // Deal with pending requests
  174. lock (m_pendingRequests)
  175. {
  176. // We're going to change inventory status within the lock to avoid a race condition
  177. // where requests are processed after the AddRequest() method has been called.
  178. m_hasInventory = true;
  179. foreach (IInventoryRequest request in m_pendingRequests)
  180. {
  181. request.Execute();
  182. }
  183. }
  184. }
  185. /// <summary>
  186. /// Callback invoked when a folder is received from an async request to the inventory service.
  187. /// </summary>
  188. /// <param name="userID"></param>
  189. /// <param name="folderInfo"></param>
  190. private void FolderReceive(InventoryFolderImpl newFolder)
  191. {
  192. // m_log.DebugFormat(
  193. // "[INVENTORY CACHE]: Received folder {0} {1} for user {2}",
  194. // folderInfo.Name, folderInfo.ID, userID);
  195. if (RootFolder == null)
  196. {
  197. if (newFolder.ParentID == LLUUID.Zero)
  198. {
  199. m_rootFolder = newFolder;
  200. }
  201. else
  202. {
  203. AddPendingFolder(newFolder);
  204. }
  205. }
  206. else
  207. {
  208. InventoryFolderImpl parentFolder = RootFolder.FindFolder(newFolder.ParentID);
  209. if (parentFolder != null)
  210. {
  211. lock (parentFolder.SubFolders)
  212. {
  213. if (!parentFolder.SubFolders.ContainsKey(newFolder.ID))
  214. {
  215. parentFolder.SubFolders.Add(newFolder.ID, newFolder);
  216. }
  217. else
  218. {
  219. m_log.WarnFormat(
  220. "[INVENTORY CACHE]: Received folder {0} {1} from inventory service which has already been received",
  221. newFolder.Name, newFolder.ID);
  222. }
  223. }
  224. }
  225. else
  226. {
  227. AddPendingFolder(newFolder);
  228. }
  229. }
  230. ResolvePendingFolders(newFolder);
  231. }
  232. /// <summary>
  233. /// Callback invoked when an item is received from an async request to the inventory service.
  234. ///
  235. /// We're assuming here that items are always received after all the folders
  236. /// received.
  237. /// </summary>
  238. /// <param name="folderInfo"></param>
  239. private void ItemReceive(InventoryItemBase itemInfo)
  240. {
  241. // m_log.DebugFormat(
  242. // "[INVENTORY CACHE]: Received item {0} {1} for user {2}",
  243. // itemInfo.Name, itemInfo.ID, userID);
  244. InventoryFolderImpl folder = RootFolder.FindFolder(itemInfo.Folder);
  245. if (null == folder)
  246. {
  247. m_log.WarnFormat(
  248. "Received item {0} {1} but its folder {2} does not exist",
  249. itemInfo.Name, itemInfo.ID, itemInfo.Folder);
  250. return;
  251. }
  252. lock (folder.Items)
  253. {
  254. folder.Items[itemInfo.ID] = itemInfo;
  255. }
  256. }
  257. /// <summary>
  258. /// Create a folder in this agent's inventory.
  259. ///
  260. /// If the inventory service has not yet delievered the inventory
  261. /// for this user then the request will be queued.
  262. /// </summary>
  263. /// <param name="parentID"></param>
  264. /// <returns></returns>
  265. public bool CreateFolder(string folderName, LLUUID folderID, ushort folderType, LLUUID parentID)
  266. {
  267. // m_log.DebugFormat(
  268. // "[AGENT INVENTORY]: Creating inventory folder {0} {1} for {2} {3}", folderID, folderName, remoteClient.Name, remoteClient.AgentId);
  269. if (HasInventory)
  270. {
  271. InventoryFolderImpl parentFolder = RootFolder.FindFolder(parentID);
  272. if (null == parentFolder)
  273. {
  274. m_log.WarnFormat(
  275. "[AGENT INVENTORY]: Tried to create folder {0} {1} but the parent {2} does not exist",
  276. folderName, folderID, parentID);
  277. return false;
  278. }
  279. InventoryFolderImpl createdFolder = parentFolder.CreateChildFolder(folderID, folderName, folderType);
  280. if (createdFolder != null)
  281. {
  282. InventoryFolderBase createdBaseFolder = new InventoryFolderBase();
  283. createdBaseFolder.Owner = createdFolder.Owner;
  284. createdBaseFolder.ID = createdFolder.ID;
  285. createdBaseFolder.Name = createdFolder.Name;
  286. createdBaseFolder.ParentID = createdFolder.ParentID;
  287. createdBaseFolder.Type = createdFolder.Type;
  288. createdBaseFolder.Version = createdFolder.Version;
  289. m_commsManager.InventoryService.AddFolder(createdBaseFolder);
  290. return true;
  291. }
  292. else
  293. {
  294. m_log.WarnFormat(
  295. "[AGENT INVENTORY]: Tried to create folder {0} {1} but the folder already exists",
  296. folderName, folderID);
  297. return false;
  298. }
  299. }
  300. else
  301. {
  302. AddRequest(
  303. new InventoryRequest(
  304. Delegate.CreateDelegate(typeof(CreateFolderDelegate), this, "CreateFolder"),
  305. new object[] { folderName, folderID, folderType, parentID }));
  306. return true;
  307. }
  308. }
  309. /// <summary>
  310. /// Handle a client request to update the inventory folder
  311. ///
  312. /// If the inventory service has not yet delievered the inventory
  313. /// for this user then the request will be queued.
  314. ///
  315. /// FIXME: We call add new inventory folder because in the data layer, we happen to use an SQL REPLACE
  316. /// so this will work to rename an existing folder. Needless to say, to rely on this is very confusing,
  317. /// and needs to be changed.
  318. /// </summary>
  319. ///
  320. /// <param name="folderID"></param>
  321. /// <param name="type"></param>
  322. /// <param name="name"></param>
  323. /// <param name="parentID"></param>
  324. public bool UpdateFolder(string name, LLUUID folderID, ushort type, LLUUID parentID)
  325. {
  326. // m_log.DebugFormat(
  327. // "[AGENT INVENTORY]: Updating inventory folder {0} {1} for {2} {3}", folderID, name, remoteClient.Name, remoteClient.AgentId);
  328. if (HasInventory)
  329. {
  330. InventoryFolderBase baseFolder = new InventoryFolderBase();
  331. baseFolder.Owner = m_userProfile.ID;
  332. baseFolder.ID = folderID;
  333. baseFolder.Name = name;
  334. baseFolder.ParentID = parentID;
  335. baseFolder.Type = (short)type;
  336. baseFolder.Version = RootFolder.Version;
  337. m_commsManager.InventoryService.UpdateFolder(baseFolder);
  338. InventoryFolderImpl folder = RootFolder.FindFolder(folderID);
  339. if (folder != null)
  340. {
  341. folder.Name = name;
  342. folder.ParentID = parentID;
  343. }
  344. }
  345. else
  346. {
  347. AddRequest(
  348. new InventoryRequest(
  349. Delegate.CreateDelegate(typeof(UpdateFolderDelegate), this, "UpdateFolder"),
  350. new object[] { name, folderID, type, parentID }));
  351. }
  352. return true;
  353. }
  354. /// <summary>
  355. /// Handle an inventory folder move request from the client.
  356. ///
  357. /// If the inventory service has not yet delievered the inventory
  358. /// for this user then the request will be queued.
  359. /// </summary>
  360. ///
  361. /// <param name="folderID"></param>
  362. /// <param name="parentID"></param>
  363. public bool MoveFolder(LLUUID folderID, LLUUID parentID)
  364. {
  365. // m_log.DebugFormat(
  366. // "[AGENT INVENTORY]: Moving inventory folder {0} into folder {1} for {2} {3}",
  367. // parentID, remoteClient.Name, remoteClient.Name, remoteClient.AgentId);
  368. if (HasInventory)
  369. {
  370. InventoryFolderBase baseFolder = new InventoryFolderBase();
  371. baseFolder.Owner = m_userProfile.ID;
  372. baseFolder.ID = folderID;
  373. baseFolder.ParentID = parentID;
  374. m_commsManager.InventoryService.MoveFolder(baseFolder);
  375. InventoryFolderImpl folder = RootFolder.FindFolder(folderID);
  376. if (folder != null)
  377. folder.ParentID = parentID;
  378. return true;
  379. }
  380. else
  381. {
  382. AddRequest(
  383. new InventoryRequest(
  384. Delegate.CreateDelegate(typeof(MoveFolderDelegate), this, "MoveFolder"),
  385. new object[] { folderID, parentID }));
  386. return true;
  387. }
  388. }
  389. /// <summary>
  390. /// This method will delete all the items and folders in the given folder.
  391. ///
  392. /// If the inventory service has not yet delievered the inventory
  393. /// for this user then the request will be queued.
  394. /// </summary>
  395. ///
  396. /// <param name="folderID"></param>
  397. public bool PurgeFolder(LLUUID folderID)
  398. {
  399. // m_log.InfoFormat("[AGENT INVENTORY]: Purging folder {0} for {1} uuid {2}",
  400. // folderID, remoteClient.Name, remoteClient.AgentId);
  401. if (HasInventory)
  402. {
  403. InventoryFolderImpl purgedFolder = RootFolder.FindFolder(folderID);
  404. if (purgedFolder != null)
  405. {
  406. // XXX Nasty - have to create a new object to hold details we already have
  407. InventoryFolderBase purgedBaseFolder = new InventoryFolderBase();
  408. purgedBaseFolder.Owner = purgedFolder.Owner;
  409. purgedBaseFolder.ID = purgedFolder.ID;
  410. purgedBaseFolder.Name = purgedFolder.Name;
  411. purgedBaseFolder.ParentID = purgedFolder.ParentID;
  412. purgedBaseFolder.Type = purgedFolder.Type;
  413. purgedBaseFolder.Version = purgedFolder.Version;
  414. m_commsManager.InventoryService.PurgeFolder(purgedBaseFolder);
  415. purgedFolder.Purge();
  416. return true;
  417. }
  418. }
  419. else
  420. {
  421. AddRequest(
  422. new InventoryRequest(
  423. Delegate.CreateDelegate(typeof(PurgeFolderDelegate), this, "PurgeFolder"),
  424. new object[] { folderID }));
  425. return true;
  426. }
  427. return false;
  428. }
  429. /// <summary>
  430. /// Add an item to the user's inventory
  431. /// </summary>
  432. /// <param name="itemInfo"></param>
  433. public void AddItem(InventoryItemBase item)
  434. {
  435. if (HasInventory)
  436. {
  437. if (item.Folder == LLUUID.Zero)
  438. {
  439. InventoryFolderImpl f = FindFolderForType(item.AssetType);
  440. if (f != null)
  441. item.Folder = f.ID;
  442. else
  443. item.Folder = RootFolder.ID;
  444. }
  445. ItemReceive(item);
  446. m_commsManager.InventoryService.AddItem(item);
  447. }
  448. else
  449. {
  450. AddRequest(
  451. new InventoryRequest(
  452. Delegate.CreateDelegate(typeof(AddItemDelegate), this, "AddItem"),
  453. new object[] { item }));
  454. }
  455. }
  456. /// <summary>
  457. /// Update an item in the user's inventory
  458. /// </summary>
  459. /// <param name="userID"></param>
  460. /// <param name="itemInfo"></param>
  461. public void UpdateItem(InventoryItemBase item)
  462. {
  463. if (HasInventory)
  464. {
  465. m_commsManager.InventoryService.UpdateItem(item);
  466. }
  467. else
  468. {
  469. AddRequest(
  470. new InventoryRequest(
  471. Delegate.CreateDelegate(typeof(UpdateItemDelegate), this, "UpdateItem"),
  472. new object[] { item }));
  473. }
  474. }
  475. /// <summary>
  476. /// Delete an item from the user's inventory
  477. ///
  478. /// If the inventory service has not yet delievered the inventory
  479. /// for this user then the request will be queued.
  480. /// </summary>
  481. /// <param name="itemID"></param>
  482. /// <returns>
  483. /// true on a successful delete or a if the request is queued.
  484. /// Returns false on an immediate failure
  485. /// </returns>
  486. public bool DeleteItem(LLUUID itemID)
  487. {
  488. if (HasInventory)
  489. {
  490. // XXX For historical reasons (grid comms), we need to retrieve the whole item in order to delete, even though
  491. // really only the item id is required.
  492. InventoryItemBase item = RootFolder.FindItem(itemID);
  493. if (null == item)
  494. {
  495. m_log.WarnFormat("[AGENT INVENTORY]: Tried to delete item {0} which does not exist", itemID);
  496. return false;
  497. }
  498. if (RootFolder.DeleteItem(item.ID))
  499. {
  500. return m_commsManager.InventoryService.DeleteItem(item);
  501. }
  502. }
  503. else
  504. {
  505. AddRequest(
  506. new InventoryRequest(
  507. Delegate.CreateDelegate(typeof(DeleteItemDelegate), this, "DeleteItem"),
  508. new object[] { itemID }));
  509. return true;
  510. }
  511. return false;
  512. }
  513. /// <summary>
  514. /// Send details of the inventory items and/or folders in a given folder to the client.
  515. /// </summary>
  516. /// <param name="client"></param>
  517. /// <param name="folderID"></param>
  518. /// <param name="fetchFolders"></param>
  519. /// <param name="fetchItems"></param>
  520. /// <returns>true if the request was queued or successfully processed, false otherwise</returns>
  521. public bool SendInventoryDecendents(IClientAPI client, LLUUID folderID, bool fetchFolders, bool fetchItems)
  522. {
  523. if (HasInventory)
  524. {
  525. InventoryFolderImpl folder;
  526. if ((folder = RootFolder.FindFolder(folderID)) != null)
  527. {
  528. // m_log.DebugFormat(
  529. // "[AGENT INVENTORY]: Found folder {0} for client {1}",
  530. // folderID, remoteClient.AgentId);
  531. client.SendInventoryFolderDetails(
  532. client.AgentId, folderID, folder.RequestListOfItems(),
  533. folder.RequestListOfFolders(), fetchFolders, fetchItems);
  534. return true;
  535. }
  536. else
  537. {
  538. m_log.WarnFormat(
  539. "[AGENT INVENTORY]: Could not find folder {0} requested by user {1} {2}",
  540. folderID, client.Name, client.AgentId);
  541. return false;
  542. }
  543. }
  544. else
  545. {
  546. AddRequest(
  547. new InventoryRequest(
  548. Delegate.CreateDelegate(typeof(SendInventoryDescendentsDelegate), this, "SendInventoryDecendents"),
  549. new object[] { client, folderID, fetchFolders, fetchItems }));
  550. return true;
  551. }
  552. }
  553. private InventoryFolderImpl FindFolderForType(int type)
  554. {
  555. if (RootFolder == null)
  556. return null;
  557. lock (RootFolder.SubFolders)
  558. {
  559. foreach (InventoryFolderImpl f in RootFolder.SubFolders.Values)
  560. {
  561. if (f.Type == type)
  562. return f;
  563. }
  564. }
  565. return null;
  566. }
  567. }
  568. /// <summary>
  569. /// Should be implemented by callers which require a callback when the user's inventory is received
  570. /// </summary>
  571. public interface IInventoryRequest
  572. {
  573. /// <summary>
  574. /// This is the method executed once we have received the user's inventory by which the request can be fulfilled.
  575. /// </summary>
  576. void Execute();
  577. }
  578. /// <summary>
  579. /// Generic inventory request
  580. /// </summary>
  581. class InventoryRequest : IInventoryRequest
  582. {
  583. private Delegate m_delegate;
  584. private Object[] m_args;
  585. internal InventoryRequest(Delegate delegat, Object[] args)
  586. {
  587. m_delegate = delegat;
  588. m_args = args;
  589. }
  590. public void Execute()
  591. {
  592. m_delegate.DynamicInvoke(m_args);
  593. }
  594. }
  595. }