Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
AssetToImportByImporter.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 using System.Collections.Generic;
5 using System.Diagnostics;
6 using System.Linq;
7 using SiliconStudio.Core.Diagnostics;
8 
9 namespace SiliconStudio.Assets
10 {
11  /// <summary>
12  /// Describes the importer that will import an <see cref="AssetToImport"/> and
13  /// the generated list of assets to import.
14  /// </summary>
15  [DebuggerDisplay("Importer: {Importer.GetType().Name} Items: [{Items.Count}]")]
17  {
18  private readonly IAssetImporter importer;
19 
20  internal AssetToImportByImporter(AssetToImport parent, IAssetImporter importer, AssetItem previousItem = null)
21  {
22  if (parent == null) throw new ArgumentNullException("parent");
23  if (importer == null) throw new ArgumentNullException("importer");
24  this.Parent = parent;
25  this.importer = importer;
26  this.Items = new List<AssetToImportMergeGroup>();
27  Enabled = true;
28  Log = new LoggerResult(string.Format("{0} Importer", importer.Name));
29  ImporterParameters = importer.GetDefaultParameters(previousItem != null);
30  ImporterParameters.Logger = Log;
31  PreviousItem = previousItem;
32  }
33 
34  /// <summary>
35  /// Gets the parent.
36  /// </summary>
37  /// <value>The parent.</value>
38  public AssetToImport Parent { get; private set; }
39 
40  /// <summary>
41  /// Gets the importer used.
42  /// </summary>
43  /// <value>The importer.</value>
44  public IAssetImporter Importer
45  {
46  get
47  {
48  return importer;
49  }
50  }
51 
52  /// <summary>
53  /// Gets the importer parameters.
54  /// </summary>
55  /// <value>The importer parameters.</value>
56  public AssetImporterParameters ImporterParameters { get; private set; }
57 
58  /// <summary>
59  /// Gets the log.
60  /// </summary>
61  /// <value>The log.</value>
62  public LoggerResult Log { get; private set; }
63 
64  /// <summary>
65  /// Gets a value indicating whether this instance has errors.
66  /// </summary>
67  /// <value><c>true</c> if this instance has errors; otherwise, <c>false</c>.</value>
68  public bool HasErrors
69  {
70  get
71  {
72  return Log.HasErrors || Items.Any(item => item.Log.HasErrors);
73  }
74  }
75 
76  /// <summary>
77  /// Gets the list of asset items generated by this importer.
78  /// </summary>
79  /// <value>The items.</value>
80  public List<AssetToImportMergeGroup> Items { get; private set; }
81 
82  /// <summary>
83  /// Gets or sets a value indicating whether this <see cref="AssetToImportByImporter"/> is enabled.
84  /// </summary>
85  /// <value><c>true</c> if enabled; otherwise, <c>false</c>.</value>
86  public bool Enabled { get; set; }
87 
88  /// <summary>
89  /// Gets or sets the previous item that is already in the session and that
90  /// we are going to re-import.
91  /// </summary>
92  /// <value>The previous item.</value>
93  internal AssetItem PreviousItem { get; private set; }
94  }
95 }
SiliconStudio.Core.Diagnostics.LoggerResult LoggerResult
A logger that stores messages locally useful for internal log scenarios.
Definition: LoggerResult.cs:14
Parameters used by IAssetImporter.Import
An asset item part of a Package accessible through SiliconStudio.Assets.Package.Assets.
Definition: AssetItem.cs:17
A raw asset being imported that will generate possibly multiple AssetItem
string Name
Gets the name of this importer.
Imports a raw asset into the asset system.
Describes the importer that will import an AssetToImport and the generated list of assets to import...
Output message to log right away.