1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- using System;
- using System.Text;
- using OpenSim.Framework;
- using OpenSim.Region.Framework.Scenes;
- using OpenMetaverse;
- using OpenMetaverse.Assets;
- namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
- {
- public class InventoryItem : IInventoryItem
- {
- TaskInventoryItem m_privateItem;
- Scene m_rootScene;
-
- public InventoryItem(Scene rootScene, TaskInventoryItem internalItem)
- {
- m_rootScene = rootScene;
- m_privateItem = internalItem;
- }
-
- internal TaskInventoryItem ToTaskInventoryItem()
- {
- return m_privateItem;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- internal static InventoryItem FromInterface(IInventoryItem i)
- {
- if (typeof(InventoryItem).IsAssignableFrom(i.GetType()))
- {
- return (InventoryItem)i;
- }
- else
- {
- throw new ApplicationException("[MRM] There is no legal conversion from IInventoryItem to InventoryItem");
- }
- }
-
- public int Type { get { return m_privateItem.Type; } }
- public UUID AssetID { get { return m_privateItem.AssetID; } }
-
-
- public T RetrieveAsset<T>() where T : OpenMetaverse.Assets.Asset, new()
- {
- AssetBase a = m_rootScene.AssetService.Get(AssetID.ToString());
- T result = new T();
- if ((sbyte)result.AssetType != a.Type)
- throw new ApplicationException("[MRM] The supplied asset class does not match the found asset");
-
- result.AssetData = a.Data;
- result.Decode();
- return result;
- }
- }
- }
|