using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HBLConsole.Service
{
public static class ExpandMethod
{
public static int GetIndex(this bool[] obj, bool value)
{
if (obj == null) return -1;
return Array.FindIndex(obj, p => p == value);
}
public static int GetIndex(this string[] obj, string value)
{
if (obj == null || value == null) return -1;
return Array.FindIndex(obj, p => p == value && p.Length > 0);
}
///
/// 保存数据
///
public static void Save(this T ot)
{
string outjson = JsonConvert.SerializeObject(ot);
var str = ot.GetType().GenericTypeArguments;
if (str != null && str.Length > 0)
{
File.WriteAllText(LocaPath.GetInstance.Getpath(str[0].Name), outjson);
}
}
///
/// 获取保存的数据
///
public static void Read(this object ot)
{
var str = ot.GetType().GenericTypeArguments;
if (str != null && str.Length > 0)
{
string pa = LocaPath.GetInstance.Getpath(str[0].Name);
if (File.Exists(pa))
{
string JsonString = File.ReadAllText(pa);
var result = JsonConvert.DeserializeObject