Serialize() 공개 메소드

Serialize the object
public Serialize ( ) : OSDMap
리턴 OSDMap
예제 #1
0
        /// <summary>
        /// Request a copy of an asset embedded within a notecard
        /// </summary>
        /// <param name="objectID">Usually UUID.Zero for copying an asset from a notecard</param>
        /// <param name="notecardID">UUID of the notecard to request an asset from</param>
        /// <param name="folderID">Target folder for asset to go to in your inventory</param>
        /// <param name="itemID">UUID of the embedded asset</param>
        /// <param name="callback">callback to run when item is copied to inventory</param>
        public void RequestCopyItemFromNotecard(UUID objectID, UUID notecardID, UUID folderID, UUID itemID, ItemCopiedCallback callback)
        {
            _ItemCopiedCallbacks[0] = callback; //Notecards always use callback ID 0

            Uri url = Client.Network.CurrentSim.Caps.CapabilityURI("CopyInventoryFromNotecard");

            if (url != null)
            {
                CopyInventoryFromNotecardMessage message = new CopyInventoryFromNotecardMessage();
                message.CallbackID = 0;
                message.FolderID = folderID;
                message.ItemID = itemID;
                message.NotecardID = notecardID;
                message.ObjectID = objectID;

                CapsClient request = new CapsClient(url);
                request.BeginGetResponse(message.Serialize(), OSDFormat.Xml, Client.Settings.CAPS_TIMEOUT);
            }
            else
            {
                CopyInventoryFromNotecardPacket copy = new CopyInventoryFromNotecardPacket();
                copy.AgentData.AgentID = Client.Self.AgentID;
                copy.AgentData.SessionID = Client.Self.SessionID;

                copy.NotecardData.ObjectID = objectID;
                copy.NotecardData.NotecardItemID = notecardID;

                copy.InventoryData = new CopyInventoryFromNotecardPacket.InventoryDataBlock[1];
                copy.InventoryData[0] = new CopyInventoryFromNotecardPacket.InventoryDataBlock();
                copy.InventoryData[0].FolderID = folderID;
                copy.InventoryData[0].ItemID = itemID;

                Client.Network.SendPacket(copy);
            }
        }
        public void CopyInventoryFromNotecardMessage()
        {
            CopyInventoryFromNotecardMessage s = new CopyInventoryFromNotecardMessage();
            s.CallbackID = 1;
            s.FolderID = UUID.Random();
            s.ItemID = UUID.Random();
            s.NotecardID = UUID.Random();
            s.ObjectID = UUID.Random();

            OSDMap map = s.Serialize();

            CopyInventoryFromNotecardMessage t = new CopyInventoryFromNotecardMessage();
            t.Deserialize(map);

            Assert.AreEqual(s.CallbackID, t.CallbackID);
            Assert.AreEqual(s.FolderID, t.FolderID);
            Assert.AreEqual(s.ItemID, t.ItemID);
            Assert.AreEqual(s.NotecardID, t.NotecardID);
            Assert.AreEqual(s.ObjectID, t.ObjectID);
        }