mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-11 19:12:31 +02:00
37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
/*
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE
|
|
* Version 3, 19 November 2007
|
|
* Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
* Everyone is permitted to copy and distribute verbatim copies
|
|
* of this license document, but changing it is not allowed.
|
|
*/
|
|
|
|
using System.IO;
|
|
using System.Runtime.Serialization.Formatters.Binary;
|
|
|
|
namespace PrusaSL1Reader.Extensions
|
|
{
|
|
public static class ObjectExtensions
|
|
{
|
|
/// <summary>
|
|
/// Converts a string into a target type
|
|
/// </summary>
|
|
/// <typeparam name="T">Target type to convert into</typeparam>
|
|
/// <param name="input">Value</param>
|
|
/// <returns>Converted value into target type</returns>
|
|
public static T Convert<T>(this object input)
|
|
{
|
|
return StringExtensions.Convert<T>(input.ToString());
|
|
}
|
|
|
|
public static object DeserializeFromBytes(byte[] bytes)
|
|
{
|
|
var formatter = new BinaryFormatter();
|
|
using (var stream = new MemoryStream(bytes))
|
|
{
|
|
return formatter.Deserialize(stream);
|
|
}
|
|
}
|
|
}
|
|
}
|