4 using System.Collections.Generic;
5 using SiliconStudio.Assets.Analysis;
6 using SiliconStudio.Core;
7 using SiliconStudio.Core.IO;
8 using SiliconStudio.Core.Reflection;
10 namespace SiliconStudio.Assets
16 [DataContract(
"AssetItem")]
19 private UFile location;
39 if (location == null)
throw new ArgumentNullException(
"location");
40 if (asset == null)
throw new ArgumentException(
"asset");
41 this.location = location;
58 if (value == null)
throw new ArgumentNullException(
"value");
59 this.location = value;
128 return Clone(
false, newLocation, newAsset);
141 internal AssetItem Clone(
bool copyPackage,
UFile newLocation = null,
Asset newAsset = null)
146 SourceFolder = SourceFolder
153 item.Package = Package;
167 public UFile FullPath
171 var localSourceFolder = SourceFolder ?? (
Package != null ? Package.GetDefaultAssetFolder() :
UDirectory.
This );
174 var rootDirectory =
Package != null && Package.RootDirectory != null ? Package.RootDirectory : null;
177 if (localSourceFolder.IsAbsolute)
179 if (rootDirectory != null)
181 localSourceFolder = localSourceFolder.MakeRelative(rootDirectory);
185 rootDirectory = rootDirectory != null ? UPath.Combine(rootDirectory, localSourceFolder) : localSourceFolder;
188 return rootDirectory != null ? UPath.Combine(rootDirectory, locationAndExtension) : locationAndExtension;
204 if (value == null)
throw new ArgumentNullException(
"value");
217 public DateTime ModifiedTime {
get;
internal set; }
234 if (value && !isDirty)
236 ModifiedTime = DateTime.Now;
242 Package.OnAssetDirtyChanged(asset);
249 return string.Format(
"{0}{1} => {2}", string.Format(
"[{0}] ", Asset.GetType().Name), location, Id);
262 assetBase.Base = null;
268 newAsset.Id = Guid.NewGuid();
271 newAsset.Base =
new AssetBase(Location, assetBase);
286 var session = Package.Session;
287 return session.FindAsset(Asset.Base.Id);
300 if (path == null)
throw new ArgumentNullException(
"path");
304 FindAssetsFromChange(path, action, value, result);
311 var pathSucceeded = path.TryGetValue(
Asset, out oldValue);
315 if (pathSucceeded && (action !=
MemberPathAction.ValueSet || value != oldValue))
320 if (Package != null && Package.Session != null)
322 var itemsToDetect = Package.Session.DependencyManager.FindAssetsInheritingFrom(Id);
323 foreach (var item
in itemsToDetect)
325 item.FindAssetsFromChange(path, action, value, items);
330 private class AssetItemComparerById : IEqualityComparer<AssetItem>
332 public bool Equals(AssetItem x, AssetItem
y)
334 if (ReferenceEquals(x, y))
337 if (x == null || y == null)
342 if (ReferenceEquals(x.Asset, y.Asset))
350 public int GetHashCode(AssetItem obj)
352 return obj.Id.GetHashCode();
AssetReference ToReference()
Converts this item to a reference.
AssetItem(UFile location, Asset asset)
Initializes a new instance of the AssetItem class.
AssetItem FindBase()
Finds the base item referenced by this item from the current session (using the Package setup on this...
AssetBase Base
Gets or sets the base.
A registry for file extensions, IAssetImporter, IAssetFactory and aliases associated with assets...
An asset item part of a Package accessible through Package.Assets.
_In_ size_t _In_ DXGI_FORMAT _In_ size_t _In_ float size_t y
static readonly UDirectory This
A this '.' directory.
An asset item part of a Package accessible through SiliconStudio.Assets.Package.Assets.
AssetItem Clone(UFile newLocation=null, Asset newAsset=null)
Clones this instance without the attached package.
Defines a normalized directory path. See UPath for details. This class cannot be inherited.
PackageSession Session
Gets the session.
override string ToString()
Allows to get/set a property/field value on a deeply nested object instance (supporting members...
static string GetDefaultExtension(Type assetType)
Gets the default extension associated with an asset.
List< AssetItem > FindAssetsFromChange(MemberPath path, MemberPathAction action, object value)
This methods returns all assets that would be changed when trying to change this asset.
object Clone()
Clones the current value of this cloner with the specified new shadow registry (optional) ...
Identify an object that is associated with an anchor file on the disk where all the UPath members of ...
Asset CreateChildAsset()
Creates a child asset that is inheriting the values of this asset.
bool IsRootImport
Gets a value indicating whether this instance is a root import base (the original import)...
A package managing assets.
MemberPathAction
A type of action used by MemberPath.Apply
Allows to clone an asset or values stored in an asset.
Defines a normalized file path. See UPath for details. This class cannot be inherited.