├── .gitignore
├── LICENCE.txt
├── README.md
├── appveyor.yml
├── examples
└── ReactiveModel
│ ├── Esp.Net.Examples.ReactiveModel
│ ├── App.config
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── Bootstrapper.cs
│ ├── ClientApp
│ │ ├── ClientAppBootstrapper.cs
│ │ ├── Model
│ │ │ ├── Entities
│ │ │ │ ├── Model.cd
│ │ │ │ ├── OrderInputs
│ │ │ │ │ └── OrderInputs.cs
│ │ │ │ ├── OrderScreen.cs
│ │ │ │ └── Rfq
│ │ │ │ │ └── Rfq.cs
│ │ │ ├── Events
│ │ │ │ ├── AcceptQuoteEvent.cs
│ │ │ │ ├── CurrencyPairChangedEvent.cs
│ │ │ │ ├── InitialiseEvent.cs
│ │ │ │ ├── NotionalChangedEvent.cs
│ │ │ │ ├── OrderResponseReceivedEvent.cs
│ │ │ │ ├── ReferenceDataReceivedEvent.cs
│ │ │ │ ├── RejectQuoteEvent.cs
│ │ │ │ └── RequestQuoteEvent.cs
│ │ │ └── Gateways
│ │ │ │ ├── IReferenceDataGateway.cs
│ │ │ │ ├── IRequestForQuoteGateway.cs
│ │ │ │ ├── ReferenceDataGateway.cs
│ │ │ │ └── RequestForQuoteGateway.cs
│ │ ├── Services
│ │ │ ├── Entities
│ │ │ │ ├── CurrencyPair.cs
│ │ │ │ ├── QuoteStatus.cs
│ │ │ │ ├── QuoteStatusExt.cs
│ │ │ │ ├── RfqRequest.cs
│ │ │ │ └── RfqResponse.cs
│ │ │ ├── IReferenceDataServiceClient.cs
│ │ │ └── IRfqServiceClient.cs
│ │ └── UI
│ │ │ ├── RfqScreen
│ │ │ ├── ClientRfqScreenView.xaml
│ │ │ ├── ClientRfqScreenView.xaml.cs
│ │ │ └── ClientRfqScreenViewModel.cs
│ │ │ └── Shell
│ │ │ ├── ClientAppShellView.xaml
│ │ │ ├── ClientAppShellView.xaml.cs
│ │ │ └── ClientAppShellViewModel.cs
│ ├── Common
│ │ ├── FakeMiddleware.cs
│ │ ├── Model
│ │ │ └── Entities
│ │ │ │ └── Fields
│ │ │ │ ├── Field.cs
│ │ │ │ └── SelectionField.cs
│ │ ├── Services
│ │ │ └── SchedulerService.cs
│ │ └── UI
│ │ │ ├── DelegateCommand .cs
│ │ │ ├── EntryMonitor.cs
│ │ │ ├── Fields
│ │ │ ├── FieldViewModel.cs
│ │ │ └── SelectionFieldViewModel.cs
│ │ │ ├── InverseBooleanToVisibilityConverter .cs
│ │ │ ├── NotifyingBase .cs
│ │ │ └── ObservableExtensions.cs
│ ├── Esp.Net.Examples.ReactiveModel.csproj
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ ├── Resources.resx
│ │ ├── Settings.Designer.cs
│ │ └── Settings.settings
│ ├── Themes
│ │ └── MetroDark
│ │ │ ├── HowToApplyTheme.txt
│ │ │ ├── MetroDark.MSControls.Core.Implicit.xaml
│ │ │ ├── MetroDark.MSControls.Toolkit.Implicit.xaml
│ │ │ ├── Styles.Shared.xaml
│ │ │ ├── Styles.WPF.xaml
│ │ │ └── Theme.Colors.xaml
│ ├── TraderApp
│ │ ├── Model
│ │ │ ├── Entities
│ │ │ │ ├── Model.cd
│ │ │ │ ├── RfqDetails.cs
│ │ │ │ └── RfqScreen.cs
│ │ │ ├── Events
│ │ │ │ ├── ClientAcceptedQuoteEvent.cs
│ │ │ │ ├── ClientClosedQuoteEvent.cs
│ │ │ │ ├── ClientRejectQuoteEvent.cs
│ │ │ │ ├── InitialiseEvent.cs
│ │ │ │ ├── RfqRateChangedEvent.cs
│ │ │ │ ├── RfqReceivedEvent.cs
│ │ │ │ ├── TraderRejectQuoteEvent.cs
│ │ │ │ └── TraderSendQuoteEvent.cs
│ │ │ └── Gateways
│ │ │ │ ├── IRfqServiceGateway.cs
│ │ │ │ └── RfqServiceGateway.cs
│ │ ├── Services
│ │ │ ├── Entities
│ │ │ │ ├── CurrencyPair.cs
│ │ │ │ ├── QuoteStatus.cs
│ │ │ │ ├── RfqRequest.cs
│ │ │ │ └── RfqResponse.cs
│ │ │ └── IRfqService.cs
│ │ ├── TraderAppBootstrapper.cs
│ │ └── UI
│ │ │ ├── RfqScreen
│ │ │ ├── RfqDetailsView.xaml
│ │ │ ├── RfqDetailsView.xaml.cs
│ │ │ ├── RfqDetailsViewModel.cs
│ │ │ ├── TraderRfqScreenView.xaml
│ │ │ ├── TraderRfqScreenView.xaml.cs
│ │ │ └── TraderRfqScreenViewModel.cs
│ │ │ └── Shell
│ │ │ ├── TraderAppShellView.xaml
│ │ │ ├── TraderAppShellView.xaml.cs
│ │ │ └── TraderAppShellViewModel.cs
│ └── packages.config
│ ├── ReactiveModel.sln
│ ├── ReactiveModel.sln.DotSettings
│ ├── ReadMe.md
│ └── doco
│ ├── client.png
│ └── trader.png
└── src
├── AssemblyInfo.Common.cs
├── Esp.Net.Dispatchers
├── Esp.Net.Dispatchers.SourcePackage.nuspec
├── Esp.Net.Dispatchers.csproj
├── Esp.Net.Dispatchers.nuspec
├── NewThreadRouterDispatcher.cs
└── Properties
│ └── AssemblyInfo.cs
├── Esp.Net.Rx
├── Esp.Net.Rx.SourcePackage.nuspec
├── Esp.Net.Rx.csproj
├── Esp.Net.Rx.nuspec
├── Properties
│ └── AssemblyInfo.cs
├── RouterScheduler.cs
└── packages.config
├── Esp.Net.Tests
├── Dispatchers
│ └── NewThreadRouterDispatcherTests.cs
├── Disposables
│ └── EspDisposableTests.cs
├── Esp.Net.Tests.csproj
├── HeldEvents
│ └── HeldEventTests.cs
├── Properties
│ └── AssemblyInfo.cs
├── Reactive
│ ├── ReactiveTests.cs
│ ├── StubEventObservable.cs
│ └── StubEventObservationRegistrar.cs
├── RouterTests.Ctor.cs
├── RouterTests.ErrorFlow.Halting.cs
├── RouterTests.ErrorFlows.cs
├── RouterTests.EventObservationDisposal.cs
├── RouterTests.EventWorkflow.cs
├── RouterTests.ModelObservation.cs
├── RouterTests.ModelRouter.cs
├── RouterTests.ModelSubRouter.cs
├── RouterTests.ObserveEventsOn.cs
├── RouterTests.RegisterModel.cs
├── RouterTests.RemoveModel.cs
├── RouterTests.RouterDispatcher.cs
├── RouterTests.RunAction.cs
├── RouterTests.cs
├── Rx
│ └── RxSubscribeTests.cs
├── StubRouterDispatcher.cs
├── Utils
│ └── ReflectionHelperTests.cs
└── packages.config
├── Esp.Net.sln
└── Esp.Net
├── CurrentThreadDispatcher.cs
├── Disposables
├── CollectionDisposable.cs
├── DictionaryDisposable.cs
├── DisposableBase.cs
├── EspDisposable.cs
└── EspSerialDisposable.cs
├── Esp.Net.SourcePackage.nuspec
├── Esp.Net.csproj
├── Esp.Net.nuspec
├── EventContext.cs
├── HeldEvents
├── HeldEventAction.cs
├── HeldEventActionEvent.cs
├── IEventDescription.cs
├── IEventHoldingStrategy.cs
└── IHeldEventStore.cs
├── IClonable.cs
├── IEventContext.cs
├── IIdentifiableEvent.cs
├── IPostEventProcessor.cs
├── IPreEventProcessor.cs
├── IRouter.`1.cs
├── IRouter.cs
├── IRouterDispatcher.cs
├── ITerminalErrorHandler.cs
├── Meta
├── EventObservations.cs
├── IEventObservationRegistrar.cs
├── IEventsObservationRegistrar.cs
├── ModelEventObservations.cs
└── ModelsEventsObservations.cs
├── ModelChangedEvent.cs
├── ObservationStage.cs
├── ObserveEventAttribute.cs
├── Properties
└── AssemblyInfo.cs
├── Reactive
├── EventObservable.cs
├── EventObserver.cs
├── EventSubject.cs
├── ModelObservable.cs
├── ModelObserver.cs
└── ModelSubject.cs
├── Router.ModelRouter.cs
├── Router.State.cs
├── Router.Status.cs
├── Router.`1.cs
├── Router.`2.cs
├── Router.cs
├── RouterExt.HeldEvents.cs
├── RouterExt.ObserveEventsOn.cs
└── Utils
├── Guard.cs
├── ReflectionExt.cs
└── ReflectionHelper.cs
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.sln.docstates
8 |
9 | # Build results
10 | [Dd]ebug/
11 | [Dd]ebugPublic/
12 | [Rr]elease/
13 | x64/
14 | build/
15 | bld/
16 | [Bb]in/
17 | [Oo]bj/
18 |
19 | # MSTest test Results
20 | [Tt]est[Rr]esult*/
21 | [Bb]uild[Ll]og.*
22 |
23 | #NUNIT
24 | *.VisualState.xml
25 | TestResult.xml
26 |
27 | # Build Results of an ATL Project
28 | [Dd]ebugPS/
29 | [Rr]eleasePS/
30 | dlldata.c
31 |
32 | *_i.c
33 | *_p.c
34 | *_i.h
35 | *.ilk
36 | *.meta
37 | *.obj
38 | *.pch
39 | *.pdb
40 | *.pgc
41 | *.pgd
42 | *.rsp
43 | *.sbr
44 | *.tlb
45 | *.tli
46 | *.tlh
47 | *.tmp
48 | *.tmp_proj
49 | *.log
50 | *.vspscc
51 | *.vssscc
52 | .builds
53 | *.pidb
54 | *.svclog
55 | *.scc
56 |
57 | # Chutzpah Test files
58 | _Chutzpah*
59 |
60 | # Visual C++ cache files
61 | ipch/
62 | *.aps
63 | *.ncb
64 | *.opensdf
65 | *.sdf
66 | *.cachefile
67 |
68 | # Visual Studio profiler
69 | *.psess
70 | *.vsp
71 | *.vspx
72 |
73 | # TFS 2012 Local Workspace
74 | $tf/
75 |
76 | # Guidance Automation Toolkit
77 | *.gpState
78 |
79 | # ReSharper is a .NET coding add-in
80 | _ReSharper*/
81 | *.[Rr]e[Ss]harper
82 | *.DotSettings.user
83 |
84 | # JustCode is a .NET coding addin-in
85 | .JustCode
86 |
87 | # TeamCity is a build add-in
88 | _TeamCity*
89 |
90 | # DotCover is a Code Coverage Tool
91 | *.dotCover
92 |
93 | # NCrunch
94 | *.ncrunch*
95 | _NCrunch_*
96 | .*crunch*.local.xml
97 |
98 | # MightyMoose
99 | *.mm.*
100 | AutoTest.Net/
101 |
102 | # Web workbench (sass)
103 | .sass-cache/
104 |
105 | # Installshield output folder
106 | [Ee]xpress/
107 |
108 | # DocProject is a documentation generator add-in
109 | DocProject/buildhelp/
110 | DocProject/Help/*.HxT
111 | DocProject/Help/*.HxC
112 | DocProject/Help/*.hhc
113 | DocProject/Help/*.hhk
114 | DocProject/Help/*.hhp
115 | DocProject/Help/Html2
116 | DocProject/Help/html
117 |
118 | # Click-Once directory
119 | publish/
120 |
121 | # Publish Web Output
122 | *.[Pp]ublish.xml
123 | *.azurePubxml
124 |
125 | # NuGet Packages Directory
126 | packages/
127 | ## TODO: If the tool you use requires repositories.config uncomment the next line
128 | #!packages/repositories.config
129 |
130 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
131 | # This line needs to be after the ignore of the build folder (and the packages folder if the line above has been uncommented)
132 | !packages/build/
133 |
134 | # nuget exe
135 | src/.nuget
136 |
137 | # Windows Azure Build Output
138 | csx/
139 | *.build.csdef
140 |
141 | # Windows Store app package directory
142 | AppPackages/
143 |
144 | # Others
145 | sql/
146 | *.Cache
147 | ClientBin/
148 | [Ss]tyle[Cc]op.*
149 | ~$*
150 | *~
151 | *.dbmdl
152 | *.dbproj.schemaview
153 | *.pfx
154 | *.publishsettings
155 | node_modules/
156 |
157 | # RIA/Silverlight projects
158 | Generated_Code/
159 |
160 | # Backup & report files from converting an old project file to a newer
161 | # Visual Studio version. Backup files are not needed, because we have git ;-)
162 | _UpgradeReport_Files/
163 | Backup*/
164 | UpgradeLog*.XML
165 | UpgradeLog*.htm
166 |
167 | # SQL Server files
168 | *.mdf
169 | *.ldf
170 |
171 | # Business Intelligence projects
172 | *.rdl.data
173 | *.bim.layout
174 | *.bim_*.settings
175 |
176 | # Microsoft Fakes
177 | FakesAssemblies/
178 | *.orig
179 |
180 | *.nupkg
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # esp-net
2 | Please refer to the JS [documentation](https://keithwoods.gitbooks.io/esp-js/content/)
3 |
4 | [](http://nuget.org/List/Packages/esp-net) [](http://nuget.org/List/Packages/esp-net) [](https://ci.appveyor.com/project/esp/esp-net/branch/master)
5 | [](https://gitter.im/esp/chat?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
6 |
--------------------------------------------------------------------------------
/appveyor.yml:
--------------------------------------------------------------------------------
1 | environment:
2 | nuget_version: 0.6.4
3 |
4 | platform: Any CPU
5 | configuration: Release
6 |
7 | nuget:
8 | account_feed: false
9 | project_feed: true
10 | disable_publish_on_pr: false
11 |
12 | assembly_info:
13 | patch: true
14 | file: src\AssemblyInfo.Common.cs
15 | assembly_version: '$(nuget_version)'
16 | assembly_file_version: '$(nuget_version)'
17 | assembly_informational_version: '$(APPVEYOR_REPO_COMMIT)'
18 |
19 | before_build:
20 | - nuget restore .\src\Esp.Net.sln
21 |
22 | build:
23 | project: src\Esp.Net.sln
24 | verbosity: detailed
25 |
26 | after_build:
27 | - cmd: nuget pack .\src\Esp.Net\Esp.Net.nuspec -version "%nuget_version%" -prop "target=%CONFIGURATION%"
28 | - cmd: nuget pack .\src\Esp.Net\Esp.Net.nuspec -version "%nuget_version%" -prop "target=%CONFIGURATION%" -Symbols
29 | - cmd: nuget pack .\src\Esp.Net\Esp.Net.SourcePackage.nuspec -version "%nuget_version%"
30 | - cmd: nuget pack .\src\Esp.Net.Dispatchers\Esp.Net.Dispatchers.nuspec -version "%nuget_version%" -prop "target=%CONFIGURATION%"
31 | - cmd: nuget pack .\src\Esp.Net.Dispatchers\Esp.Net.Dispatchers.nuspec -version "%nuget_version%" -prop "target=%CONFIGURATION%" -Symbols
32 | - cmd: nuget pack .\src\Esp.Net.Dispatchers\Esp.Net.Dispatchers.SourcePackage.nuspec -version "%nuget_version%"
33 |
34 | artifacts:
35 | - path: '*.nupkg'
36 |
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/App.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | namespace Esp.Net.Examples.ReactiveModel
4 | {
5 | public partial class App
6 | {
7 | private readonly Bootstrapper _bootstrapper = new Bootstrapper();
8 |
9 | protected override void OnStartup(StartupEventArgs e)
10 | {
11 | base.OnStartup(e);
12 | _bootstrapper.Run();
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/Bootstrapper.cs:
--------------------------------------------------------------------------------
1 | using Esp.Net.Examples.ReactiveModel.ClientApp;
2 | using Esp.Net.Examples.ReactiveModel.TraderApp;
3 | using log4net;
4 | using log4net.Appender;
5 | using log4net.Config;
6 | using log4net.Core;
7 | using log4net.Layout;
8 |
9 | namespace Esp.Net.Examples.ReactiveModel
10 | {
11 | public class Bootstrapper
12 | {
13 | private static readonly ILog Log = LogManager.GetLogger(typeof(Bootstrapper));
14 |
15 | private ClientAppBootstrapper _clientAppBootstrapper;
16 | private TraderAppBootstrapper _traderAppBootstrapper;
17 |
18 | public void Run()
19 | {
20 | ConfigureLogging();
21 | Log.Debug("Running");
22 |
23 | _clientAppBootstrapper = new ClientAppBootstrapper();
24 | _clientAppBootstrapper.Run();
25 | _traderAppBootstrapper = new TraderAppBootstrapper();
26 | _traderAppBootstrapper.Run();
27 | }
28 |
29 | private void ConfigureLogging()
30 | {
31 | // Fun tip: if you change the startup type of a WPF project to console you'll see
32 | // both the app windows and a console displaying the log output.
33 |
34 | var appender = new ColoredConsoleAppender
35 | {
36 | Threshold = Level.All,
37 | Layout = new PatternLayout(
38 | "[%logger{1}] - %message%newline"
39 | ),
40 | };
41 | appender.AddMapping(new ColoredConsoleAppender.LevelColors
42 | {
43 | Level = Level.Debug,
44 | ForeColor = ColoredConsoleAppender.Colors.White
45 | });
46 | appender.AddMapping(new ColoredConsoleAppender.LevelColors
47 | {
48 | Level = Level.Info,
49 | ForeColor = ColoredConsoleAppender.Colors.Green
50 | });
51 | appender.AddMapping(new ColoredConsoleAppender.LevelColors
52 | {
53 | Level = Level.Warn,
54 | ForeColor = ColoredConsoleAppender.Colors.Yellow
55 | });
56 | appender.AddMapping(new ColoredConsoleAppender.LevelColors
57 | {
58 | Level = Level.Error,
59 | ForeColor = ColoredConsoleAppender.Colors.Red
60 | });
61 | appender.AddMapping(new ColoredConsoleAppender.LevelColors
62 | {
63 | Level = Level.Fatal,
64 | ForeColor = ColoredConsoleAppender.Colors.Red | ColoredConsoleAppender.Colors.HighIntensity,
65 | BackColor = ColoredConsoleAppender.Colors.Red
66 | });
67 | appender.ActivateOptions();
68 | BasicConfigurator.Configure(appender);
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/ClientApp/Model/Entities/Model.cd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | JAgAVABAAAQAMAAAAAAAQAAAlAgAAAAAAAAgAAAgAAA=
17 | ClientApp\Model\Entities\OrderScreen.cs
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 | ClientApp\Model\Entities\Rfq\Rfq.cs
43 |
44 |
45 |
46 |
47 | QEAACEAECABAQAAAFABBABAAAAgAAAAAAAAAAQkAAAQ=
48 | ClientApp\Model\Entities\Rfq\Rfq.cs
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 | AAACIACABAAAAAAAAQABAAAAAAgAIACAAAAAAAEgAAA=
61 | ClientApp\Model\Entities\OrderInputs\OrderInputs.cs
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/ClientApp/Model/Entities/OrderInputs/OrderInputs.cs:
--------------------------------------------------------------------------------
1 | using Esp.Net.Examples.ReactiveModel.ClientApp.Model.Events;
2 | using Esp.Net.Examples.ReactiveModel.ClientApp.Services.Entities;
3 | using Esp.Net.Examples.ReactiveModel.Common.Model.Entities.Fields;
4 |
5 | namespace Esp.Net.Examples.ReactiveModel.ClientApp.Model.Entities.OrderInputs
6 | {
7 | public class OrderInputs : DisposableBase
8 | {
9 | private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(OrderInputs));
10 |
11 | private readonly SelectionField _currencyPair;
12 | private readonly Field _notional;
13 | private string _orderSummary;
14 |
15 | public OrderInputs()
16 | {
17 | _currencyPair = new SelectionField();
18 | _notional = new Field();
19 | }
20 |
21 | public ISelectionField CurrencyPair
22 | {
23 | get { return _currencyPair; }
24 | }
25 |
26 | public IField Notional
27 | {
28 | get { return _notional; }
29 | }
30 |
31 | public string OrderSummary
32 | {
33 | get { return _orderSummary; }
34 | }
35 |
36 | [ObserveEvent(typeof(NotionalChangedEvent))]
37 | private void OnNotionalChangedEvent(NotionalChangedEvent e)
38 | {
39 | Log.DebugFormat("Setting notional to {0}", e.Notional);
40 | _notional.Value = e.Notional;
41 | }
42 |
43 | [ObserveEvent(typeof(CurrencyPairChangedEvent))]
44 | private void OnCurrencyPairChangedEvent(CurrencyPairChangedEvent e)
45 | {
46 | Log.DebugFormat("Setting selected currency pair to {0}", e.CurrencyPair.IsoCode);
47 | _currencyPair.Value = e.CurrencyPair;
48 | }
49 |
50 | [ObserveEvent(typeof(ReferenceDataReceivedEvent), ObservationStage.Committed)]
51 | private void OnReferenceDataReceivedEvent(OrderScreen model)
52 | {
53 | Log.DebugFormat("Applying reference data symbols");
54 | _currencyPair.Items.AddRange(model.CurrencyPairs);
55 | }
56 |
57 | public void OnPostProcessing(OrderScreen orderScreen)
58 | {
59 | var isEnabled = orderScreen.CurrencyPairs != null && orderScreen.CurrencyPairs.Count > 0 && !orderScreen.Rfq.Status.RfqInFlight();
60 | _currencyPair.IsEnabled = isEnabled;
61 | _notional.IsEnabled = isEnabled;
62 | if (_notional.HasValue && _currencyPair.HasValue)
63 | {
64 | _orderSummary = string.Format(
65 | "You BUY {0} {1} against {2}",
66 | _notional.Value,
67 | _currencyPair.Value.Base,
68 | _currencyPair.Value.Counter
69 | );
70 | }
71 | else
72 | {
73 | _orderSummary = "Please select both notional and currency pair above";
74 | }
75 | }
76 | }
77 | }
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/ClientApp/Model/Entities/OrderScreen.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Collections.ObjectModel;
3 | using System.Reactive.Disposables;
4 | using Esp.Net.Examples.ReactiveModel.ClientApp.Model.Events;
5 | using Esp.Net.Examples.ReactiveModel.ClientApp.Model.Gateways;
6 | using Esp.Net.Examples.ReactiveModel.ClientApp.Services.Entities;
7 | using log4net;
8 |
9 | namespace Esp.Net.Examples.ReactiveModel.ClientApp.Model.Entities
10 | {
11 | public class OrderScreen
12 | : DisposableBase
13 | , IPreEventProcessor
14 | , IPostEventProcessor
15 | {
16 | private static readonly ILog Log = LogManager.GetLogger(typeof(OrderScreen));
17 | private readonly IRouter _router;
18 | private readonly IReferenceDataGateway _referenceDataGateway;
19 | private readonly OrderInputs.OrderInputs _orderInputs;
20 | private readonly Rfq.Rfq _rfq;
21 | private readonly SerialDisposable _referenceDataDisposable = new SerialDisposable();
22 | private IReadOnlyCollection _currentyPairs;
23 | private int _version;
24 |
25 | public OrderScreen(
26 | IRouter router,
27 | IReferenceDataGateway referenceDataGateway,
28 | OrderInputs.OrderInputs orderInputs,
29 | Rfq.Rfq rfq)
30 | {
31 | _router = router;
32 | _referenceDataGateway = referenceDataGateway;
33 | _orderInputs = orderInputs;
34 | _rfq = rfq;
35 | AddDisposable(_referenceDataDisposable);
36 | }
37 |
38 | public int Version
39 | {
40 | get { return _version; }
41 | }
42 |
43 | public IReadOnlyCollection CurrencyPairs
44 | {
45 | get { return _currentyPairs; }
46 | }
47 |
48 | public OrderInputs.OrderInputs Inputs
49 | {
50 | get { return _orderInputs; }
51 | }
52 |
53 | public Rfq.Rfq Rfq
54 | {
55 | get { return _rfq; }
56 | }
57 |
58 | public void ObserveEvents()
59 | {
60 | _router.ObserveEventsOn(this);
61 | _router.ObserveEventsOn(_orderInputs);
62 | _router.ObserveEventsOn(_rfq);
63 | }
64 |
65 | void IPreEventProcessor.Process()
66 | {
67 | _version++;
68 | Log.DebugFormat("Model version is at {0}", _version);
69 | }
70 |
71 | void IPostEventProcessor.Process()
72 | {
73 | _rfq.OnPostProcessing();
74 | _orderInputs.OnPostProcessing(this);
75 | }
76 |
77 | [ObserveEvent(typeof(ReferenceDataReceivedEvent))]
78 | private void OnReferenceDataReceivedEvent(ReferenceDataReceivedEvent e, IEventContext context)
79 | {
80 | Log.DebugFormat("Applying reference data");
81 | _currentyPairs = new ReadOnlyCollection(e.CurrencyPairs);
82 | context.Commit();
83 | }
84 |
85 | [ObserveEvent(typeof(InitialiseEvent))]
86 | private void OnInitialiseEvent()
87 | {
88 | _referenceDataDisposable.Disposable = _referenceDataGateway.BeginGetReferenceData();
89 | }
90 | }
91 | }
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/ClientApp/Model/Events/AcceptQuoteEvent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Esp.Net.Examples.ReactiveModel.ClientApp.Model.Events
4 | {
5 | public class AcceptQuoteEvent
6 | {
7 | public AcceptQuoteEvent(Guid quoteId)
8 | {
9 | QuoteId = quoteId;
10 | }
11 |
12 | public Guid QuoteId { get; private set; }
13 | }
14 | }
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/ClientApp/Model/Events/CurrencyPairChangedEvent.cs:
--------------------------------------------------------------------------------
1 | using Esp.Net.Examples.ReactiveModel.ClientApp.Services.Entities;
2 |
3 | namespace Esp.Net.Examples.ReactiveModel.ClientApp.Model.Events
4 | {
5 | public class CurrencyPairChangedEvent
6 | {
7 | public CurrencyPairChangedEvent(CurrencyPair currencyPair)
8 | {
9 | CurrencyPair = currencyPair;
10 | }
11 |
12 | public CurrencyPair CurrencyPair { get; private set; }
13 | }
14 | }
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/ClientApp/Model/Events/InitialiseEvent.cs:
--------------------------------------------------------------------------------
1 | namespace Esp.Net.Examples.ReactiveModel.ClientApp.Model.Events
2 | {
3 | public class InitialiseEvent
4 | {
5 |
6 | }
7 | }
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/ClientApp/Model/Events/NotionalChangedEvent.cs:
--------------------------------------------------------------------------------
1 | namespace Esp.Net.Examples.ReactiveModel.ClientApp.Model.Events
2 | {
3 | public class NotionalChangedEvent
4 | {
5 | public NotionalChangedEvent(decimal? notional)
6 | {
7 | Notional = notional;
8 | }
9 |
10 | public decimal? Notional { get; private set; }
11 | }
12 | }
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/ClientApp/Model/Events/OrderResponseReceivedEvent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Esp.Net.Examples.ReactiveModel.ClientApp.Services.Entities;
3 |
4 | namespace Esp.Net.Examples.ReactiveModel.ClientApp.Model.Events
5 | {
6 | public class OrderResponseReceivedEvent
7 | {
8 | public OrderResponseReceivedEvent(Guid quoteId, CurrencyPair currencyPair, decimal notional, decimal? rate, bool isLastMessage, QuoteStatus status)
9 | {
10 | QuoteId = quoteId;
11 | CurrencyPair = currencyPair;
12 | Notional = notional;
13 | Rate = rate;
14 | IsLastMessage = isLastMessage;
15 | Status = status;
16 | }
17 |
18 | public OrderResponseReceivedEvent(Exception exception)
19 | {
20 | Exception = exception;
21 | HasException = true;
22 | }
23 |
24 | public bool HasException { get; private set; }
25 | public Exception Exception { get; private set; }
26 | public Guid QuoteId { get; private set; }
27 | public CurrencyPair CurrencyPair { get; private set; }
28 | public decimal Notional { get; private set; }
29 | public decimal? Rate { get; private set; }
30 | public QuoteStatus Status { get; private set; }
31 | public bool IsLastMessage { get; private set; }
32 | }
33 | }
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/ClientApp/Model/Events/ReferenceDataReceivedEvent.cs:
--------------------------------------------------------------------------------
1 | using Esp.Net.Examples.ReactiveModel.ClientApp.Services.Entities;
2 |
3 | namespace Esp.Net.Examples.ReactiveModel.ClientApp.Model.Events
4 | {
5 | public class ReferenceDataReceivedEvent
6 | {
7 | public ReferenceDataReceivedEvent(CurrencyPair[] currencyPairs)
8 | {
9 | CurrencyPairs = currencyPairs;
10 | }
11 |
12 | public CurrencyPair[] CurrencyPairs { get; private set; }
13 | }
14 | }
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/ClientApp/Model/Events/RejectQuoteEvent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Esp.Net.Examples.ReactiveModel.ClientApp.Model.Events
4 | {
5 | public class RejectQuoteEvent
6 | {
7 | public RejectQuoteEvent(Guid quoteId)
8 | {
9 | QuoteId = quoteId;
10 | }
11 |
12 | public Guid QuoteId { get; private set; }
13 | }
14 | }
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/ClientApp/Model/Events/RequestQuoteEvent.cs:
--------------------------------------------------------------------------------
1 | namespace Esp.Net.Examples.ReactiveModel.ClientApp.Model.Events
2 | {
3 | public class RequestQuoteEvent
4 | {
5 | }
6 | }
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/ClientApp/Model/Gateways/IReferenceDataGateway.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Esp.Net.Examples.ReactiveModel.ClientApp.Model.Gateways
4 | {
5 | public interface IReferenceDataGateway
6 | {
7 | IDisposable BeginGetReferenceData();
8 | }
9 | }
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/ClientApp/Model/Gateways/IRequestForQuoteGateway.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Esp.Net.Examples.ReactiveModel.ClientApp.Services.Entities;
3 |
4 | namespace Esp.Net.Examples.ReactiveModel.ClientApp.Model.Gateways
5 | {
6 | public interface IRequestForQuoteGateway
7 | {
8 | IDisposable BegingGetQuote(Guid quoteId, CurrencyPair currencyPair, decimal notional);
9 | IDisposable BegingAcceptQuote(Guid quoteId);
10 | IDisposable BegingRejectQuote(Guid quoteId);
11 | }
12 | }
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/ClientApp/Model/Gateways/ReferenceDataGateway.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using Esp.Net.Examples.ReactiveModel.ClientApp.Model.Entities;
4 | using Esp.Net.Examples.ReactiveModel.ClientApp.Model.Events;
5 | using Esp.Net.Examples.ReactiveModel.ClientApp.Services;
6 | using Esp.Net.Examples.ReactiveModel.ClientApp.Services.Entities;
7 |
8 | namespace Esp.Net.Examples.ReactiveModel.ClientApp.Model.Gateways
9 | {
10 | public class ReferenceDataGateway : IReferenceDataGateway
11 | {
12 | private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(ReferenceDataGateway));
13 |
14 | private readonly IRouter _router;
15 | private readonly IReferenceDataServiceClient _referenceDataServiceClient;
16 |
17 | public ReferenceDataGateway(IRouter router, IReferenceDataServiceClient referenceDataServiceClient)
18 | {
19 | _router = router;
20 | _referenceDataServiceClient = referenceDataServiceClient;
21 | }
22 |
23 | public IDisposable BeginGetReferenceData()
24 | {
25 | Log.Debug("Getting reference Data");
26 | return _referenceDataServiceClient.GetCurrencyPairs().Subscribe(currencyPairsDtos =>
27 | {
28 | Log.Debug("Reference Data received");
29 | CurrencyPair[] currencyPairs = currencyPairsDtos.Select(p => new CurrencyPair(p.IsoCode, p.Precision)).ToArray();
30 | _router.PublishEvent(new ReferenceDataReceivedEvent(currencyPairs));
31 | },
32 | ex =>
33 | {
34 | // TODO
35 | });
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/ClientApp/Model/Gateways/RequestForQuoteGateway.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Esp.Net.Examples.ReactiveModel.ClientApp.Model.Entities;
3 | using Esp.Net.Examples.ReactiveModel.ClientApp.Model.Events;
4 | using Esp.Net.Examples.ReactiveModel.ClientApp.Services;
5 | using Esp.Net.Examples.ReactiveModel.ClientApp.Services.Entities;
6 |
7 | namespace Esp.Net.Examples.ReactiveModel.ClientApp.Model.Gateways
8 | {
9 | public class RequestForQuoteGateway : IRequestForQuoteGateway
10 | {
11 | private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(RequestForQuoteGateway));
12 |
13 | private readonly IRfqServiceClient _rfqServiceClient;
14 | private readonly IRouter _router;
15 |
16 | public RequestForQuoteGateway(IRfqServiceClient rfqServiceClient, IRouter router)
17 | {
18 | _rfqServiceClient = rfqServiceClient;
19 | _router = router;
20 | }
21 |
22 | public IDisposable BegingGetQuote(Guid quoteId, CurrencyPair currencyPair, decimal notional)
23 | {
24 | Log.DebugFormat("Getting quote. Id {0}, {1}, {2}", quoteId, currencyPair.IsoCode, notional);
25 | return _rfqServiceClient.RequestQuote(new RfqRequest(quoteId, currencyPair, notional)).Subscribe(
26 | response =>
27 | {
28 | Log.DebugFormat("Quote response received. Id {0}, {1}, {2}", quoteId, currencyPair.IsoCode, notional);
29 | _router.PublishEvent(
30 | new OrderResponseReceivedEvent(
31 | response.QuoteId,
32 | new CurrencyPair(response.CurrencyPair.IsoCode, response.CurrencyPair.Precision),
33 | response.Notional,
34 | response.Rate,
35 | response.IsLastMessage,
36 | response.QuoteStatus
37 | )
38 | );
39 | },
40 | ex =>
41 | {
42 | Log.ErrorFormat("Quote error. Id {0}, {1}, {2}", quoteId, currencyPair.IsoCode, notional);
43 | _router.PublishEvent(new OrderResponseReceivedEvent(ex));
44 | },
45 | () =>
46 | {
47 | // publish other event for unexpected completed cases if required
48 | }
49 | );
50 | }
51 |
52 | public IDisposable BegingAcceptQuote(Guid quoteId)
53 | {
54 | Log.DebugFormat("Accepting quote with id {0}", quoteId);
55 | return _rfqServiceClient.AcceptQuote(quoteId).Subscribe(
56 | ack =>
57 | {
58 | Log.DebugFormat("Quote {0} accept ack received", quoteId);
59 | },
60 | ex =>
61 | {
62 | // TODO
63 | }
64 | );
65 | }
66 |
67 | public IDisposable BegingRejectQuote(Guid quoteId)
68 | {
69 | Log.DebugFormat("Rejecting quote with id {0}", quoteId);
70 | return _rfqServiceClient.RejectQuote(quoteId).Subscribe(
71 | ack =>
72 | {
73 | Log.DebugFormat("Quote {0} reject ack received", quoteId);
74 | },
75 | ex =>
76 | {
77 | // TODO
78 | }
79 | );
80 | }
81 | }
82 | }
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/ClientApp/Services/Entities/CurrencyPair.cs:
--------------------------------------------------------------------------------
1 | namespace Esp.Net.Examples.ReactiveModel.ClientApp.Services.Entities
2 | {
3 | public class CurrencyPair
4 | {
5 | public CurrencyPair(string isoCode, int precision)
6 | {
7 | IsoCode = isoCode;
8 | Precision = precision;
9 |
10 | Base = IsoCode.Substring(0, 3);
11 | Counter = IsoCode.Substring(3, 3);
12 | }
13 |
14 | public string IsoCode { get; private set; }
15 |
16 | public int Precision { get; private set; }
17 |
18 | public string Base { get; private set; }
19 |
20 | public string Counter { get; private set; }
21 | }
22 | }
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/ClientApp/Services/Entities/QuoteStatus.cs:
--------------------------------------------------------------------------------
1 | namespace Esp.Net.Examples.ReactiveModel.ClientApp.Services.Entities
2 | {
3 | public enum QuoteStatus
4 | {
5 | New,
6 | Requesting,
7 | Quoting,
8 | Booking,
9 | Rejecting,
10 | ClientRejected,
11 | TraderRejected,
12 | Booked
13 | }
14 | }
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/ClientApp/Services/Entities/QuoteStatusExt.cs:
--------------------------------------------------------------------------------
1 | namespace Esp.Net.Examples.ReactiveModel.ClientApp.Services.Entities
2 | {
3 | public static class QuoteStatusExt
4 | {
5 | public static bool IsEndState(this QuoteStatus status)
6 | {
7 | var isEndState = status == QuoteStatus.ClientRejected || status == QuoteStatus.TraderRejected || status == QuoteStatus.Booked;
8 | return isEndState;
9 | }
10 |
11 | public static bool RfqInFlight(this QuoteStatus status)
12 | {
13 | var rfqInFlight = status == QuoteStatus.Quoting || status == QuoteStatus.Requesting || status == QuoteStatus.Booking || status == QuoteStatus.Rejecting;
14 | return rfqInFlight;
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/ClientApp/Services/Entities/RfqRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Esp.Net.Examples.ReactiveModel.ClientApp.Services.Entities
4 | {
5 | public class RfqRequest
6 | {
7 | public RfqRequest(Guid quoteId, CurrencyPair currencyPair, decimal notional)
8 | {
9 | QuoteId = quoteId;
10 | CurrencyPair = currencyPair;
11 | Notional = notional;
12 | }
13 |
14 | public Guid QuoteId { get; private set; }
15 | public CurrencyPair CurrencyPair { get; private set; }
16 | public decimal Notional { get; private set; }
17 | }
18 | }
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/ClientApp/Services/Entities/RfqResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Esp.Net.Examples.ReactiveModel.ClientApp.Services.Entities
4 | {
5 | public class RfqResponse
6 | {
7 | public RfqResponse(Guid quoteId, CurrencyPair currencyPair, decimal notional, decimal? rate, QuoteStatus quoteStatus, bool isLastMessage = false)
8 | {
9 | QuoteId = quoteId;
10 | CurrencyPair = currencyPair;
11 | Notional = notional;
12 | Rate = rate;
13 | QuoteStatus = quoteStatus;
14 | IsLastMessage = isLastMessage;
15 | }
16 |
17 | public Guid QuoteId { get; private set; }
18 | public CurrencyPair CurrencyPair { get; private set; }
19 | public decimal Notional { get; private set; }
20 | public decimal? Rate { get; private set; }
21 | public QuoteStatus QuoteStatus { get; private set; }
22 | public bool IsLastMessage { get; private set; }
23 | }
24 | }
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/ClientApp/Services/IReferenceDataServiceClient.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Esp.Net.Examples.ReactiveModel.ClientApp.Services.Entities;
3 |
4 | namespace Esp.Net.Examples.ReactiveModel.ClientApp.Services
5 | {
6 | public interface IReferenceDataServiceClient
7 | {
8 | IObservable GetCurrencyPairs();
9 | }
10 | }
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/ClientApp/Services/IRfqServiceClient.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reactive;
3 | using Esp.Net.Examples.ReactiveModel.ClientApp.Services.Entities;
4 |
5 | namespace Esp.Net.Examples.ReactiveModel.ClientApp.Services
6 | {
7 | public interface IRfqServiceClient
8 | {
9 | IObservable RequestQuote(RfqRequest request);
10 |
11 | IObservable AcceptQuote(Guid quoteId);
12 |
13 | IObservable RejectQuote(Guid quoteId);
14 | }
15 | }
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/ClientApp/UI/RfqScreen/ClientRfqScreenView.xaml:
--------------------------------------------------------------------------------
1 |
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 |
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/ClientApp/UI/RfqScreen/ClientRfqScreenView.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Esp.Net.Examples.ReactiveModel.ClientApp.UI.RfqScreen
2 | {
3 | public partial class ClientRfqScreenView
4 | {
5 | public ClientRfqScreenView()
6 | {
7 | InitializeComponent();
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/ClientApp/UI/Shell/ClientAppShellView.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/ClientApp/UI/Shell/ClientAppShellView.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Esp.Net.Examples.ReactiveModel.ClientApp.UI.Shell
2 | {
3 | public partial class ClientAppShellView
4 | {
5 | public ClientAppShellView(ClientAppShellViewModel viewModel)
6 | {
7 | InitializeComponent();
8 | DataContext= viewModel;
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/ClientApp/UI/Shell/ClientAppShellViewModel.cs:
--------------------------------------------------------------------------------
1 | using Esp.Net.Examples.ReactiveModel.ClientApp.UI.RfqScreen;
2 |
3 | namespace Esp.Net.Examples.ReactiveModel.ClientApp.UI.Shell
4 | {
5 | public class ClientAppShellViewModel
6 | {
7 | public ClientAppShellViewModel(ClientRfqScreenViewModel clientRfqScreenViewModel)
8 | {
9 | ClientRfqScreenViewModel = clientRfqScreenViewModel;
10 | }
11 |
12 | public ClientRfqScreenViewModel ClientRfqScreenViewModel { get; private set; }
13 | }
14 | }
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/Common/Model/Entities/Fields/Field.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Esp.Net.Examples.ReactiveModel.Common.Model.Entities.Fields
4 | {
5 | public interface IField : IField
6 | {
7 | T Value { get; }
8 | }
9 |
10 | public interface IField
11 | {
12 | bool IsEnabled { get; }
13 | bool IsValid { get; }
14 | bool HasValue { get; }
15 | }
16 |
17 | public abstract class Field : IField
18 | {
19 | public bool IsEnabled { get; set; }
20 |
21 | public bool IsValid { get; set; }
22 |
23 | public abstract bool HasValue { get; }
24 | }
25 |
26 | public class Field : Field, IField
27 | {
28 | public T Value { get; set; }
29 |
30 | public override bool HasValue
31 | {
32 | get
33 | {
34 | return !EqualityComparer.Default.Equals(Value, default(T));
35 | }
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/Common/Model/Entities/Fields/SelectionField.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Collections.ObjectModel;
3 |
4 | namespace Esp.Net.Examples.ReactiveModel.Common.Model.Entities.Fields
5 | {
6 | public interface ISelectionField : IField
7 | {
8 | IReadOnlyCollection Items { get; }
9 | }
10 |
11 | public class SelectionField : Field, ISelectionField
12 | {
13 | private readonly List _items;
14 | private readonly ReadOnlyCollection _readOnlyItems;
15 |
16 | public SelectionField()
17 | {
18 | _items = new List();
19 | _readOnlyItems = new ReadOnlyCollection(_items);
20 | }
21 |
22 | public List Items
23 | {
24 | get { return _items; }
25 | }
26 |
27 | public void ResetItems(IEnumerable items)
28 | {
29 | _items.Clear();
30 | _items.AddRange(items);
31 | }
32 |
33 | IReadOnlyCollection ISelectionField.Items
34 | {
35 | get
36 | {
37 | return _readOnlyItems;
38 | }
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/Common/Services/SchedulerService.cs:
--------------------------------------------------------------------------------
1 | using System.Reactive.Concurrency;
2 |
3 | namespace Esp.Net.Examples.ReactiveModel.Common.Services
4 | {
5 | public interface ISchedulerService
6 | {
7 | IScheduler ThreadPool { get; }
8 | IScheduler Ui { get; }
9 | }
10 |
11 | public class SchedulerService : ISchedulerService
12 | {
13 | public SchedulerService()
14 | {
15 | ThreadPool = ThreadPoolScheduler.Instance;
16 | Ui = DispatcherScheduler.Instance;
17 | }
18 |
19 | public IScheduler ThreadPool { get; private set; }
20 |
21 | public IScheduler Ui { get; private set; }
22 | }
23 | }
--------------------------------------------------------------------------------
/examples/ReactiveModel/Esp.Net.Examples.ReactiveModel/Common/UI/DelegateCommand .cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Input;
3 |
4 | namespace Esp.Net.Examples.ReactiveModel.Common.UI
5 | {
6 | public class DelegateCommand : ICommand
7 | {
8 | private readonly Predicate