Change CommandPattern from console to library
Remove Random from StockSchedule
This commit is contained in:
@@ -1,14 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CommandPattern
|
|
||||||
{
|
|
||||||
public class Program
|
|
||||||
{
|
|
||||||
public static void Main(string[] args)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,17 +6,24 @@ namespace CommandPattern.StocksExample
|
|||||||
public class StockSchedule
|
public class StockSchedule
|
||||||
{
|
{
|
||||||
TimeSpan openingTime;
|
TimeSpan openingTime;
|
||||||
|
TimeSpan closingTime;
|
||||||
public StockSchedule()
|
public StockSchedule()
|
||||||
{
|
{
|
||||||
CheckForOpeningOfStockExchange();
|
CheckForOpeningOfStockExchange();
|
||||||
openingTime = new TimeSpan(9, 0, 0);
|
openingTime = new TimeSpan(9, 0, 0);
|
||||||
|
closingTime = new TimeSpan(17, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public event EventHandler StockExchangedOpened;
|
public event EventHandler StockExchangedOpened;
|
||||||
|
|
||||||
public bool IsStockOpen()
|
public bool IsStockOpen()
|
||||||
{
|
{
|
||||||
return new Random().NextDouble() > 0.5;
|
var timeOfDay = DateTime.Now.TimeOfDay;
|
||||||
|
if(timeOfDay.CompareTo(openingTime) > 0 && timeOfDay.CompareTo(closingTime) < 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnStockExchangedOpened(object state)
|
private void OnStockExchangedOpened(object state)
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "1.0.0-*",
|
"version": "1.0.0-*",
|
||||||
"buildOptions": {
|
|
||||||
"emitEntryPoint": true
|
|
||||||
},
|
|
||||||
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"Microsoft.NETCore.App": {
|
"Microsoft.NETCore.App": {
|
||||||
|
|||||||
Reference in New Issue
Block a user