Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
AssetItemCollection.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.IO;
7 
8 using SiliconStudio.Core;
9 using SiliconStudio.Core.Diagnostics;
10 
11 namespace SiliconStudio.Assets
12 {
13  /// <summary>
14  /// A collection of <see cref="AssetItem"/> that contains only absolute location without any drive information. This class cannot be inherited.
15  /// </summary>
16  [DebuggerTypeProxy(typeof(CollectionDebugView))]
17  [DebuggerDisplay("Count = {Count}")]
18  [DataContract("AssetItems")]
19  public sealed class AssetItemCollection : List<AssetItem>
20  {
21  /// <summary>
22  /// Initializes a new instance of the <see cref="AssetItemCollection"/> class.
23  /// </summary>
25  {
26  }
27 
28  /// <summary>
29  /// Initializes a new instance of the <see cref="T:System.Collections.Generic.List`1" /> class that is empty and has the specified initial capacity.
30  /// </summary>
31  /// <param name="capacity">The number of elements that the new list can initially store.</param>
32  public AssetItemCollection(int capacity)
33  : base(capacity)
34  {
35  }
36 
37  /// <summary>
38  /// Initializes a new instance of the <see cref="AssetItemCollection"/> class.
39  /// </summary>
40  /// <param name="collection">The collection.</param>
42  : base(collection)
43  {
44  }
45 
46  /// <summary>
47  /// Converts this instance to a YAML text.
48  /// </summary>
49  /// <returns>A string representation of this instance.</returns>
50  public string ToText()
51  {
52  var stream = new MemoryStream();
53  AssetSerializer.Default.Save(stream, this);
54  stream.Position = 0;
55  return new StreamReader(stream).ReadToEnd();
56  }
57 
58  /// <summary>
59  /// Parses items from the specified text.
60  /// </summary>
61  /// <param name="text">The text.</param>
62  /// <returns>SiliconStudio.Assets.AssetItemCollection.</returns>
63  public static AssetItemCollection FromText(string text)
64  {
65  if (text == null) throw new ArgumentNullException("text");
66 
67  var stream = new MemoryStream();
68  var writer = new StreamWriter(stream);
69  writer.Write(text);
70  writer.Flush();
71  stream.Position = 0;
72 
73  return (AssetItemCollection)AssetSerializer.Default.Load(stream, null);
74  }
75  }
76 }
string ToText()
Converts this instance to a YAML text.
A collection of AssetItem that contains only absolute location without any drive information. This class cannot be inherited.
AssetItemCollection(IEnumerable< AssetItem > collection)
Initializes a new instance of the AssetItemCollection class.
AssetItemCollection(int capacity)
Initializes a new instance of the T:System.Collections.Generic.List`1 class that is empty and has the...
static AssetItemCollection FromText(string text)
Parses items from the specified text.
Use this class to provide a debug output in Visual Studio debugger.
AssetItemCollection()
Initializes a new instance of the AssetItemCollection class.