/// <summary> /// Convert ReadOnlyMemory byte to type /// </summary> /// <typeparam name="TResult">Specify type for convert</typeparam> /// <param name="byteData">ReadOnlyMemory byte data</param> /// <param name="encoding">Specify encoding</param> /// <returns>Converted type from byte[]</returns> #region FromJson public static TResult FromJson <TResult>(this ReadOnlyMemory <byte> byteData, G9Encoding encoding) { return(typeof(TResult) == typeof(byte[]) ? (TResult)(object)byteData.ToArray() : JsonConvert.DeserializeObject <TResult>(encoding.GetString(byteData))); }
/// <summary> /// Convert byte to type /// </summary> /// <typeparam name="TResult">Specify type for convert</typeparam> /// <param name="byteData">byte[] data</param> /// <param name="encoding">Specify encoding</param> /// <returns>Converted type from byte[]</returns> #region FromJson public static TResult FromJson <TResult>(this byte[] byteData, G9Encoding encoding) { return(typeof(TResult) == typeof(byte[]) ? (TResult)(object)byteData : JsonConvert.DeserializeObject <TResult>(encoding.GetString(byteData))); }