Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
TagSelector.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.Collections.Generic;
4 using System.Linq;
5 using SiliconStudio.Core;
6 using SiliconStudio.Core.Serialization.Assets;
7 
8 namespace SiliconStudio.Assets.Selectors
9 {
10  /// <summary>
11  /// An <see cref="AssetSelector"/> using tags stored in <see cref="Asset.Tags"/>
12  /// </summary>
13  [DataContract("TagSelector")]
14  public class TagSelector : AssetSelector
15  {
16  /// <summary>
17  /// Initializes a new instance of the <see cref="TagSelector"/> class.
18  /// </summary>
19  public TagSelector()
20  {
21  Tags = new TagCollection();
22  }
23 
24  /// <summary>
25  /// Gets the tags that will be used to select an asset.
26  /// </summary>
27  /// <value>The tags.</value>
28  public TagCollection Tags { get; private set; }
29 
30  public override IEnumerable<string> Select(PackageSession packageSession, IAssetIndexMap assetIndexMap)
31  {
32  return packageSession.Packages
33  .SelectMany(package => package.Assets) // Select all assets
34  .Where(assetItem => assetItem.Asset.Tags.Any(tag => Tags.Contains(tag))) // Matches tags
35  .Select(x => x.Location.FullPath); // Convert to string;
36  }
37  }
38 }
override IEnumerable< string > Select(PackageSession packageSession, IAssetIndexMap assetIndexMap)
Definition: TagSelector.cs:30
A session for editing a package.
An AssetSelector using tags stored in Asset.Tags
Definition: TagSelector.cs:14
TagSelector()
Initializes a new instance of the TagSelector class.
Definition: TagSelector.cs:19