remove MSG.cs, merge content from MSG.cs and ChatMessage.cs, refactor code

This commit is contained in:
Felix Hartmann (PEA3-Fe-FI)
2021-09-21 09:28:29 +02:00
parent 5d69842ec0
commit d42acbc90e
6 changed files with 29 additions and 50 deletions

View File

@@ -1,23 +1,31 @@
namespace PolyChat.Models
using System;
namespace PolyChat.Models
{
public class ChatMessage
{
public string Text;
public string Date;
public bool Foreign;
public readonly string Sender;
public readonly DateTime Timestamp = new DateTime(1970, 01, 01);
public readonly string Msg = "empty";
public readonly string Ip;
public readonly bool Foreign;
public readonly string StringTimeStamp;
public ChatMessage(string text, string date, bool foreign)
public ChatMessage(DateTime Timestamp, string Msg, bool Foreign = true, string Sender= "Unknown", string Ip = "127.0.0.1")
{
Text = text;
Date = date;
Foreign = foreign;
this.Sender = Sender;
this.Timestamp = Timestamp;
StringTimeStamp = Timestamp.ToString();
this.Msg = Msg;
this.Foreign = Foreign;
this.Ip = Ip;
}
override
public string ToString()
{
string prefix = Foreign ? "Other" : "Me";
return $"{prefix}: Text";
return $"{prefix}: {Msg}({Sender})";
}
}
}