-
Notifications
You must be signed in to change notification settings - Fork 375
/
FeatureContainer.cs
34 lines (24 loc) · 1.19 KB
/
FeatureContainer.cs
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
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Collections.Generic;
using Pocket;
namespace Microsoft.DotNet.Interactive.CSharpProject;
public abstract class FeatureContainer : IDisposable
{
private readonly CompositeDisposable _disposables = new();
private readonly Dictionary<string, object> _features = new(StringComparer.OrdinalIgnoreCase);
private List<(string, object)> _featureProperties;
public IReadOnlyDictionary<string, object> Features => _features;
public void Dispose() => _disposables.Dispose();
public void AddFeature(IRunResultFeature feature)
{
if (feature is IDisposable disposable)
{
_disposables.Add(disposable);
}
_features.Add(feature.Name, feature);
}
public List<(string Name, object Value)> FeatureProperties => _featureProperties ??= new List<(string, object)>(); // TODO: (FeatureProperties) replace tuple with a class
public void AddProperty(string name, object value) => FeatureProperties.Add((name, value));
}