forked from dotnet/try
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFeatureContainer.cs
More file actions
36 lines (27 loc) · 1.25 KB
/
FeatureContainer.cs
File metadata and controls
36 lines (27 loc) · 1.25 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
35
36
// 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.Try.Protocol.ClientApi
{
public abstract class FeatureContainer : IDisposable
{
private readonly CompositeDisposable _disposables = new CompositeDisposable();
private readonly Dictionary<string, object> _features =
new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
private List<(string, object)> _featureProperties;
public IReadOnlyDictionary<string, object> Features => _features;
public void Dispose() => _disposables.Dispose();
public void AddFeature(IFeature feature)
{
if (feature is IDisposable disposable)
{
_disposables.Add(disposable);
}
_features.Add(feature.Name, feature);
}
public List<(string Name, object Value)> FeatureProperties => _featureProperties ?? (_featureProperties = new List<(string, object)>());
public void AddProperty(string name, object value) => FeatureProperties.Add((name, value));
}
}