blob: 5e66358213d161ec20d6de7b1610e8e80861b5fb (
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
using System;
using System.Linq.Expressions;
using gorilla.utility;
using solidware.financials.infrastructure;
using solidware.financials.messages;
using solidware.financials.windows.ui.presenters.validation;
namespace solidware.financials.windows.ui.presenters
{
public class AddNewStockSymbolPresenter : DialogPresenter, INotification<AddNewStockSymbolPresenter>
{
public AddNewStockSymbolPresenter(UICommandBuilder builder)
{
this.builder = builder;
Notification = new Notification<AddNewStockSymbolPresenter>();
}
public ObservableCommand Add { get; set; }
public ObservableCommand Cancel { get; set; }
public virtual string Symbol { get; set; }
public virtual Action close { get; set; }
public Notification<AddNewStockSymbolPresenter> Notification { get; set; }
public void present()
{
Add = builder.build<AddCommand>(this);
Cancel = builder.build<CancelCommand>(this);
Notification.Register<Error>(x => x.Symbol, () => Symbol.is_blank(), () => "Please specify a symbol.");
}
public string this[string property]
{
get { return Notification[property]; }
}
public string this[Expression<Func<AddNewStockSymbolPresenter, object>> property]
{
get { return Notification[property]; }
}
public string Error
{
get { return Notification.Error; }
}
UICommandBuilder builder;
public class AddCommand : UICommand<AddNewStockSymbolPresenter>
{
ServiceBus bus;
public AddCommand(ServiceBus bus)
{
this.bus = bus;
}
public override void run(AddNewStockSymbolPresenter presenter)
{
bus.publish(new StartWatchingSymbol {Symbol = presenter.Symbol.ToUpperInvariant()});
presenter.close();
}
}
}
}
|