本文整理汇总了C#中AssetBase类的典型用法代码示例。如果您正苦于以下问题:C# AssetBase类的具体用法?C# AssetBase怎么用?C# AssetBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AssetBase类属于命名空间,在下文中一共展示了AssetBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckContainsReferences
private void CheckContainsReferences(AssetType assetType, bool expected)
{
AssetBase asset = new AssetBase();
asset.Type = (sbyte)assetType;
bool actual = asset.ContainsReferences;
Assert.AreEqual(expected, actual, "Expected "+assetType+".ContainsReferences to be "+expected+" but was "+actual+".");
}
示例2: StoreAsset
public bool StoreAsset(AssetBase asset)
{
try
{
if (asset.Name.Length > 64)
asset.Name = asset.Name.Substring(0, 64);
if (asset.Description.Length > 128)
asset.Description = asset.Description.Substring(0, 128);
if (ExistsAsset(asset.ID))
{
AssetBase oldAsset = GetAsset(asset.ID);
if (oldAsset == null || (oldAsset.Flags & AssetFlags.Rewritable) == AssetFlags.Rewritable)
{
MainConsole.Instance.Debug("[LocalAssetDatabase]: Asset already exists in the db, overwriting - " + asset.ID);
Delete(asset.ID, true);
InsertAsset(asset, asset.ID);
}
else
{
MainConsole.Instance.Warn("[LocalAssetDatabase]: Asset already exists in the db, fixing ID... - " + asset.ID);
InsertAsset(asset, UUID.Random());
}
}
else
{
InsertAsset(asset, asset.ID);
}
}
catch (Exception e)
{
MainConsole.Instance.ErrorFormat("[LocalAssetDatabase]: Failure creating asset {0} with name \"{1}\". Error: {2}",
asset.ID, asset.Name, e);
}
return true;
}
示例3: AddToInventory
public LLUUID AddToInventory(LLUUID folderID, AssetBase asset)
{
if (this.InventoryFolders.ContainsKey(folderID))
{
LLUUID NewItemID = LLUUID.Random();
InventoryItem Item = new InventoryItem();
Item.FolderID = folderID;
Item.OwnerID = AgentID;
Item.AssetID = asset.FullID;
Item.ItemID = NewItemID;
Item.Type = asset.Type;
Item.Name = asset.Name;
Item.Description = asset.Description;
Item.InvType = asset.InvType;
this.InventoryItems.Add(Item.ItemID, Item);
InventoryFolder Folder = InventoryFolders[Item.FolderID];
Folder.Items.Add(Item);
return (Item.ItemID);
}
else
{
return (null);
}
}
示例4: AddUpload
public void AddUpload(LLUUID transactionID, AssetBase asset)
{
AssetTransaction upload = new AssetTransaction();
lock (this.transactions)
{
upload.Asset = asset;
upload.TransactionID = transactionID;
this.transactions.Add(transactionID, upload);
}
if (upload.Asset.Data.Length > 2)
{
//is complete
upload.UploadComplete = true;
AssetUploadCompletePacket response = new AssetUploadCompletePacket();
response.AssetBlock.Type = asset.Type;
response.AssetBlock.Success = true;
response.AssetBlock.UUID = transactionID.Combine(this.ourClient.SecureSessionID);
this.ourClient.OutPacket(response);
m_assetCache.AddAsset(asset);
}
else
{
upload.UploadComplete = false;
upload.XferID = Util.GetNextXferID();
RequestXferPacket xfer = new RequestXferPacket();
xfer.XferID.ID = upload.XferID;
xfer.XferID.VFileType = upload.Asset.Type;
xfer.XferID.VFileID = transactionID.Combine(this.ourClient.SecureSessionID);
xfer.XferID.FilePath = 0;
xfer.XferID.Filename = new byte[0];
this.ourClient.OutPacket(xfer);
}
}
示例5: LoadAsset
protected static void LoadAsset(AssetBase info, string path)
{
// bool image =
// (info.Type == (sbyte)AssetType.Texture ||
// info.Type == (sbyte)AssetType.TextureTGA ||
// info.Type == (sbyte)AssetType.ImageJPEG ||
// info.Type == (sbyte)AssetType.ImageTGA);
FileInfo fInfo = new FileInfo(path);
long numBytes = fInfo.Length;
if (fInfo.Exists)
{
FileStream fStream = new FileStream(path, FileMode.Open, FileAccess.Read);
byte[] idata = new byte[numBytes];
BinaryReader br = new BinaryReader(fStream);
idata = br.ReadBytes((int)numBytes);
br.Close();
fStream.Close();
info.Data = idata;
//info.loaded=true;
}
else
{
m_log.ErrorFormat("[ASSETS]: file: [{0}] not found !", path);
}
}
示例6: SaveBitmap
public UUID SaveBitmap(Bitmap data, bool lossless, bool temporary)
{
AssetBase asset = new AssetBase(UUID.Random(), "MRMDynamicImage", AssetType.Texture,
m_scene.RegionInfo.RegionID)
{
Data = OpenJPEG.EncodeFromImage(data, lossless),
Description = "MRM Image",
Flags = (temporary) ? AssetFlags.Temporary : 0
};
asset.ID = m_scene.AssetService.Store(asset);
return asset.ID;
}
示例7: AddBasePart
/// <summary>
/// Adds the given <see cref="AssetBase"/> to the <see cref="Asset.BaseParts"/> collection of this asset.
/// </summary>
/// <remarks>If the <see cref="Asset.BaseParts"/> collection already contains the argument. this method does nothing.</remarks>
/// <param name="newBasePart">The base to add to the <see cref="Asset.BaseParts"/> collection.</param>
public void AddBasePart(AssetBase newBasePart)
{
if (newBasePart == null) throw new ArgumentNullException(nameof(newBasePart));
if (BaseParts == null)
{
BaseParts = new List<AssetBase>();
}
if (BaseParts.All(x => x.Id != newBasePart.Id))
{
BaseParts.Add(newBasePart);
}
}
示例8: CreateAsset
protected static AssetBase CreateAsset(string assetIdStr, string name, string path, sbyte type)
{
AssetBase asset = new AssetBase(new UUID(assetIdStr), name, type, LIBRARY_OWNER_ID.ToString());
if (!String.IsNullOrEmpty(path))
{
//m_log.InfoFormat("[ASSETS]: Loading: [{0}][{1}]", name, path);
LoadAsset(asset, path);
}
else
{
m_log.InfoFormat("[ASSETS]: Instantiated: [{0}]", name);
}
return asset;
}
示例9: StoreAsset
public override void StoreAsset(AssetBase asset)
{
byte[] idBytes = asset.FullID.Guid.ToByteArray();
string cdir = m_dir + Path.DirectorySeparatorChar + idBytes[0]
+ Path.DirectorySeparatorChar + idBytes[1];
if (!Directory.Exists(m_dir + Path.DirectorySeparatorChar + idBytes[0]))
Directory.CreateDirectory(m_dir + Path.DirectorySeparatorChar + idBytes[0]);
if (!Directory.Exists(cdir))
Directory.CreateDirectory(cdir);
FileStream x = new FileStream(cdir + Path.DirectorySeparatorChar + asset.FullID + ".xml", FileMode.Create);
m_xs.Serialize(x, asset);
x.Flush();
x.Close();
}
示例10: CreateAsset
protected static AssetBase CreateAsset(string assetIdStr, string name, string path, bool isImage)
{
AssetBase asset = new AssetBase(
new UUID(assetIdStr),
name
);
if (!String.IsNullOrEmpty(path))
{
//m_log.InfoFormat("[ASSETS]: Loading: [{0}][{1}]", name, path);
LoadAsset(asset, isImage, path);
}
else
{
m_log.InfoFormat("[ASSETS]: Instantiated: [{0}]", name);
}
return asset;
}
示例11: LoadAssetBase
private AssetBase LoadAssetBase(OSDMap map)
{
AssetBase asset = new AssetBase();
asset.Data = map["AssetData"].AsBinary();
asset.TypeString = map["ContentType"].AsString();
asset.CreationDate = map["CreationDate"].AsDate();
asset.CreatorID = map["CreatorID"].AsUUID();
asset.Description = map["Description"].AsString();
asset.ID = map["ID"].AsUUID();
asset.Name = map["Name"].AsString();
asset.Type = map["Type"].AsInteger();
return asset;
}
示例12: CreateMetaDataMap
private void CreateMetaDataMap(AssetBase data, OSDMap map)
{
map["ContentType"] = OSD.FromString(data.TypeString);
map["CreationDate"] = OSD.FromDate(data.CreationDate);
map["CreatorID"] = OSD.FromUUID(data.CreatorID);
map["Description"] = OSD.FromString(data.Description);
map["ID"] = OSD.FromUUID(data.ID);
map["Name"] = OSD.FromString(data.Name);
map["Type"] = OSD.FromInteger(data.Type);
}
示例13: Store
public string Store(AssetBase asset)
{
//m_log.DebugFormat("[ASSET SERVICE]: Store asset {0} {1}", asset.Name, asset.ID);
m_Database.StoreAsset(asset);
return asset.ID;
}
示例14: AssetRequestCallback
/// <summary>
/// Called back by the asset cache when it has the asset
/// </summary>
/// <param name="assetID"></param>
/// <param name="sender"></param>
/// <param name="asset"></param>
public void AssetRequestCallback(string assetID, object sender, AssetBase asset)
{
try
{
lock (this)
{
//MainConsole.Instance.DebugFormat("[ARCHIVER]: Received callback for asset {0}", id);
m_requestCallbackTimer.Stop();
if (m_requestState == RequestState.Aborted)
{
MainConsole.Instance.WarnFormat(
"[ARCHIVER]: Received information about asset {0} after archive save abortion. Ignoring.",
assetID);
return;
}
if (asset != null)
{
// MainConsole.Instance.DebugFormat("[ARCHIVER]: Writing asset {0}", id);
m_foundAssetUuids.Add(asset.ID);
m_assetsArchiver.WriteAsset(asset);
}
else
{
// MainConsole.Instance.DebugFormat("[ARCHIVER]: Recording asset {0} as not found", id);
m_notFoundAssetUuids.Add(new UUID(assetID));
}
if (m_foundAssetUuids.Count + m_notFoundAssetUuids.Count == m_repliesRequired)
{
m_requestState = RequestState.Completed;
MainConsole.Instance.InfoFormat(
"[ARCHIVER]: Successfully added {0} assets ({1} assets notified missing)",
m_foundAssetUuids.Count, m_notFoundAssetUuids.Count);
// We want to stop using the asset cache thread asap
// as we now need to do the work of producing the rest of the archive
Util.FireAndForget(PerformAssetsRequestCallback);
}
else
m_requestCallbackTimer.Start();
}
}
catch (Exception e)
{
MainConsole.Instance.ErrorFormat("[ARCHIVER]: AssetRequestCallback failed with {0}", e);
}
}
示例15: Store
public string Store(AssetBase asset)
{
//m_log.DebugFormat("[ASSET SERVICE]: Store asset {0} {1}", asset.Name, asset.ID);
m_Database.StoreAsset (asset);
IImprovedAssetCache cache = m_registry.RequestModuleInterface<IImprovedAssetCache> ();
if (cache != null && asset != null)
{
cache.Expire (asset.ID);
cache.Cache (asset);
}
return asset.ID;
}