Skip to content
This repository has been archived by the owner on Jun 3, 2023. It is now read-only.

Commit

Permalink
Revise
Browse files Browse the repository at this point in the history
  • Loading branch information
Taiizor committed Mar 24, 2022
1 parent 4ffa7c5 commit c5b74e6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 33 deletions.
27 changes: 27 additions & 0 deletions src/Conforyon/Conforyon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
using Conforyon.Constant;
using Conforyon.Enum;
using System;
using System.IO;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Text.RegularExpressions;

#endregion
Expand Down Expand Up @@ -698,6 +701,30 @@ public static bool UseCheck(string Variable, bool Spaces = false)
return false;
}
}

/// <summary>
///
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="Data"></param>
/// <returns></returns>
public static string DataToJson<T>(T Data)
{
MemoryStream MemoryStream = new();

DataContractJsonSerializer Serializer = new
(
Data.GetType(),
new DataContractJsonSerializerSettings()
{
UseSimpleDictionaryFormat = true
}
);

Serializer.WriteObject(MemoryStream, Data);

return Encoding.UTF8.GetString(MemoryStream.ToArray());
}
#endregion
}
#endregion
Expand Down
7 changes: 2 additions & 5 deletions src/Conforyon/Method/Board/ClipBoard.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#if !NETSTANDARD

#region Imports
#region Imports

using Conforyon.Constant;
using System.IO;
Expand Down Expand Up @@ -125,5 +123,4 @@ public static Stream GetAudio(bool Clear = false)
}
#endregion
}
}
#endif
}
29 changes: 1 addition & 28 deletions src/Conforyon/Value/Values.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@

using Conforyon.Array;
using Conforyon.Constant;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Json;
using System.Text;

#endregion

Expand Down Expand Up @@ -145,35 +140,13 @@ public static string ListValueJson(string Error = Constants.ErrorMessage)
{
try
{
return DataToJson(ListValue());
return Cores.DataToJson(ListValue());
}
catch
{
return Error + Constants.ErrorTitle + "VS-LVJ1!)";
}
}

/// <summary>
///
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="Data"></param>
/// <returns></returns>
private static string DataToJson<T>(T Data)
{
MemoryStream MemoryStream = new();

DataContractJsonSerializer Serializer = new(
Data.GetType(),
new DataContractJsonSerializerSettings()
{
UseSimpleDictionaryFormat = true
});

Serializer.WriteObject(MemoryStream, Data);

return Encoding.UTF8.GetString(MemoryStream.ToArray());
}
#endregion
}
}

0 comments on commit c5b74e6

Please # to comment.