Add DateTime support for read/write methods

This commit is contained in:
Michael Croes
2018-09-21 21:38:23 +02:00
parent 735f1d4533
commit 427d8124de
3 changed files with 22 additions and 1 deletions

View File

@@ -41,6 +41,8 @@ namespace S7.Net.Protocol
return Types.Double.ToByteArray((double)value);
case "Single":
return Types.Single.ToByteArray((float)value);
case "DateTime":
return Types.DateTime.ToByteArray((System.DateTime) value);
case "Byte[]":
return (byte[])value;
case "Int16[]":
@@ -60,6 +62,8 @@ namespace S7.Net.Protocol
// if the consumer does not pay attention to string length.
var stringVal = (string) value;
return Types.String.ToByteArray(stringVal, stringVal.Length);
case "DateTime[]":
return Types.DateTime.ToByteArray((System.DateTime[]) value);
default:
throw new InvalidVariableTypeException();
}