|
@@ -1,70 +1,18 @@
|
|
|
-
|
|
|
-using System;
|
|
|
+using System;
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
|
using Vit.Extensions.Json_Extensions;
|
|
|
|
|
|
namespace Vit.Core.Module.Serialization
|
|
|
{
|
|
|
- public static class Json
|
|
|
+ public static partial class Json
|
|
|
{
|
|
|
|
|
|
public static ISerialization Instance { get; set; } = Serialization_Newtonsoft.Instance;
|
|
|
|
|
|
|
|
|
- #region (x.1)object <--> String
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// T也可为值类型(例如 int?、bool)
|
|
|
- /// </summary>
|
|
|
- /// <typeparam name="T"></typeparam>
|
|
|
- /// <param name="value"></param>
|
|
|
- /// <returns></returns>
|
|
|
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
- public static string SerializeToString<T>(T value)
|
|
|
- {
|
|
|
- return Instance.SerializeToString<T>(value);
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// T也可为值类型(例如 int?、bool)
|
|
|
- /// </summary>
|
|
|
- /// <param name="value"></param>
|
|
|
- /// <param name="type"></param>
|
|
|
- /// <returns></returns>
|
|
|
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
- public static string SerializeToString(object value, Type type)
|
|
|
- {
|
|
|
- return Instance.SerializeToString(value, type);
|
|
|
- }
|
|
|
|
|
|
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 使用Newtonsoft反序列化。T也可为值类型(例如 int?、bool)
|
|
|
- /// </summary>
|
|
|
- /// <param name="value"></param>
|
|
|
- /// <returns></returns>
|
|
|
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
- public static T DeserializeFromString<T>(string value)
|
|
|
- {
|
|
|
- return Instance.DeserializeFromString<T>(value);
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 使用Newtonsoft反序列化。T也可为值类型(例如 int?、bool)
|
|
|
- /// </summary>
|
|
|
- /// <param name="value"></param>
|
|
|
- /// <param name="type"></param>
|
|
|
- /// <returns></returns>
|
|
|
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
- public static object DeserializeFromString(string value, Type type)
|
|
|
- {
|
|
|
- return Instance.DeserializeFromString(value, type);
|
|
|
- }
|
|
|
-
|
|
|
- #endregion
|
|
|
-
|
|
|
#region (x.1)object <--> String
|
|
|
|
|
|
/// <summary>
|
|
@@ -76,7 +24,7 @@ namespace Vit.Core.Module.Serialization
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
public static string Serialize<T>(T value)
|
|
|
{
|
|
|
- return Instance.SerializeToString<T>(value);
|
|
|
+ return Instance.Serialize<T>(value);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -88,7 +36,7 @@ namespace Vit.Core.Module.Serialization
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
public static string Serialize(object value, Type type)
|
|
|
{
|
|
|
- return Instance.SerializeToString(value, type);
|
|
|
+ return Instance.Serialize(value, type);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -101,7 +49,7 @@ namespace Vit.Core.Module.Serialization
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
public static T Deserialize<T>(string value)
|
|
|
{
|
|
|
- return Instance.DeserializeFromString<T>(value);
|
|
|
+ return Instance.Deserialize<T>(value);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -113,7 +61,7 @@ namespace Vit.Core.Module.Serialization
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
public static object Deserialize(string value, Type type)
|
|
|
{
|
|
|
- return Instance.DeserializeFromString(value, type);
|
|
|
+ return Instance.Deserialize(value, type);
|
|
|
}
|
|
|
|
|
|
#endregion
|