我有一个控制台应用程序,我想从if (!e.AcceptSocket.ReceiveAsync(e)) Receive(null, e);
文件中读取配置void Receive(object sender, SocketAsyncEventArgs e)
{
if (e.BytesTransferred > 0 && e.SocketError == SocketError.Success)
{
var data = PacMan<MessageHeader>.Unpack(e.Buffer);
if (data.Type == Message.Trade)
{
e.SetBuffer(orderBuffer, 0, orderBuffer.Length);
e.AcceptSocket.Receive(e.Buffer);
var order = PacMan<AllOrderStruct>.Unpack(e.Buffer);
switch (order.Action)
{
case Data.Action.Add: AddNewOrder(order); break;
case Data.Action.Delete: RemoveOrder(order); break;
case Data.Action.Modify: ModifyOrder(order); break;
case Data.Action.Execute: UpdateOrderOnExecution(order); break;
}
}
else
{
SetBuffer(e, data.Size);
e.AcceptSocket.Receive(e.Buffer);
var array = e.Buffer.ToArray();
Task.Run(() => AddNews(array));
}
e.SetBuffer(headerBuffer, 0, headerBuffer.Length);
if (!e.AcceptSocket.ReceiveAsync(e)) Receive(null, e);
}
else Disconnect4mServer(null);
}
。我能够读取连接字符串,但无法读取其他值。
database_number
C#代码:
appsettings.json
尽管我能够读取连接字符串。
{
"ConnectionStrings": {
"connection_string": "Some values",
"key": "testkey",
"server": "localhost"
},
"database_number": "1"
}