blob: 4913e409df27fd7febb2dc1056fe053b92fb7535 (
plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using System.Collections.Generic;
namespace Microsoft.VisualStudio.Text.Editor
{
public readonly struct InfoBarAction
{
public string Title { get; }
public Action Handler { get; }
public bool IsDefault { get; }
public InfoBarAction(string title, Action handler, bool isDefault = false)
{
Title = title;
Handler = handler;
IsDefault = isDefault;
}
public void Invoke()
=> Handler?.Invoke();
}
public sealed class InfoBarViewModel
{
public string PrimaryLabelText { get; }
public string SecondaryLabelText { get; }
public IReadOnlyList<InfoBarAction> Actions { get; }
public Action DismissedHandler { get; }
public InfoBarViewModel(
string primaryLabelText,
string secondaryLabelText,
IReadOnlyList<InfoBarAction> actions,
Action dismissedHandler = null)
{
PrimaryLabelText = primaryLabelText;
SecondaryLabelText = secondaryLabelText;
Actions = actions;
DismissedHandler = dismissedHandler;
}
public void InvokeDismissed()
=> DismissedHandler?.Invoke();
}
}
|