Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
TemplateGeneratorParameters.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 SiliconStudio.Core.Diagnostics;
5 using SiliconStudio.Core.IO;
6 
7 namespace SiliconStudio.Assets.Templates
8 {
9  /// <summary>
10  /// Parameters used by <see cref="ITemplateGenerator.PrepareForRun"/>
11  /// </summary>
12  public sealed class TemplateGeneratorParameters
13  {
14  /// <summary>
15  /// Gets or sets the project name used to generate the template.
16  /// </summary>
17  /// <value>The name.</value>
18  public string Name { get; set; }
19 
20  /// <summary>
21  /// Gets or sets the default namespace of this project.
22  /// </summary>
23  /// <value>
24  /// The namespace.
25  /// </value>
26  public string Namespace { get; set; }
27 
28  /// <summary>
29  /// Gets or sets the output directory.
30  /// </summary>
31  /// <value>The output directory.</value>
32  public UDirectory OutputDirectory { get; set; }
33 
34  /// <summary>
35  /// The actual template description.
36  /// </summary>
37  public TemplateDescription Description { get; set; }
38 
39  /// <summary>
40  /// Gets or sets the window handle.
41  /// </summary>
42  /// <value>The window handle.</value>
43  public IntPtr WindowHandle { get; set; }
44 
45  /// <summary>
46  /// Gets or sets the logger.
47  /// </summary>
48  /// <value>The logger.</value>
49  public ILogger Logger { get; set; }
50 
51  /// <summary>
52  /// Gets or sets the current session.
53  /// </summary>
54  /// <value>The session.</value>
55  public PackageSession Session { get; set; }
56 
57  /// <summary>
58  /// Gets or sets the current package (may be null)
59  /// </summary>
60  /// <value>The package.</value>
61  public Package Package { get; set; }
62 
63  /// <summary>
64  /// Validates this instance (all fields must be setup)
65  /// </summary>
66  public void Validate()
67  {
68  if (Name == null)
69  {
70  throw new InvalidOperationException("[Name] cannot be null in TemplateGeneratorParameters");
71  }
72  if (OutputDirectory == null && Description.Scope != TemplateScope.Package)
73  {
74  throw new InvalidOperationException("[OutputDirectory] cannot be null in TemplateGeneratorParameters for a template that is not generated within a Package");
75  }
76  if (Description == null)
77  {
78  throw new InvalidOperationException("[Description] cannot be null in TemplateGeneratorParameters");
79  }
80  if (Logger == null)
81  {
82  throw new InvalidOperationException("[Logger] cannot be null in TemplateGeneratorParameters");
83  }
84 
85  if (Description.Scope == TemplateScope.Session && Session == null)
86  {
87  throw new InvalidOperationException("[Session] cannot be null in for a template expecting a PackageSession");
88  }
89  if (Description.Scope == TemplateScope.Package && Package == null)
90  {
91  throw new InvalidOperationException("[Package] cannot be null in for a template expecting a Package");
92  }
93  }
94  }
95 }
void Validate()
Validates this instance (all fields must be setup)
TemplateScope
Describes if a template is supporting a particular context
Parameters used by ITemplateGenerator.PrepareForRun
A session for editing a package.
Base implementation for ILogger.
Definition: Logger.cs:10
Description of a template generator that can be displayed in the GameStudio.
Defines a normalized directory path. See UPath for details. This class cannot be inherited.
Definition: UDirectory.cs:13
The template can be applied to an existing PackageSession.
A package managing assets.
Definition: Package.cs:28
Interface for logging.
Definition: ILogger.cs:8