51 lines
1.4 KiB
C#
51 lines
1.4 KiB
C#
namespace CommonConsole
|
|
{
|
|
using CommonMessurementUnits;
|
|
|
|
public class Program
|
|
{
|
|
public static void Main(string[] args)
|
|
{
|
|
int x = 3;
|
|
Console.WriteLine($"From Int32: {x}");
|
|
byte[] xb = x.GetBytes();
|
|
Console.WriteLine($"Bits: {string.Join("", xb.GetBits())}");
|
|
Console.WriteLine($"Hex bytes: {xb.ToHex()}");
|
|
int y = BitConverter.ToInt32(xb, 0);
|
|
Console.WriteLine($"To Int32: {y}");
|
|
Console.WriteLine();
|
|
|
|
var model = new TestClass
|
|
{
|
|
Current = 130,
|
|
Flow = 40,
|
|
Pressure = 250000,
|
|
Temperature = 21,
|
|
Time = 960,
|
|
Volume = 40,
|
|
};
|
|
|
|
var modelJson = JsonConvert.SerializeObject(model, Formatting.Indented);
|
|
var testModel = JsonConvert.DeserializeObject<TestClass>(modelJson);
|
|
|
|
Console.WriteLine($"To Json: {modelJson}");
|
|
Console.WriteLine($"From Json: {JsonConvert.SerializeObject(testModel, Formatting.Indented)}");
|
|
}
|
|
}
|
|
|
|
public class TestClass
|
|
{
|
|
public Current Current { get; set; }
|
|
|
|
public Flow Flow { get; set; }
|
|
|
|
public Pressure Pressure { get; set; }
|
|
|
|
public Temperature Temperature { get; set; }
|
|
|
|
public Time Time { get; set; }
|
|
|
|
public Volume Volume { get; set; }
|
|
}
|
|
}
|