Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
PackageProfile.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.Collections.ObjectModel;
6 using System.ComponentModel;
7 using System.Linq;
8 using NuGet;
9 using SiliconStudio.Core;
10 using SiliconStudio.Core.IO;
11 
12 namespace SiliconStudio.Assets
13 {
14  /// <summary>
15  /// A collection of <see cref="PackageProfile"/>.
16  /// </summary>
17  [DataContract("PackageProfileCollection")]
18  public sealed class PackageProfileCollection : KeyedCollection<PlatformType, PackageProfile>
19  {
20  /// <summary>
21  /// Initializes a new instance of the <see cref="PackageProfileCollection"/> class.
22  /// </summary>
23  public PackageProfileCollection() : base(null, -1)
24  {
25  // Set -1 to dictionary threshold in order to make sure we don't use a dictionary internaly (so that
26  // renaming PackageProfile will work)
27  }
28 
29  protected override PlatformType GetKeyForItem(PackageProfile item)
30  {
31  return item.Platform;
32  }
33 
34  /// <summary>
35  /// Finds a shared profile (a profile that is not platform specific)
36  /// </summary>
37  /// <returns>PackageProfile.</returns>
39  {
40  return this.FirstOrDefault(profile => profile.Platform == PlatformType.Shared);
41  }
42  }
43 
44  /// <summary>
45  /// Describes buld parameters used when building assets.
46  /// </summary>
47  [DataContract("PackageProfile")]
48  public sealed class PackageProfile
49  {
50  private readonly AssetFolderCollection assetFolders;
51 
52  public const string SharedName = "Shared";
53 
54  /// <summary>
55  /// Initializes a new instance of the <see cref="PackageProfile"/> class.
56  /// </summary>
57  public PackageProfile()
58  {
59  assetFolders = new AssetFolderCollection();
60  InheritProfiles = new List<string>();
61  Properties = new PropertyCollection();
62  OutputGroupDirectories = new Dictionary<string, UDirectory>();
63  ProjectReferences = new List<ProjectReference>();
64  }
65 
66  /// <summary>
67  /// Initializes a new instance of the <see cref="PackageProfile"/> class.
68  /// </summary>
69  /// <param name="name">The name.</param>
70  /// <exception cref="System.ArgumentNullException">name</exception>
71  public PackageProfile(string name) : this()
72  {
73  if (name == null) throw new ArgumentNullException("name");
74  Name = name;
75  }
76 
77  /// <summary>
78  /// Initializes a new instance of the <see cref="PackageProfile" /> class.
79  /// </summary>
80  /// <param name="name">The name.</param>
81  /// <param name="folders">The folders.</param>
82  /// <exception cref="System.ArgumentNullException">name</exception>
83  public PackageProfile(string name, params AssetFolder[] folders)
84  : this()
85  {
86  if (name == null) throw new ArgumentNullException("name");
87  Name = name;
88  AssetFolders.AddRange(folders);
89  }
90 
91 
92  /// <summary>
93  /// Gets or sets the name of this profile.
94  /// </summary>
95  /// <value>The name.</value>
96  [DataMember(10)]
97  public string Name { get; set; }
98 
99  /// <summary>
100  /// Gets or sets the platform.
101  /// </summary>
102  /// <value>The platform.</value>
103  [DataMember(20)]
104  public PlatformType Platform { get; set; }
105 
106  /// <summary>
107  /// Gets the inherit profiles.
108  /// </summary>
109  /// <value>The inherit profiles.</value>
110  [DataMember(30)]
111  public List<string> InheritProfiles { get; private set; }
112 
113  /// <summary>
114  /// Gets the asset directories to lookup.
115  /// </summary>
116  /// <value>The asset directories.</value>
117  [DataMember(40)]
118  public AssetFolderCollection AssetFolders
119  {
120  get
121  {
122  return assetFolders;
123  }
124  }
125 
126  /// <summary>
127  /// Gets the output group directories.
128  /// </summary>
129  /// <value>The output group directories.</value>
130  [DataMember(50)]
131  public Dictionary<string, UDirectory> OutputGroupDirectories { get; private set; }
132 
133  /// <summary>
134  /// Gets the dynamic properties associated with this profile.
135  /// </summary>
136  /// <value>The properties.</value>
137  [DataMember(60)]
138  public PropertyCollection Properties { get; private set; }
139 
140  /// <summary>
141  /// Gets the assembly references to load when compiling this package.
142  /// </summary>
143  /// <value>The assembly references.</value>
144  [DataMember(70)]
145  public List<ProjectReference> ProjectReferences { get; private set; }
146 
147  /// <summary>
148  /// Creates a a default shared package profile.
149  /// </summary>
150  /// <returns>PackageProfile.</returns>
151  public static PackageProfile NewShared()
152  {
153  var sharedProfile = new PackageProfile(SharedName) { Platform = PlatformType.Shared };
154  sharedProfile.AssetFolders.Add(new AssetFolder("Assets/" + SharedName));
155  return sharedProfile;
156  }
157  }
158 }
PackageProfile(string name, params AssetFolder[] folders)
Initializes a new instance of the PackageProfile class.
PlatformType
Describes the platform operating system.
Definition: PlatformType.cs:9
A location relative to a package from where assets will be loaded
Definition: AssetFolder.cs:16
PackageProfile FindSharedProfile()
Finds a shared profile (a profile that is not platform specific)
override PlatformType GetKeyForItem(PackageProfile item)
static PackageProfile NewShared()
Creates a a default shared package profile.
PackageProfile(string name)
Initializes a new instance of the PackageProfile class.
A collection of PackageProfile.
PackageProfile()
Initializes a new instance of the PackageProfile class.
Platform specific queries and functions.
Definition: Platform.cs:15
Describes buld parameters used when building assets.
PackageProfileCollection()
Initializes a new instance of the PackageProfileCollection class.