Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ThumbnailCommand.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 
5 using SiliconStudio.Assets.Analysis;
6 using SiliconStudio.Core.Serialization.Assets;
7 
8 namespace SiliconStudio.Assets.Compiler
9 {
10  /// <summary>
11  /// The base command to build thumbnails.
12  /// This command overrides <see cref="GetInputFiles"/> so that it automatically returns all the item asset reference files.
13  /// By doing so the thumbnail is re-generated every time one of the dependencies changes.
14  /// </summary>
15  /// <typeparam name="T">The type of the asset parameter</typeparam>
16  public abstract class ThumbnailCommand<T> : AssetCommand<T>
17  {
18  protected readonly AssetItem AssetItem;
19 
20  protected readonly PackageSession AssetsSession;
21 
22  protected ThumbnailCommand(string url, PackageSession assetsSession, AssetItem assetItem, T assetParameters)
23  : base(url, assetParameters)
24  {
25  if (assetsSession == null) throw new ArgumentNullException("assetsSession");
26  if (assetItem == null) throw new ArgumentNullException("assetItem");
27  if (url == null) throw new ArgumentNullException("url");
28 
29  AssetItem = assetItem;
30  AssetsSession = assetsSession;
31  }
32 
33  public override System.Collections.Generic.IEnumerable<ObjectUrl> GetInputFiles()
34  {
35  var dependencies = AssetsSession.DependencyManager.ComputeDependencies(AssetItem);
36  foreach (var assetReference in dependencies)
37  yield return new ObjectUrl(UrlType.Internal, assetReference.Location);
38 
39  foreach (var inputFile in base.GetInputFiles())
40  yield return inputFile;
41  }
42  }
43 }
A command processing an Asset.
Definition: AssetCommand.cs:11
An asset item part of a Package accessible through SiliconStudio.Assets.Package.Assets.
Definition: AssetItem.cs:17
A session for editing a package.
override System.Collections.Generic.IEnumerable< ObjectUrl > GetInputFiles()
Gets the list of input files (that can be deduced without running the command, only from command para...
ThumbnailCommand(string url, PackageSession assetsSession, AssetItem assetItem, T assetParameters)