forked from scriptcs/scriptcs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRecipeManager.cs
More file actions
34 lines (30 loc) · 1 KB
/
RecipeManager.cs
File metadata and controls
34 lines (30 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using Scriptcs.Contracts;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition.Hosting;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Scriptcs
{
public class RecipeManager : IRecipeManager
{
private readonly CompositionContainer _container;
public RecipeManager(CompositionContainer container)
{
_container = container;
}
public IEnumerable<Contracts.IScriptcsRecipe> GetReceipes(IEnumerable<string> recipeNames)
{
List<IScriptcsRecipe> recipes = new List<IScriptcsRecipe>();
foreach (var recipeName in recipeNames)
{
var recipeExports =
_container.GetExportedValues<Lazy<IScriptcsRecipe, IScriptcsRecipeMetadata>>()
.Where(l => recipeName == l.Metadata.Name);
recipes.AddRange(recipeExports.Select(re=>re.Value));
}
return recipes;
}
}
}