123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- using System.Text;
- using OpenMetaverse;
- using OpenMetaverse.Assets;
- using OpenSim.Framework;
- using OpenSim.Region.Framework.Scenes;
- using OpenSim.Region.Framework.Scenes.Serialization;
- using OpenSim.Services.Interfaces;
- namespace OpenSim.Tests.Common
- {
- public class AssetHelpers
- {
-
-
-
-
- public static AssetBase CreateNotecardAsset()
- {
- return CreateNotecardAsset(UUID.Random());
- }
-
-
-
-
-
- public static AssetBase CreateNotecardAsset(UUID assetId)
- {
- return CreateNotecardAsset(assetId, "hello");
- }
-
-
-
-
-
-
- public static AssetBase CreateNotecardAsset(UUID assetId, string text)
- {
- return CreateAsset(assetId, AssetType.Notecard, text, UUID.Random());
- }
-
-
-
-
-
-
-
-
-
-
- public static AssetBase CreateAsset(int assetUuidTail, SceneObjectGroup sog)
- {
- return CreateAsset(new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", assetUuidTail)), sog);
- }
-
-
-
-
-
-
-
- public static AssetBase CreateAsset(UUID assetUuid, SceneObjectGroup sog)
- {
- return CreateAsset(
- assetUuid,
- AssetType.Object,
- Encoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(sog)),
- sog.OwnerID);
- }
-
-
-
-
-
-
-
-
-
-
- public static AssetBase CreateAsset(int assetUuidTail, CoalescedSceneObjects coa)
- {
- return CreateAsset(new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", assetUuidTail)), coa);
- }
-
-
-
-
-
-
-
- public static AssetBase CreateAsset(UUID assetUuid, CoalescedSceneObjects coa)
- {
- return CreateAsset(
- assetUuid,
- AssetType.Object,
- Encoding.ASCII.GetBytes(CoalescedSceneObjectsSerializer.ToXml(coa)),
- coa.CreatorId);
- }
-
-
-
-
- public static AssetBase CreateAsset(UUID assetUuid, AssetType assetType, string text, UUID creatorID)
- {
- AssetNotecard anc = new AssetNotecard();
- anc.BodyText = text;
- anc.Encode();
- return CreateAsset(assetUuid, assetType, anc.AssetData, creatorID);
- }
-
-
-
-
- public static AssetBase CreateAsset(UUID assetUuid, AssetType assetType, byte[] data, UUID creatorID)
- {
- AssetBase asset = new AssetBase(assetUuid, assetUuid.ToString(), (sbyte)assetType, creatorID.ToString());
- asset.Data = data;
- return asset;
- }
-
- public static string ReadAssetAsString(IAssetService assetService, UUID uuid)
- {
- byte[] assetData = assetService.GetData(uuid.ToString());
- return Encoding.ASCII.GetString(assetData);
- }
- }
- }
|