Class Package
A package managing assets.
[DataContract("Package")]
[AssetDescription(".sdpkg")]
[AssetFormatVersion("Assets", "3.1.0.0", "0.0.0.4")]
[AssetUpgrader("Assets", "0.0.0.4", "3.1.0.0", typeof(Package.MovePackageInsideProject))]
public sealed class Package : IFileSynchronizable, IAssetFinder
- Inheritance
-
Package
- Implements
- Extension Methods
Constructors
Package()
Initializes a new instance of the Package class.
public Package()
Fields
PackageFileExtension
The file extension used for Package.
public const string PackageFileExtension = ".sdpkg"
Field Value
Properties
AssetFolders
Gets the asset directories to lookup.
[DataMember(40, DataMemberMode.Assign)]
public AssetFolderCollection AssetFolders { get; set; }
Property Value
- AssetFolderCollection
The asset directories.
Assets
Gets the assets stored in this package.
public PackageAssetCollection Assets { get; }
Property Value
- PackageAssetCollection
The assets.
Bundles
Gets the bundles defined for this package.
[DataMember(80)]
public BundleCollection Bundles { get; }
Property Value
- BundleCollection
The bundles.
Container
public PackageContainer Container { get; }
Property Value
ExplicitFolders
Gets or sets the list of folders that are explicitly created but contains no assets.
[DataMember(70)]
public List<UDirectory> ExplicitFolders { get; }
Property Value
- List<UDirectory>
FullPath
Gets the path to the package file. May be null if the package was not loaded or saved.
public UFile FullPath { get; set; }
Property Value
- UFile
The package path.
IsDirty
Gets or sets a value indicating whether this instance has been modified since last saving.
public bool IsDirty { get; set; }
Property Value
- bool
true
if this instance is dirty; otherwise,false
.
IsImplicitProject
public bool IsImplicitProject { get; }
Property Value
IsSystem
Gets or sets a value indicating whether this package is a system package.
public bool IsSystem { get; }
Property Value
- bool
true
if this package is a system package; otherwise,false
.
LoadedAssemblies
Gets the list of assemblies loaded by this package.
public List<PackageLoadedAssembly> LoadedAssemblies { get; }
Property Value
- List<PackageLoadedAssembly>
The loaded assemblies.
Meta
Gets or sets the metadata associated with this package.
[DataMember(10)]
public PackageMeta Meta { get; set; }
Property Value
- PackageMeta
The meta.
OutputGroupDirectories
Gets the output group directories.
[DataMember(50, DataMemberMode.Assign)]
public Dictionary<string, UDirectory> OutputGroupDirectories { get; set; }
Property Value
- Dictionary<string, UDirectory>
The output group directories.
ResourceFolders
Gets the resource directories to lookup.
[DataMember(45, DataMemberMode.Assign)]
public List<UDirectory> ResourceFolders { get; set; }
Property Value
- List<UDirectory>
The resource directories.
RootAssets
Asset references that needs to be compiled even if not directly or indirectly referenced (useful for explicit code references).
[DataMember(100)]
public RootAssetCollection RootAssets { get; }
Property Value
RootDirectory
Gets the top directory of this package on the local disk.
public UDirectory RootDirectory { get; }
Property Value
- UDirectory
The top directory.
RootNamespace
public string RootNamespace { get; }
Property Value
SerializedVersion
Gets or sets the version number for this asset, used internally when migrating assets.
[DataMember(-8000, DataMemberMode.Assign)]
[DataStyle(DataStyle.Compact)]
[Display(null, null, Browsable = false)]
public Dictionary<string, PackageVersion> SerializedVersion { get; set; }
Property Value
- Dictionary<string, PackageVersion>
The version.
Session
Gets the session.
public PackageSession Session { get; }
Property Value
- PackageSession
The session.
Exceptions
- InvalidOperationException
Cannot attach a package to more than one session
State
public PackageState State { get; set; }
Property Value
TemplateFolders
Gets the template folders.
[DataMember(90)]
public List<TemplateFolder> TemplateFolders { get; }
Property Value
- List<TemplateFolder>
The template folders.
Templates
Gets the loaded templates from the TemplateFolders
public List<TemplateDescription> Templates { get; }
Property Value
- List<TemplateDescription>
The templates.
TemporaryAssets
Gets the temporary assets list loaded from disk before they are going into Assets.
public List<AssetItem> TemporaryAssets { get; }
Property Value
UserSettings
Gets the package user settings. Usually stored in a .user file alongside the package. Lazily loaded on first time.
public PackageUserSettings UserSettings { get; }
Property Value
- PackageUserSettings
The package user settings.
Methods
AddExistingProject(UFile)
Adds an existing project to this package.
public LoggerResult AddExistingProject(UFile pathToMsproj)
Parameters
pathToMsproj
UFileThe path to msproj.
Returns
- LoggerResult
LoggerResult.
AddExistingProject(UFile, LoggerResult)
Adds an existing project to this package.
public void AddExistingProject(UFile pathToMsproj, LoggerResult logger)
Parameters
pathToMsproj
UFileThe path to msproj.
logger
LoggerResultThe logger.
Clone()
Deep clone this package.
public Package Clone()
Returns
- Package
The package cloned.
FindAsset(AssetId)
Finds an asset by its identifier.
public AssetItem FindAsset(AssetId assetId)
Parameters
assetId
AssetIdThe identifier of the asset.
Returns
Remarks
Looks for the asset amongst the current package and its dependencies.
FindAsset(UFile)
Finds an asset by its location.
public AssetItem FindAsset(UFile location)
Parameters
location
UFileThe location of the asset.
Returns
Remarks
Looks for the asset amongst the current package and its dependencies.
FindAssetFromProxyObject(object)
Finds an asset from a proxy object.
public AssetItem FindAssetFromProxyObject(object proxyObject)
Parameters
proxyObject
objectThe proxy object which is represent the targeted asset.
Returns
Remarks
Looks for the asset amongst the current package and its dependencies.
FindAssetsInProject(string, out string)
public static List<(UFile FilePath, UFile Link)> FindAssetsInProject(string projectFullPath, out string nameSpace)
Parameters
Returns
GetDefaultAssetFolder()
public UDirectory GetDefaultAssetFolder()
Returns
- UDirectory
GetPackageIdFromFile(string)
Gets the package identifier from file.
public static Guid GetPackageIdFromFile(string filePath)
Parameters
filePath
stringThe file path.
Returns
- Guid
Guid.
Exceptions
- ArgumentNullException
log or filePath
ListAssetFiles(ILogger, Package, bool, bool, CancellationToken?)
public static List<PackageLoadingAssetFile> ListAssetFiles(ILogger log, Package package, bool listAssetsInMsbuild, bool listUnregisteredAssets, CancellationToken? cancelToken)
Parameters
log
ILoggerpackage
PackagelistAssetsInMsbuild
boollistUnregisteredAssets
boolcancelToken
CancellationToken?
Returns
Load(ILogger, string, PackageLoadParameters)
Loads only the package description but not assets or plugins.
public static Package Load(ILogger log, string filePath, PackageLoadParameters loadParametersArg = null)
Parameters
log
ILoggerThe log to receive error messages.
filePath
stringThe file path.
loadParametersArg
PackageLoadParametersThe load parameters argument.
Returns
- Package
A package.
Exceptions
- ArgumentNullException
log or filePath
LoadProject(ILogger, string)
public static PackageContainer LoadProject(ILogger log, string filePath)
Parameters
Returns
LoadTemporaryAssets(ILogger, List<PackageLoadingAssetFile>, CancellationToken?, bool, Func<PackageLoadingAssetFile, bool>)
Refreshes this package from the disk by loading or reloading all assets.
public void LoadTemporaryAssets(ILogger log, List<PackageLoadingAssetFile> assetFiles = null, CancellationToken? cancelToken = null, bool listAssetsInMsbuild = true, Func<PackageLoadingAssetFile, bool> filterFunc = null)
Parameters
log
ILoggerThe log.
assetFiles
List<PackageLoadingAssetFile>The asset files (loaded from ListAssetFiles(ILogger, Package, bool, bool, CancellationToken?) if null).
cancelToken
CancellationToken?The cancel token.
listAssetsInMsbuild
boolSpecifies if we need to evaluate MSBuild files for assets.
filterFunc
Func<PackageLoadingAssetFile, bool>A function that will filter assets loading
Exceptions
- InvalidOperationException
Package RootDirectory is null or Package RootDirectory [{0}] does not exist.ToFormat(RootDirectory)
SaveSingleAsset(AssetItem, ILogger)
public static bool SaveSingleAsset(AssetItem asset, ILogger log)
Parameters
Returns
SetPackagePath(UFile, bool)
Sets the package path.
public void SetPackagePath(UFile newPath, bool copyAssets = true)
Parameters
newPath
UFileThe new path.
copyAssets
boolif set to
true
assets will be copied relatively to the new location.
UpdateAssemblyReferences(ILogger, PackageLoadParameters)
Loads the assembly references that were not loaded before.
public void UpdateAssemblyReferences(ILogger log, PackageLoadParameters loadParametersArg = null)
Parameters
log
ILoggerThe log.
loadParametersArg
PackageLoadParametersThe load parameters argument.
ValidateAssets(bool, bool, ILogger)
public void ValidateAssets(bool alwaysGenerateNewAssetId, bool removeUnloadableObjects, ILogger log)
Parameters
Events
AssetDirtyChanged
Occurs when an asset dirty changed occurred.
public event DirtyFlagChangedDelegate<AssetItem> AssetDirtyChanged
Event Type
PackageDirtyChanged
Occurs when package dirty changed occurred.
public event DirtyFlagChangedDelegate<Package> PackageDirtyChanged