Browse Source

添加Json工具(没啥用,只是为了统一Newtonsoft.json的版本),包括引用之后的一系列修改

yuzhengyang 7 years ago
parent
commit
2a6cf1ea84
37 changed files with 521 additions and 78895 deletions
  1. 5 5
      Azylee.Utils/Azylee.Core.Plus/Azylee.Core.Plus.csproj
  2. 1 1
      Azylee.Utils/Azylee.Core.Plus/packages.config
  3. 7 2
      Azylee.Utils/Azylee.Core/LogUtils/SimpleLogUtils/Log.cs
  4. 1 1
      Azylee.Utils/Azylee.Core/Properties/AssemblyInfo.cs
  5. 59 0
      Azylee.Utils/Azylee.Jsons/Azylee.Jsons.csproj
  6. 326 0
      Azylee.Utils/Azylee.Jsons/ConvertJson.cs
  7. 48 0
      Azylee.Utils/Azylee.Jsons/Json.cs
  8. 36 0
      Azylee.Utils/Azylee.Jsons/Properties/AssemblyInfo.cs
  9. 4 0
      Azylee.Utils/Azylee.Jsons/packages.config
  10. 7 0
      Azylee.Utils/Azylee.Utils.sln
  11. 4 3
      Azylee.Utils/Azylee.YeahWeb/Azylee.YeahWeb.csproj
  12. 2 6
      Azylee.Utils/Azylee.YeahWeb/BaiDuWebAPI/GPSAPI/GPSConverter.cs
  13. 3 8
      Azylee.Utils/Azylee.YeahWeb/BaiDuWebAPI/GPSAPI/GPSInfoTool.cs
  14. 3 3
      Azylee.Utils/Azylee.YeahWeb/BaiDuWebAPI/IPLocationAPI/IPLocationTool.cs
  15. 5 7
      Azylee.Utils/Azylee.YeahWeb/HttpUtils/HttpTool.cs
  16. 4 8
      Azylee.Utils/Azylee.YeahWeb/HttpUtils/HttpToolPlus.cs
  17. 0 4
      Azylee.Utils/Azylee.YeahWeb/TencentWebAPI/PictureAI/PictureScener.cs
  18. 6 0
      Azylee.Utils/Tests/Test.ProcessTool/Program.cs
  19. 0 20
      Azylee.Utils/packages/Newtonsoft.Json.10.0.3/LICENSE.md
  20. BIN
      Azylee.Utils/packages/Newtonsoft.Json.10.0.3/Newtonsoft.Json.10.0.3.nupkg
  21. BIN
      Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/net20/Newtonsoft.Json.dll
  22. 0 9815
      Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/net20/Newtonsoft.Json.xml
  23. BIN
      Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/net35/Newtonsoft.Json.dll
  24. 0 8944
      Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/net35/Newtonsoft.Json.xml
  25. BIN
      Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/net40/Newtonsoft.Json.dll
  26. 0 9144
      Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/net40/Newtonsoft.Json.xml
  27. BIN
      Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/net45/Newtonsoft.Json.dll
  28. 0 10760
      Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/net45/Newtonsoft.Json.xml
  29. BIN
      Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/netstandard1.0/Newtonsoft.Json.dll
  30. 0 10467
      Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/netstandard1.0/Newtonsoft.Json.xml
  31. BIN
      Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/netstandard1.3/Newtonsoft.Json.dll
  32. 0 10559
      Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/netstandard1.3/Newtonsoft.Json.xml
  33. BIN
      Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/portable-net40+sl5+win8+wp8+wpa81/Newtonsoft.Json.dll
  34. 0 8555
      Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/portable-net40+sl5+win8+wp8+wpa81/Newtonsoft.Json.xml
  35. BIN
      Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/portable-net45+win8+wp8+wpa81/Newtonsoft.Json.dll
  36. 0 10467
      Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/portable-net45+win8+wp8+wpa81/Newtonsoft.Json.xml
  37. 0 116
      Azylee.Utils/packages/Newtonsoft.Json.10.0.3/tools/install.ps1

+ 5 - 5
Azylee.Utils/Azylee.Core.Plus/Azylee.Core.Plus.csproj

@@ -30,8 +30,8 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
-      <HintPath>..\..\packages\Newtonsoft.Json.10.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
+    <Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
+      <HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net40\Newtonsoft.Json.dll</HintPath>
     </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
@@ -47,13 +47,13 @@
     <Compile Include="Properties\AssemblyInfo.cs" />
   </ItemGroup>
   <ItemGroup>
-    <None Include="packages.config" />
-  </ItemGroup>
-  <ItemGroup>
     <ProjectReference Include="..\Azylee.Core\Azylee.Core.csproj">
       <Project>{88dc61fa-95f0-41b7-9d7d-ab0f3cbd169c}</Project>
       <Name>Azylee.Core</Name>
     </ProjectReference>
   </ItemGroup>
+  <ItemGroup>
+    <None Include="packages.config" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 </Project>

+ 1 - 1
Azylee.Utils/Azylee.Core.Plus/packages.config

@@ -1,4 +1,4 @@
 <?xml version="1.0" encoding="utf-8"?>
 <packages>
-  <package id="Newtonsoft.Json" version="10.0.3" targetFramework="net40" />
+  <package id="Newtonsoft.Json" version="11.0.2" targetFramework="net40" />
 </packages>

+ 7 - 2
Azylee.Utils/Azylee.Core/LogUtils/SimpleLogUtils/Log.cs

@@ -56,9 +56,9 @@ namespace Azylee.Core.LogUtils.SimpleLogUtils
 
         private Log() { }
         /// <summary>
-        /// 初始化 Log 工具
+        /// 初始化 Log 工具(不建议使用)
         /// </summary>
-        /// <param name="isWrite">已失效,使用WriteLevel代替</param>
+        /// <param name="isWrite">是否写出日志</param>
         /// <param name="logLevel"></param>
         /// <param name="writeLevel"></param>
         [Obsolete]
@@ -70,6 +70,11 @@ namespace Azylee.Core.LogUtils.SimpleLogUtils
                 ConsoleLogLevel = logLevel;
                 FileLogLevel = writeLevel;
             }
+            else
+            {
+                ConsoleLogLevel = logLevel;
+                FileLogLevel = LogLevel.None;
+            }
         }
         /// <summary>
         /// 初始化 Log 工具

+ 1 - 1
Azylee.Utils/Azylee.Core/Properties/AssemblyInfo.cs

@@ -32,4 +32,4 @@ using System.Runtime.InteropServices;
 // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
 //通过使用 "*",如下所示:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.4")]
+[assembly: AssemblyVersion("1.0.0.5")]

+ 59 - 0
Azylee.Utils/Azylee.Jsons/Azylee.Jsons.csproj

@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{DE3AB999-96D3-4A53-A9F2-7409138D0333}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Azylee.Jsons</RootNamespace>
+    <AssemblyName>Azylee.Jsons</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
+      <HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net40\Newtonsoft.Json.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="ConvertJson.cs" />
+    <Compile Include="Json.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\Azylee.Core\Azylee.Core.csproj">
+      <Project>{88dc61fa-95f0-41b7-9d7d-ab0f3cbd169c}</Project>
+      <Name>Azylee.Core</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="packages.config" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project>

+ 326 - 0
Azylee.Utils/Azylee.Jsons/ConvertJson.cs

@@ -0,0 +1,326 @@
+//############################################################
+//      https://github.com/yuzhengyang
+//      author:yuzhengyang
+//############################################################
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Data;
+using System.Reflection;
+using System.Collections;
+using System.Data.Common;
+
+namespace Azylee.Jsons
+{
+    //JSON转换类
+    public class ConvertJson
+    {
+        #region 私有方法
+        /// <summary>
+        /// 过滤特殊字符
+        /// </summary>
+        private static string String2Json(String s)
+        {
+            StringBuilder sb = new StringBuilder();
+            for (int i = 0; i < s.Length; i++)
+            {
+                char c = s.ToCharArray()[i];
+                switch (c)
+                {
+                    case '\"':
+                        sb.Append("\\\""); break;
+                    case '\\':
+                        sb.Append("\\\\"); break;
+                    case '/':
+                        sb.Append("\\/"); break;
+                    case '\b':
+                        sb.Append("\\b"); break;
+                    case '\f':
+                        sb.Append("\\f"); break;
+                    case '\n':
+                        sb.Append("\\n"); break;
+                    case '\r':
+                        sb.Append("\\r"); break;
+                    case '\t':
+                        sb.Append("\\t"); break;
+                    default:
+                        sb.Append(c); break;
+                }
+            }
+            return sb.ToString();
+        }
+
+        /// <summary>
+        /// 格式化字符型、日期型、布尔型
+        /// </summary>
+        private static string StringFormat(string str, Type type)
+        {
+            if (type == typeof(string))
+            {
+                str = String2Json(str);
+                str = "\"" + str + "\"";
+            }
+            else if (type == typeof(DateTime))
+            {
+                str = "\"" + str + "\"";
+            }
+            else if (type == typeof(bool))
+            {
+                str = str.ToLower();
+            }
+            else if (type != typeof(string) && string.IsNullOrEmpty(str))
+            {
+                str = "\"" + str + "\"";
+            }
+            return str;
+        }
+        #endregion
+
+        #region List转换成Json
+        /// <summary>
+        /// List转换成Json
+        /// </summary>
+        public static string ListToJson<T>(IList<T> list)
+        {
+            object obj = list[0];
+            return ListToJson<T>(list, obj.GetType().Name);
+        }
+
+        /// <summary>
+        /// List转换成Json 
+        /// </summary>
+        public static string ListToJson<T>(IList<T> list, string jsonName)
+        {
+            StringBuilder Json = new StringBuilder();
+            if (string.IsNullOrEmpty(jsonName)) jsonName = list[0].GetType().Name;
+            Json.Append("{\"" + jsonName + "\":[");
+            if (list.Count > 0)
+            {
+                for (int i = 0; i < list.Count; i++)
+                {
+                    T obj = Activator.CreateInstance<T>();
+                    PropertyInfo[] pi = obj.GetType().GetProperties();
+                    Json.Append("{");
+                    for (int j = 0; j < pi.Length; j++)
+                    {
+                        Type type = pi[j].GetValue(list[i], null).GetType();
+                        Json.Append("\"" + pi[j].Name.ToString() + "\":" + StringFormat(pi[j].GetValue(list[i], null).ToString(), type));
+
+                        if (j < pi.Length - 1)
+                        {
+                            Json.Append(",");
+                        }
+                    }
+                    Json.Append("}");
+                    if (i < list.Count - 1)
+                    {
+                        Json.Append(",");
+                    }
+                }
+            }
+            Json.Append("]}");
+            return Json.ToString();
+        }
+        #endregion
+
+        #region 对象转换为Json
+        /// <summary> 
+        /// 对象转换为Json 
+        /// </summary> 
+        /// <param name="jsonObject">对象</param> 
+        /// <returns>Json字符串</returns> 
+        public static string ToJson(object jsonObject)
+        {
+            string jsonString = "{";
+            PropertyInfo[] propertyInfo = jsonObject.GetType().GetProperties();
+            for (int i = 0; i < propertyInfo.Length; i++)
+            {
+                object objectValue = propertyInfo[i].GetGetMethod().Invoke(jsonObject, null);
+                string value = string.Empty;
+                if (objectValue is DateTime || objectValue is Guid || objectValue is TimeSpan)
+                {
+                    value = "'" + objectValue.ToString() + "'";
+                }
+                else if (objectValue is string)
+                {
+                    value = "'" + ToJson(objectValue.ToString()) + "'";
+                }
+                else if (objectValue is IEnumerable)
+                {
+                    value = ToJson((IEnumerable)objectValue);
+                }
+                else
+                {
+                    value = ToJson(objectValue.ToString());
+                }
+                jsonString += "\"" + ToJson(propertyInfo[i].Name) + "\":" + value + ",";
+            }
+            jsonString.Remove(jsonString.Length - 1, jsonString.Length);
+            return jsonString + "}";
+        }
+        #endregion
+
+        #region 对象集合转换Json
+        /// <summary> 
+        /// 对象集合转换Json 
+        /// </summary> 
+        /// <param name="array">集合对象</param> 
+        /// <returns>Json字符串</returns> 
+        public static string ToJson(IEnumerable array)
+        {
+            string jsonString = "[";
+            foreach (object item in array)
+            {
+                jsonString += ToJson(item) + ",";
+            }
+            jsonString.Remove(jsonString.Length - 1, jsonString.Length);
+            return jsonString + "]";
+        }
+        #endregion
+
+        #region 普通集合转换Json
+        /// <summary> 
+        /// 普通集合转换Json 
+        /// </summary> 
+        /// <param name="array">集合对象</param> 
+        /// <returns>Json字符串</returns> 
+        public static string ToArrayString(IEnumerable array)
+        {
+            string jsonString = "[";
+            foreach (object item in array)
+            {
+                jsonString = ToJson(item.ToString()) + ",";
+            }
+            jsonString.Remove(jsonString.Length - 1, jsonString.Length);
+            return jsonString + "]";
+        }
+        #endregion
+
+        #region  DataSet转换为Json
+        /// <summary> 
+        /// DataSet转换为Json 
+        /// </summary> 
+        /// <param name="dataSet">DataSet对象</param> 
+        /// <returns>Json字符串</returns> 
+        public static string ToJson(DataSet dataSet)
+        {
+            string jsonString = "{";
+            foreach (DataTable table in dataSet.Tables)
+            {
+                jsonString += "\"" + table.TableName + "\":" + ToJson(table) + ",";
+            }
+            jsonString = jsonString.TrimEnd(',');
+            return jsonString + "}";
+        }
+        #endregion
+
+        #region Datatable转换为Json
+        /// <summary> 
+        /// Datatable转换为Json 
+        /// </summary> 
+        /// <param name="table">Datatable对象</param> 
+        /// <returns>Json字符串</returns> 
+        public static string ToJson(DataTable dt)
+        {
+            StringBuilder jsonString = new StringBuilder();
+            jsonString.Append("[");
+            DataRowCollection drc = dt.Rows;
+            for (int i = 0; i < drc.Count; i++)
+            {
+                jsonString.Append("{");
+                for (int j = 0; j < dt.Columns.Count; j++)
+                {
+                    string strKey = dt.Columns[j].ColumnName;
+                    string strValue = drc[i][j].ToString();
+                    Type type = dt.Columns[j].DataType;
+                    jsonString.Append("\"" + strKey + "\":");
+                    strValue = StringFormat(strValue, type);
+                    if (j < dt.Columns.Count - 1)
+                    {
+                        jsonString.Append(strValue + ",");
+                    }
+                    else
+                    {
+                        jsonString.Append(strValue);
+                    }
+                }
+                jsonString.Append("},");
+            }
+            jsonString.Remove(jsonString.Length - 1, 1);
+            jsonString.Append("]");
+            return jsonString.ToString();
+        }
+
+        /// <summary>
+        /// DataTable转换为Json 
+        /// </summary>
+        public static string ToJson(DataTable dt, string jsonName)
+        {
+            StringBuilder Json = new StringBuilder();
+            if (string.IsNullOrEmpty(jsonName)) jsonName = dt.TableName;
+            Json.Append("{\"" + jsonName + "\":[");
+            if (dt.Rows.Count > 0)
+            {
+                for (int i = 0; i < dt.Rows.Count; i++)
+                {
+                    Json.Append("{");
+                    for (int j = 0; j < dt.Columns.Count; j++)
+                    {
+                        Type type = dt.Rows[i][j].GetType();
+                        Json.Append("\"" + dt.Columns[j].ColumnName.ToString() + "\":" + StringFormat(dt.Rows[i][j].ToString(), type));
+                        if (j < dt.Columns.Count - 1)
+                        {
+                            Json.Append(",");
+                        }
+                    }
+                    Json.Append("}");
+                    if (i < dt.Rows.Count - 1)
+                    {
+                        Json.Append(",");
+                    }
+                }
+            }
+            Json.Append("]}");
+            return Json.ToString();
+        }
+        #endregion
+
+        #region DataReader转换为Json
+        /// <summary> 
+        /// DataReader转换为Json 
+        /// </summary> 
+        /// <param name="dataReader">DataReader对象</param> 
+        /// <returns>Json字符串</returns> 
+        public static string ToJson(DbDataReader dataReader)
+        {
+            StringBuilder jsonString = new StringBuilder();
+            jsonString.Append("[");
+            while (dataReader.Read())
+            {
+                jsonString.Append("{");
+                for (int i = 0; i < dataReader.FieldCount; i++)
+                {
+                    Type type = dataReader.GetFieldType(i);
+                    string strKey = dataReader.GetName(i);
+                    string strValue = dataReader[i].ToString();
+                    jsonString.Append("\"" + strKey + "\":");
+                    strValue = StringFormat(strValue, type);
+                    if (i < dataReader.FieldCount - 1)
+                    {
+                        jsonString.Append(strValue + ",");
+                    }
+                    else
+                    {
+                        jsonString.Append(strValue);
+                    }
+                }
+                jsonString.Append("},");
+            }
+            dataReader.Close();
+            jsonString.Remove(jsonString.Length - 1, 1);
+            jsonString.Append("]");
+            return jsonString.ToString();
+        }
+        #endregion
+    }
+}

+ 48 - 0
Azylee.Utils/Azylee.Jsons/Json.cs

@@ -0,0 +1,48 @@
+//************************************************************************
+//      https://github.com/yuzhengyang
+//      author:     yuzhengyang
+//      date:       2017.3.29 - 2017.8.24
+//      desc:       Json转换工具类(需要Newtonsoft.Json支持)
+//      Copyright (c) yuzhengyang. All rights reserved.
+//************************************************************************
+using Azylee.Core.IOUtils.TxtUtils;
+using Newtonsoft.Json;
+using System;
+
+namespace Azylee.Jsons
+{
+    public class Json
+    {
+        public static string Object2String(object obj)
+        {
+            return JsonConvert.SerializeObject(obj);
+        }
+        public static object String2Object(string s)
+        {
+            string json = s;
+            if (!string.IsNullOrWhiteSpace(json))
+            {
+                try { return JsonConvert.DeserializeObject(json); } catch (Exception e) { }
+            }
+            return null;
+        }
+        public static T String2Object<T>(string s)
+        {
+            string json = s;
+            if (!string.IsNullOrWhiteSpace(json))
+            {
+                try { return JsonConvert.DeserializeObject<T>(json); } catch (Exception e) { }
+            }
+            return default(T);
+        }
+        public static T File2Object<T>(string file)
+        {
+            string json = TxtTool.Read(file);
+            if (!string.IsNullOrWhiteSpace(json))
+            {
+                try { return JsonConvert.DeserializeObject<T>(json); } catch (Exception e) { }
+            }
+            return default(T);
+        }
+    }
+}

+ 36 - 0
Azylee.Utils/Azylee.Jsons/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("Azylee.Jsons")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Azylee.Jsons")]
+[assembly: AssemblyCopyright("Copyright ©  2018")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("de3ab999-96d3-4a53-a9f2-7409138d0333")]
+
+// 程序集的版本信息由下列四个值组成: 
+//
+//      主版本
+//      次版本
+//      生成号
+//      修订号
+//
+// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
+//通过使用 "*",如下所示:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 4 - 0
Azylee.Utils/Azylee.Jsons/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="Newtonsoft.Json" version="11.0.2" targetFramework="net40" />
+</packages>

+ 7 - 0
Azylee.Utils/Azylee.Utils.sln

@@ -31,6 +31,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azylee.DB.SQLite", "Azylee.
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.Toast", "Tests\Test.Toast\Test.Toast.csproj", "{576CFDD2-150A-4D0C-874A-730265537902}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azylee.Jsons", "Azylee.Jsons\Azylee.Jsons.csproj", "{DE3AB999-96D3-4A53-A9F2-7409138D0333}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -85,6 +87,10 @@ Global
 		{576CFDD2-150A-4D0C-874A-730265537902}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{576CFDD2-150A-4D0C-874A-730265537902}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{576CFDD2-150A-4D0C-874A-730265537902}.Release|Any CPU.Build.0 = Release|Any CPU
+		{DE3AB999-96D3-4A53-A9F2-7409138D0333}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{DE3AB999-96D3-4A53-A9F2-7409138D0333}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{DE3AB999-96D3-4A53-A9F2-7409138D0333}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{DE3AB999-96D3-4A53-A9F2-7409138D0333}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
@@ -101,6 +107,7 @@ Global
 		{0213B9D4-1B4A-4BDE-9CE9-228C68A9A522} = {9351FC10-E8D0-41BB-A813-0B5B3EA90605}
 		{A77DBB5D-CA37-425C-8FA2-8B0736AE1C4D} = {927325CD-24FD-4B85-A982-543D4F58A47C}
 		{576CFDD2-150A-4D0C-874A-730265537902} = {9351FC10-E8D0-41BB-A813-0B5B3EA90605}
+		{DE3AB999-96D3-4A53-A9F2-7409138D0333} = {927325CD-24FD-4B85-A982-543D4F58A47C}
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 		SolutionGuid = {3A021A3E-4C98-47CD-B4E8-912E12611C2E}

+ 4 - 3
Azylee.Utils/Azylee.YeahWeb/Azylee.YeahWeb.csproj

@@ -30,9 +30,6 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
-      <HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net40\Newtonsoft.Json.dll</HintPath>
-    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
     <Reference Include="System.Web" />
@@ -70,6 +67,10 @@
       <Project>{88dc61fa-95f0-41b7-9d7d-ab0f3cbd169c}</Project>
       <Name>Azylee.Core</Name>
     </ProjectReference>
+    <ProjectReference Include="..\Azylee.Jsons\Azylee.Jsons.csproj">
+      <Project>{de3ab999-96d3-4a53-a9f2-7409138d0333}</Project>
+      <Name>Azylee.Jsons</Name>
+    </ProjectReference>
   </ItemGroup>
   <ItemGroup>
     <None Include="packages.config" />

+ 2 - 6
Azylee.Utils/Azylee.YeahWeb/BaiDuWebAPI/GPSAPI/GPSConverter.cs

@@ -1,10 +1,6 @@
 using Azylee.Core.DataUtils.CollectionUtils;
+using Azylee.Jsons;
 using Azylee.YeahWeb.HttpUtils;
-using Newtonsoft.Json;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
 
 namespace Azylee.YeahWeb.BaiDuWebAPI.GPSAPI
 {
@@ -27,7 +23,7 @@ namespace Azylee.YeahWeb.BaiDuWebAPI.GPSAPI
             {
                 string url = $"http://api.map.baidu.com/geoconv/v1/?coords={longitude},{latitude}&from=1&to=5&ak={ak}";
                 string rs = HttpTool.Get(url);
-                GPSPointWebModel rsobj = JsonConvert.DeserializeObject<GPSPointWebModel>(rs);
+                GPSPointWebModel rsobj = Json.String2Object<GPSPointWebModel>(rs);
                 if (rsobj != null && ListTool.HasElements(rsobj.result))
                 {
                     x = rsobj.result[0].x;

+ 3 - 8
Azylee.Utils/Azylee.YeahWeb/BaiDuWebAPI/GPSAPI/GPSInfoTool.cs

@@ -1,22 +1,17 @@
-using Azylee.Core.DataUtils.CollectionUtils;
+using Azylee.Jsons;
 using Azylee.YeahWeb.HttpUtils;
-using Newtonsoft.Json;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
 
 namespace Azylee.YeahWeb.BaiDuWebAPI.GPSAPI
 {
     public class GPSInfoTool
     {
-        public static GPSInfoWebModel GetInfo(string ak, double longitude, double latitude )
+        public static GPSInfoWebModel GetInfo(string ak, double longitude, double latitude)
         {
             try
             {
                 string url = $"http://api.map.baidu.com/geocoder/v2/?location={latitude},{longitude}&coordtype=wgs84ll&output=json&ak={ak}";
                 string rs = HttpTool.Get(url);
-                GPSInfoWebModel obj = JsonConvert.DeserializeObject<GPSInfoWebModel>(rs);
+                GPSInfoWebModel obj = Json.String2Object<GPSInfoWebModel>(rs);
                 if (obj != null) return obj;
             }
             catch { }

+ 3 - 3
Azylee.Utils/Azylee.YeahWeb/BaiDuWebAPI/IPLocationAPI/IPLocationTool.cs

@@ -1,5 +1,5 @@
-using Azylee.YeahWeb.HttpUtils;
-using Newtonsoft.Json;
+using Azylee.Jsons;
+using Azylee.YeahWeb.HttpUtils;
 using System;
 using System.Net;
 
@@ -16,7 +16,7 @@ namespace Azylee.YeahWeb.BaiDuWebAPI.IPLocationAPI
                 CookieCollection cookie = new CookieCollection();
                 string rss1 = HttpToolPlus.Get(URL, ref cookie);//第一次请求以获取Cookie
                 string rss2 = HttpToolPlus.Get(URL, ref cookie);//携带第一次的Cookie获取数据
-                model = JsonConvert.DeserializeObject<IPLocationWebModel>(rss2);
+                model = Json.String2Object<IPLocationWebModel>(rss2);
                 return model.ToIPLocationModel();
             }
             catch (Exception e) { return null; }

+ 5 - 7
Azylee.Utils/Azylee.YeahWeb/HttpUtils/HttpTool.cs

@@ -6,13 +6,11 @@ using Azylee.Core.DataUtils.GuidUtils;
 using Azylee.Core.DataUtils.StringUtils;
 using Azylee.Core.DelegateUtils.ProcessDelegateUtils;
 using Azylee.Core.IOUtils.DirUtils;
-using Newtonsoft.Json;
+using Azylee.Jsons;
 using System;
-using System.Diagnostics;
 using System.IO;
 using System.Net;
 using System.Text;
-using System.Web;
 
 namespace Azylee.YeahWeb.HttpUtils
 {
@@ -75,7 +73,7 @@ namespace Azylee.YeahWeb.HttpUtils
                     string response = new StreamReader(wr.GetResponseStream(), myEncoding).ReadToEnd();
                     if (!StringTool.IsNullOrWhiteSpace(response))
                     {
-                        T result = JsonConvert.DeserializeObject<T>(response);
+                        T result = Json.String2Object<T>(response);
                         return result;
                     }
                 }
@@ -104,7 +102,7 @@ namespace Azylee.YeahWeb.HttpUtils
                             string txt = sr.ReadToEnd();
                             if (!string.IsNullOrWhiteSpace(txt))
                             {
-                                T result = JsonConvert.DeserializeObject<T>(txt);
+                                T result = Json.String2Object<T>(txt);
                                 return result;
                             }
                         }
@@ -157,7 +155,7 @@ namespace Azylee.YeahWeb.HttpUtils
             }
             else
             {
-                what = JsonConvert.DeserializeObject<T>(txt);
+                what = Json.String2Object<T>(txt);
                 return (int)Math.Ceiling((DateTime.Now - beginTime).TotalSeconds);//操作成功
             }
         }
@@ -208,7 +206,7 @@ namespace Azylee.YeahWeb.HttpUtils
             }
             else
             {
-                what = JsonConvert.DeserializeObject<T>(txt);
+                what = Json.String2Object<T>(txt);
                 return (int)Math.Ceiling((DateTime.Now - beginTime).TotalSeconds);//操作成功
             }
         }

+ 4 - 8
Azylee.Utils/Azylee.YeahWeb/HttpUtils/HttpToolPlus.cs

@@ -1,12 +1,8 @@
-using Azylee.YeahWeb.HttpUtils.MethodUtils.ExtendUtils;
+using Azylee.Jsons;
 using Azylee.YeahWeb.HttpUtils.MethodUtils.GetUtils;
 using Azylee.YeahWeb.HttpUtils.MethodUtils.PostUtils;
 using Azylee.YeahWeb.HttpUtils.Models;
-using Newtonsoft.Json;
-using System;
 using System.Collections.Generic;
-using System.IO;
-using System.Linq;
 using System.Net;
 using System.Text;
 
@@ -14,11 +10,11 @@ namespace Azylee.YeahWeb.HttpUtils
 {
     public class HttpToolPlus
     {
-        public static string Get(string url, ref CookieCollection cookie, Dictionary<string, string> headers = null, string contentType = HttpContentTypes.ApplicationXWwwFormUrlEncoded, bool autoRedirect = false, bool keepAlive = true, string userAgent =  UserAgents.Mozilla4)
+        public static string Get(string url, ref CookieCollection cookie, Dictionary<string, string> headers = null, string contentType = HttpContentTypes.ApplicationXWwwFormUrlEncoded, bool autoRedirect = false, bool keepAlive = true, string userAgent = UserAgents.Mozilla4)
         {
             return GetToolPlus.Get(url, ref cookie, headers = null, contentType, autoRedirect, keepAlive, userAgent);
         }
-        public static string Post(string url, ref CookieCollection cookie, Dictionary<string, string> data = null,Encoding encoding=null, Dictionary<string, string> headers = null, string contentType = HttpContentTypes.ApplicationXWwwFormUrlEncoded, bool autoRedirect = true, bool keepAlive = true, string userAgent = UserAgents.Mozilla4)
+        public static string Post(string url, ref CookieCollection cookie, Dictionary<string, string> data = null, Encoding encoding = null, Dictionary<string, string> headers = null, string contentType = HttpContentTypes.ApplicationXWwwFormUrlEncoded, bool autoRedirect = true, bool keepAlive = true, string userAgent = UserAgents.Mozilla4)
         {
             string param = null;
             try
@@ -38,7 +34,7 @@ namespace Azylee.YeahWeb.HttpUtils
         }
         public static string PostJson(string url, ref CookieCollection cookie, object data, Encoding encoding = null, Dictionary<string, string> headers = null, bool autoRedirect = true, bool keepAlive = true, string userAgent = UserAgents.Mozilla4)
         {
-            string param = JsonConvert.SerializeObject(data);
+            string param = Json.Object2String(data);
             return PostToolPlus.Post(url, ref cookie, param, encoding, headers, HttpContentTypes.ApplicationJson, autoRedirect, keepAlive, userAgent);
         }
     }

+ 0 - 4
Azylee.Utils/Azylee.YeahWeb/TencentWebAPI/PictureAI/PictureScener.cs

@@ -1,8 +1,4 @@
 using Azylee.YeahWeb.HttpUtils;
-using Newtonsoft.Json;
-using System;
-using System.Collections.Generic;
-using System.Linq;
 using System.Text;
 
 namespace Azylee.YeahWeb.TencentWebAPI.PictureAI

+ 6 - 0
Azylee.Utils/Tests/Test.ProcessTool/Program.cs

@@ -24,6 +24,12 @@ namespace Test.ProcessTool
             Cons.Log("测试 Muted 测试\r\n\r\n测试 Muted 测试\r\n\r\n测试 Muted 测试\r\n\r\n测试 Muted 测试", ConsColorMode.Muted);
             log.I("测试 Log V \r\n\r\n 测试 Log V \r\n\r\n 测试 Log V \r\n\r\n");
 
+            Cons.Log("测试 Muted 测试\r\r测试 Muted 测试\r\r测试 Muted 测试\r\r测试 Muted 测试", ConsColorMode.Muted);
+            log.I("测试 Log V \r\r 测试 Log V \r\r 测试 Log V \r\r");
+
+            Cons.Log("测试 Muted 测试\n\n测试 Muted 测试\n\n测试 Muted 测试\n\n测试 Muted 测试", ConsColorMode.Muted);
+            log.I("测试 Log V \n\n 测试 Log V \n\n 测试 Log V \n\n");
+
             Cons.Log("测试 Primary 测试", ConsColorMode.Primary);
             Cons.Log("测试 Secondary 测试", ConsColorMode.Secondary);
             Cons.Log("测试 Success 测试", ConsColorMode.Success);

+ 0 - 20
Azylee.Utils/packages/Newtonsoft.Json.10.0.3/LICENSE.md

@@ -1,20 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) 2007 James Newton-King
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
-the Software, and to permit persons to whom the Software is furnished to do so,
-subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
-FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

BIN
Azylee.Utils/packages/Newtonsoft.Json.10.0.3/Newtonsoft.Json.10.0.3.nupkg


BIN
Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/net20/Newtonsoft.Json.dll


File diff suppressed because it is too large
+ 0 - 9815
Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/net20/Newtonsoft.Json.xml


BIN
Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/net35/Newtonsoft.Json.dll


File diff suppressed because it is too large
+ 0 - 8944
Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/net35/Newtonsoft.Json.xml


BIN
Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/net40/Newtonsoft.Json.dll


File diff suppressed because it is too large
+ 0 - 9144
Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/net40/Newtonsoft.Json.xml


BIN
Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/net45/Newtonsoft.Json.dll


File diff suppressed because it is too large
+ 0 - 10760
Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/net45/Newtonsoft.Json.xml


BIN
Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/netstandard1.0/Newtonsoft.Json.dll


File diff suppressed because it is too large
+ 0 - 10467
Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/netstandard1.0/Newtonsoft.Json.xml


BIN
Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/netstandard1.3/Newtonsoft.Json.dll


File diff suppressed because it is too large
+ 0 - 10559
Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/netstandard1.3/Newtonsoft.Json.xml


BIN
Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/portable-net40+sl5+win8+wp8+wpa81/Newtonsoft.Json.dll


File diff suppressed because it is too large
+ 0 - 8555
Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/portable-net40+sl5+win8+wp8+wpa81/Newtonsoft.Json.xml


BIN
Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/portable-net45+win8+wp8+wpa81/Newtonsoft.Json.dll


File diff suppressed because it is too large
+ 0 - 10467
Azylee.Utils/packages/Newtonsoft.Json.10.0.3/lib/portable-net45+win8+wp8+wpa81/Newtonsoft.Json.xml


+ 0 - 116
Azylee.Utils/packages/Newtonsoft.Json.10.0.3/tools/install.ps1

@@ -1,116 +0,0 @@
-param($installPath, $toolsPath, $package, $project)
-
-# open json.net splash page on package install
-# don't open if json.net is installed as a dependency
-
-try
-{
-  $url = "http://www.newtonsoft.com/json/install?version=" + $package.Version
-  $dte2 = Get-Interface $dte ([EnvDTE80.DTE2])
-
-  if ($dte2.ActiveWindow.Caption -eq "Package Manager Console")
-  {
-    # user is installing from VS NuGet console
-    # get reference to the window, the console host and the input history
-    # show webpage if "install-package newtonsoft.json" was last input
-
-    $consoleWindow = $(Get-VSComponentModel).GetService([NuGetConsole.IPowerConsoleWindow])
-
-    $props = $consoleWindow.GetType().GetProperties([System.Reflection.BindingFlags]::Instance -bor `
-      [System.Reflection.BindingFlags]::NonPublic)
-
-    $prop = $props | ? { $_.Name -eq "ActiveHostInfo" } | select -first 1
-    if ($prop -eq $null) { return }
-  
-    $hostInfo = $prop.GetValue($consoleWindow)
-    if ($hostInfo -eq $null) { return }
-
-    $history = $hostInfo.WpfConsole.InputHistory.History
-
-    $lastCommand = $history | select -last 1
-
-    if ($lastCommand)
-    {
-      $lastCommand = $lastCommand.Trim().ToLower()
-      if ($lastCommand.StartsWith("install-package") -and $lastCommand.Contains("newtonsoft.json"))
-      {
-        $dte2.ItemOperations.Navigate($url) | Out-Null
-      }
-    }
-  }
-  else
-  {
-    # user is installing from VS NuGet dialog
-    # get reference to the window, then smart output console provider
-    # show webpage if messages in buffered console contains "installing...newtonsoft.json" in last operation
-
-    $instanceField = [NuGet.Dialog.PackageManagerWindow].GetField("CurrentInstance", [System.Reflection.BindingFlags]::Static -bor `
-      [System.Reflection.BindingFlags]::NonPublic)
-
-    $consoleField = [NuGet.Dialog.PackageManagerWindow].GetField("_smartOutputConsoleProvider", [System.Reflection.BindingFlags]::Instance -bor `
-      [System.Reflection.BindingFlags]::NonPublic)
-
-    if ($instanceField -eq $null -or $consoleField -eq $null) { return }
-
-    $instance = $instanceField.GetValue($null)
-
-    if ($instance -eq $null) { return }
-
-    $consoleProvider = $consoleField.GetValue($instance)
-    if ($consoleProvider -eq $null) { return }
-
-    $console = $consoleProvider.CreateOutputConsole($false)
-
-    $messagesField = $console.GetType().GetField("_messages", [System.Reflection.BindingFlags]::Instance -bor `
-      [System.Reflection.BindingFlags]::NonPublic)
-    if ($messagesField -eq $null) { return }
-
-    $messages = $messagesField.GetValue($console)
-    if ($messages -eq $null) { return }
-
-    $operations = $messages -split "=============================="
-
-    $lastOperation = $operations | select -last 1
-
-    if ($lastOperation)
-    {
-      $lastOperation = $lastOperation.ToLower()
-
-      $lines = $lastOperation -split "`r`n"
-
-      $installMatch = $lines | ? { $_.StartsWith("------- installing...newtonsoft.json ") } | select -first 1
-
-      if ($installMatch)
-      {
-        $dte2.ItemOperations.Navigate($url) | Out-Null
-      }
-    }
-  }
-}
-catch
-{
-  try
-  {
-    $pmPane = $dte2.ToolWindows.OutputWindow.OutputWindowPanes.Item("Package Manager")
-
-    $selection = $pmPane.TextDocument.Selection
-    $selection.StartOfDocument($false)
-    $selection.EndOfDocument($true)
-
-    if ($selection.Text.StartsWith("Attempting to gather dependencies information for package 'Newtonsoft.Json." + $package.Version + "'"))
-    {
-      # don't show on upgrade
-      if (!$selection.Text.Contains("Removed package"))
-      {
-        $dte2.ItemOperations.Navigate($url) | Out-Null
-      }
-    }
-  }
-  catch
-  {
-    # stop potential errors from bubbling up
-    # worst case the splash page won't open  
-  }
-}
-
-# still yolo