From 131d9d7f9fff570b398b677cd91491d9df68f27f Mon Sep 17 00:00:00 2001
From: "smallchi(Koike)" <564952747@qq.com>
Date: Wed, 15 Mar 2023 09:04:46 +0800
Subject: [PATCH] =?UTF-8?q?1.=E6=96=B0=E5=A2=9E=E9=BB=98=E8=AE=A4=E8=A7=A3?=
=?UTF-8?q?=E6=9E=90=E5=AE=9E=E4=BE=8B=E6=97=A0DI=E4=BE=9D=E8=B5=96=202.?=
=?UTF-8?q?=E5=B0=86DI=E5=BA=93=E8=BF=81=E7=A7=BB=E5=87=BA=E6=9D=A5=203.?=
=?UTF-8?q?=E6=96=87=E6=A1=A3=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.en.md | 13 +++
README.md | 12 +++
publish.bat | 1 +
src/Info.props | 4 +-
.../JT808.Protocol.Benchmark.csproj | 1 +
.../DefaultDIBuilder.cs | 33 +++++++
.../DependencyInjectionExtensions.cs | 22 +++--
.../IJT808DIBuilder.cs | 20 ++++
.../JT808.Protocol.DependencyInjection.csproj | 29 ++++++
.../JT808.Protocol.DependencyInjection.xml | 85 +++++++++++++++++
...808.Protocol.Extensions.JT1078.Test.csproj | 1 +
.../JT808_0x0200Test.cs | 12 +++
.../DependencyInjectionExtensions.cs | 1 -
.../JT808.Protocol.Extensions.JT1078.xml | 6 ++
.../JT808_JT1078_Constants.cs | 9 ++
...808.Protocol.Extensions.SuBiao.Test.csproj | 1 +
.../JT808_0x0200_0x64_Test.cs | 7 ++
.../DependencyInjectionExtensions.cs | 1 -
.../JT808.Protocol.Extensions.SuBiao.xml | 6 ++
.../JT808_SuBiao_Constants.cs | 9 ++
...08.Protocol.Extensions.YueBiao.Test.csproj | 1 +
.../DependencyInjectionExtensions.cs | 1 -
.../JT808.Protocol.Extensions.YueBiao.xml | 6 ++
.../JT808_YueBiao_Constants.cs | 9 ++
.../JT808.Protocol.Test.csproj | 1 +
.../JT808SerializerTest.cs | 25 -----
src/JT808.Protocol.sln | 7 ++
src/JT808.Protocol/IJT808Builder.cs | 5 -
src/JT808.Protocol/Internal/DefaultBuilder.cs | 9 +-
.../Internal/DefaultGlobalConfig.cs | 3 +-
src/JT808.Protocol/JT808.Protocol.csproj | 5 +-
src/JT808.Protocol/JT808.Protocol.xml | 91 +++----------------
src/JT808.Protocol/JT808Serializer.cs | 81 +++++++----------
33 files changed, 336 insertions(+), 181 deletions(-)
create mode 100644 src/JT808.Protocol.Extensions/JT808.Protocol.DependencyInjection/DefaultDIBuilder.cs
rename src/{JT808.Protocol => JT808.Protocol.Extensions/JT808.Protocol.DependencyInjection}/DependencyInjectionExtensions.cs (67%)
create mode 100644 src/JT808.Protocol.Extensions/JT808.Protocol.DependencyInjection/IJT808DIBuilder.cs
create mode 100644 src/JT808.Protocol.Extensions/JT808.Protocol.DependencyInjection/JT808.Protocol.DependencyInjection.csproj
create mode 100644 src/JT808.Protocol.Extensions/JT808.Protocol.DependencyInjection/JT808.Protocol.DependencyInjection.xml
diff --git a/README.en.md b/README.en.md
index 777f03b..790988c 100644
--- a/README.en.md
+++ b/README.en.md
@@ -382,6 +382,7 @@ Due to access many different equipment vendor's agreement, but each protocol doc
| Install-Package JT808.Protocol.Extensions.JT1078 |  | | |JT1078 extension JT808|
| Install-Package JT808.Protocol.Extensions.SuBiao|  | | |Active Safety (Su Biao) extension JT808|
| Install-Package JT808.Protocol.Extensions.YueBiao|  | | |Active Safety (Yue Biao) extension JT808|
+| Install-Package JT808.Protocol.DependencyInjection|  | | |JT808 DependencyInjection|
## Using BenchmarkDotNet performance test reports (just for fun, not to be taken seriously)
@@ -532,9 +533,13 @@ Platform=AnyCpu Server=False Toolchain=.NET 7.0
## usage
```csharp
+Use DI:
IServiceCollection serviceDescriptors1 = new ServiceCollection();
serviceDescriptors1.AddJT808Configure()
.AddJT1078Configure();
+
+Use Global:
+JT808Serializer.Instance.Register(JT808_JT1078_Constants.GetCurrentAssembly());
```
## Active Security (SuBiao) extended JT808 protocol message comparison table
@@ -564,9 +569,13 @@ serviceDescriptors1.AddJT808Configure()
## usage
```csharp
+Use DI:
IServiceCollection serviceDescriptors1 = new ServiceCollection();
serviceDescriptors1.AddJT808Configure()
.AddSuBiaoConfigure();
+
+Use Global:
+JT808Serializer.Instance.Register(JT808_SuBiao_Constants.GetCurrentAssembly());
```
## Active Security (Yue Biao) extended JT808 protocol message comparison table
@@ -600,7 +609,11 @@ serviceDescriptors1.AddJT808Configure()
## usage
```csharp
+Use DI:
IServiceCollection serviceDescriptors1 = new ServiceCollection();
serviceDescriptors1.AddJT808Configure()
.AddYueBiaoConfigure();
+
+Use Global:
+JT808Serializer.Instance.Register(JT808_YueBiao_Constants.GetCurrentAssembly());
```
diff --git a/README.md b/README.md
index 23822b3..57d8167 100644
--- a/README.md
+++ b/README.md
@@ -382,6 +382,7 @@ JT808Serializer DT2JT808Serializer = new JT808Serializer(DT2JT808Config);
| Install-Package JT808.Protocol.Extensions.JT1078 |  | | |JT1078扩展JT808|
| Install-Package JT808.Protocol.Extensions.SuBiao|  | | |主动安全(苏标)扩展JT808|
| Install-Package JT808.Protocol.Extensions.YueBiao|  | | |主动安全(粤标)扩展JT808|
+| Install-Package JT808.Protocol.DependencyInjection|  | | |JT808依赖注入扩展|
## 使用BenchmarkDotNet性能测试报告(只是玩玩,不能当真)
@@ -532,9 +533,12 @@ Platform=AnyCpu Server=False Toolchain=.NET 7.0
## 使用方法
```csharp
+DI:
IServiceCollection serviceDescriptors1 = new ServiceCollection();
serviceDescriptors1.AddJT808Configure()
.AddJT1078Configure();
+全局注册:
+JT808Serializer.Instance.Register(JT808_JT1078_Constants.GetCurrentAssembly());
```
## 主动安全(苏标)扩展JT808协议消息对照表
@@ -564,9 +568,13 @@ serviceDescriptors1.AddJT808Configure()
## 使用方法
```csharp
+DI:
IServiceCollection serviceDescriptors1 = new ServiceCollection();
serviceDescriptors1.AddJT808Configure()
.AddSuBiaoConfigure();
+
+全局注册:
+JT808Serializer.Instance.Register(JT808_SuBiao_Constants.GetCurrentAssembly());
```
## 主动安全(粤标)扩展JT808协议消息对照表
@@ -600,7 +608,11 @@ serviceDescriptors1.AddJT808Configure()
## 使用方法
```csharp
+DI:
IServiceCollection serviceDescriptors1 = new ServiceCollection();
serviceDescriptors1.AddJT808Configure()
.AddYueBiaoConfigure();
+
+全局注册:
+JT808Serializer.Instance.Register(JT808_YueBiao_Constants.GetCurrentAssembly());
```
diff --git a/publish.bat b/publish.bat
index 0900f92..f7acbb4 100644
--- a/publish.bat
+++ b/publish.bat
@@ -1,4 +1,5 @@
dotnet pack .\src\JT808.Protocol\JT808.Protocol.csproj -c Release --output nupkgs
+dotnet pack .\src\JT808.Protocol.Extensions\JT808.Protocol.DependencyInjection\JT808.Protocol.DependencyInjection.csproj -c Release --output nupkgs
dotnet pack .\src\JT808.Protocol.Extensions\JT808.Protocol.Extensions.JT1078\JT808.Protocol.Extensions.JT1078.csproj -c Release --output nupkgs
dotnet pack .\src\JT808.Protocol.Extensions\JT808.Protocol.Extensions.SuBiao\JT808.Protocol.Extensions.SuBiao.csproj -c Release --output nupkgs
dotnet pack .\src\JT808.Protocol.Extensions\JT808.Protocol.Extensions.YueBiao\JT808.Protocol.Extensions.YueBiao.csproj -c Release --output nupkgs
diff --git a/src/Info.props b/src/Info.props
index 553e32e..690881d 100644
--- a/src/Info.props
+++ b/src/Info.props
@@ -1,6 +1,6 @@
- net7.0;
+ net7.0;
11.0
Copyright 2018.
SmallChi(Koike)
@@ -8,7 +8,7 @@
https://github.com/SmallChi/JT808
https://github.com/SmallChi/JT808/blob/master/LICENSE
https://github.com/SmallChi/JT808/blob/master/LICENSE
- 2.6.0
+ 2.6.1
enable
LICENSE
true
diff --git a/src/JT808.Protocol.Benchmark/JT808.Protocol.Benchmark.csproj b/src/JT808.Protocol.Benchmark/JT808.Protocol.Benchmark.csproj
index 43a4fad..06418bc 100644
--- a/src/JT808.Protocol.Benchmark/JT808.Protocol.Benchmark.csproj
+++ b/src/JT808.Protocol.Benchmark/JT808.Protocol.Benchmark.csproj
@@ -21,6 +21,7 @@
+
diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.DependencyInjection/DefaultDIBuilder.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.DependencyInjection/DefaultDIBuilder.cs
new file mode 100644
index 0000000..ad06e46
--- /dev/null
+++ b/src/JT808.Protocol.Extensions/JT808.Protocol.DependencyInjection/DefaultDIBuilder.cs
@@ -0,0 +1,33 @@
+using JT808.Protocol.Interfaces;
+using Microsoft.Extensions.DependencyInjection;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace JT808.Protocol.DependencyInjection
+{
+ ///
+ /// 默认JT808构造器
+ ///
+ class DefaultDIBuilder : IJT808DIBuilder
+ {
+ ///
+ /// JT808配置
+ ///
+ public IJT808Config Config { get; }
+ ///
+ /// DI ServiceCollection
+ ///
+ public IServiceCollection Services { get; }
+ ///
+ ///
+ ///
+ ///
+ ///
+ public DefaultDIBuilder(IServiceCollection services,IJT808Config config)
+ {
+ Config = config;
+ Services = services;
+ }
+ }
+}
diff --git a/src/JT808.Protocol/DependencyInjectionExtensions.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.DependencyInjection/DependencyInjectionExtensions.cs
similarity index 67%
rename from src/JT808.Protocol/DependencyInjectionExtensions.cs
rename to src/JT808.Protocol.Extensions/JT808.Protocol.DependencyInjection/DependencyInjectionExtensions.cs
index 2c21686..6f6925f 100644
--- a/src/JT808.Protocol/DependencyInjectionExtensions.cs
+++ b/src/JT808.Protocol.Extensions/JT808.Protocol.DependencyInjection/DependencyInjectionExtensions.cs
@@ -1,4 +1,5 @@
-using JT808.Protocol.Interfaces;
+using JT808.Protocol.DependencyInjection;
+using JT808.Protocol.Interfaces;
using JT808.Protocol.Internal;
using Microsoft.Extensions.DependencyInjection;
using System;
@@ -8,7 +9,8 @@ using System.Text;
namespace JT808.Protocol
{
///
- /// DI扩展
+ /// JT808 DI扩展
+ /// JT808 DependencyInjectionExtensions
///
public static class DependencyInjectionExtensions
{
@@ -18,10 +20,10 @@ namespace JT808.Protocol
///
///
///
- public static IJT808Builder AddJT808Configure(this IServiceCollection services, IJT808Config jT808Config)
+ public static IJT808DIBuilder AddJT808Configure(this IServiceCollection services, IJT808Config jT808Config)
{
services.AddSingleton(jT808Config.GetType(), jT808Config);
- return new DefaultBuilder(services, jT808Config);
+ return new DefaultDIBuilder(services,jT808Config);
}
///
/// 注册808配置
@@ -29,7 +31,7 @@ namespace JT808.Protocol
///
///
///
- public static IJT808Builder AddJT808Configure(this IJT808Builder builder, IJT808Config jT808Config)
+ public static IJT808DIBuilder AddJT808Configure(this IJT808DIBuilder builder, IJT808Config jT808Config)
{
builder.Services.AddSingleton(jT808Config.GetType(), jT808Config);
return builder;
@@ -40,11 +42,11 @@ namespace JT808.Protocol
///
///
///
- public static IJT808Builder AddJT808Configure(this IServiceCollection services)where TJT808Config : IJT808Config,new()
+ public static IJT808DIBuilder AddJT808Configure(this IServiceCollection services)where TJT808Config : IJT808Config,new()
{
var config = new TJT808Config();
services.AddSingleton(typeof(TJT808Config), config);
- return new DefaultBuilder(services, config);
+ return new DefaultDIBuilder(services, config);
}
///
/// 注册808配置
@@ -52,7 +54,7 @@ namespace JT808.Protocol
///
///
///
- public static IJT808Builder AddJT808Configure(this IJT808Builder builder) where TJT808Config : IJT808Config, new()
+ public static IJT808DIBuilder AddJT808Configure(this IJT808DIBuilder builder) where TJT808Config : IJT808Config, new()
{
var config = new TJT808Config();
builder.Services.AddSingleton(typeof(TJT808Config), config);
@@ -63,11 +65,11 @@ namespace JT808.Protocol
///
///
///
- public static IJT808Builder AddJT808Configure(this IServiceCollection services)
+ public static IJT808DIBuilder AddJT808Configure(this IServiceCollection services)
{
DefaultGlobalConfig config = new DefaultGlobalConfig();
services.AddSingleton(config);
- return new DefaultBuilder(services, config);
+ return new DefaultDIBuilder(services,config);
}
}
}
diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.DependencyInjection/IJT808DIBuilder.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.DependencyInjection/IJT808DIBuilder.cs
new file mode 100644
index 0000000..acdc45e
--- /dev/null
+++ b/src/JT808.Protocol.Extensions/JT808.Protocol.DependencyInjection/IJT808DIBuilder.cs
@@ -0,0 +1,20 @@
+using Microsoft.Extensions.DependencyInjection;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JT808.Protocol.DependencyInjection
+{
+ ///
+ /// JT808 DI Builder
+ ///
+ public interface IJT808DIBuilder: IJT808Builder
+ {
+ ///
+ /// 服务注册
+ ///
+ IServiceCollection Services { get; }
+ }
+}
diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.DependencyInjection/JT808.Protocol.DependencyInjection.csproj b/src/JT808.Protocol.Extensions/JT808.Protocol.DependencyInjection/JT808.Protocol.DependencyInjection.csproj
new file mode 100644
index 0000000..331d610
--- /dev/null
+++ b/src/JT808.Protocol.Extensions/JT808.Protocol.DependencyInjection/JT808.Protocol.DependencyInjection.csproj
@@ -0,0 +1,29 @@
+
+
+
+ JT808.Protocol.DependencyInjection
+ JT808.Protocol.DependencyInjection
+
+ JT808.Protocol.DependencyInjection.
+
+
+ JT808.Protocol.DependencyInjection.
+
+ JT808.Protocol.DependencyInjection.xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.DependencyInjection/JT808.Protocol.DependencyInjection.xml b/src/JT808.Protocol.Extensions/JT808.Protocol.DependencyInjection/JT808.Protocol.DependencyInjection.xml
new file mode 100644
index 0000000..564b0a7
--- /dev/null
+++ b/src/JT808.Protocol.Extensions/JT808.Protocol.DependencyInjection/JT808.Protocol.DependencyInjection.xml
@@ -0,0 +1,85 @@
+
+
+
+ JT808.Protocol.DependencyInjection
+
+
+
+
+ 默认JT808构造器
+
+
+
+
+ JT808配置
+
+
+
+
+ DI ServiceCollection
+
+
+
+
+
+
+
+
+
+
+
+ JT808 DI Builder
+
+
+
+
+ 服务注册
+
+
+
+
+ JT808 DI扩展
+ JT808 DependencyInjectionExtensions
+
+
+
+
+ 注册808配置
+
+
+
+
+
+
+
+ 注册808配置
+
+
+
+
+
+
+
+ 注册808配置
+
+
+
+
+
+
+
+ 注册808配置
+
+
+
+
+
+
+
+ 注册808配置
+
+
+
+
+
+
diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808.Protocol.Extensions.JT1078.Test.csproj b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808.Protocol.Extensions.JT1078.Test.csproj
index fb0f6b0..b51e5b8 100644
--- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808.Protocol.Extensions.JT1078.Test.csproj
+++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808.Protocol.Extensions.JT1078.Test.csproj
@@ -16,6 +16,7 @@
+
diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x0200Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x0200Test.cs
index 5e73d5a..4b1d65a 100644
--- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x0200Test.cs
+++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x0200Test.cs
@@ -6,6 +6,7 @@ using System;
using System.Collections.Generic;
using System.Text;
using Xunit;
+using System.Reflection;
namespace JT808.Protocol.Extensions.JT1078.Test
{
@@ -121,5 +122,16 @@ namespace JT808.Protocol.Extensions.JT1078.Test
byte[] bodys = "7e020040420100000000013419905507021200040000001410010213679206c4a97d01001300000002220720103957010400000e3e020200000302025825040000001030014531010814040000000115040000000c797e".ToHexBytes();
string json = JT808Serializer.Analyze(bodys);
}
+
+ ///
+ ///
+ ///
+ [Fact]
+ public void Test_0x15_5()
+ {
+ JT808Serializer.Instance.Register(JT808_JT1078_Constants.GetCurrentAssembly());
+ byte[] bodys = "7e020040420100000000013419905507021200040000001410010213679206c4a97d01001300000002220720103957010400000e3e020200000302025825040000001030014531010814040000000115040000000c797e".ToHexBytes();
+ string json = JT808Serializer.Instance.Analyze(bodys);
+ }
}
}
diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/DependencyInjectionExtensions.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/DependencyInjectionExtensions.cs
index 9c8ac88..70ec629 100644
--- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/DependencyInjectionExtensions.cs
+++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/DependencyInjectionExtensions.cs
@@ -1,7 +1,6 @@
using JT808.Protocol.Extensions.JT1078.Enums;
using JT808.Protocol.Extensions.JT1078.MessageBody;
using JT808.Protocol.Interfaces;
-using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Reflection;
diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/JT808.Protocol.Extensions.JT1078.xml b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/JT808.Protocol.Extensions.JT1078.xml
index 8d5ee25..a7d9bc7 100644
--- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/JT808.Protocol.Extensions.JT1078.xml
+++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/JT808.Protocol.Extensions.JT1078.xml
@@ -262,6 +262,12 @@
Wake up in hibernation mode
+
+
+
+
+
+
视频相关报警
diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/JT808_JT1078_Constants.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/JT808_JT1078_Constants.cs
index bfc473c..079943b 100644
--- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/JT808_JT1078_Constants.cs
+++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/JT808_JT1078_Constants.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Reflection;
using System.Text;
namespace JT808.Protocol.Extensions.JT1078
@@ -69,5 +70,13 @@ namespace JT808.Protocol.Extensions.JT1078
/// Wake up in hibernation mode
///
public const uint JT808_0X8103_0x007C = 0x007C;
+ ///
+ ///
+ ///
+ ///
+ public static Assembly GetCurrentAssembly()
+ {
+ return Assembly.GetExecutingAssembly();
+ }
}
}
diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao.Test/JT808.Protocol.Extensions.SuBiao.Test.csproj b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao.Test/JT808.Protocol.Extensions.SuBiao.Test.csproj
index 94a138b..7962b76 100644
--- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao.Test/JT808.Protocol.Extensions.SuBiao.Test.csproj
+++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao.Test/JT808.Protocol.Extensions.SuBiao.Test.csproj
@@ -17,6 +17,7 @@
+
diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao.Test/JT808_0x0200_0x64_Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao.Test/JT808_0x0200_0x64_Test.cs
index b7c3489..2f1dbe6 100644
--- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao.Test/JT808_0x0200_0x64_Test.cs
+++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao.Test/JT808_0x0200_0x64_Test.cs
@@ -96,5 +96,12 @@ namespace JT808.Protocol.Extensions.SuBiao.Test
{
var json = JT808Serializer.Analyze("000000010000000200BA7F0E07E4F11C0028003C00001807151010106420000000010C0605120A0B100F1100070000000D0000000E191211183100001334343434343434191210183100030200".ToHexBytes());
}
+
+ [Fact]
+ public void Deserialize2()
+ {
+ JT808Serializer.Instance.Register(JT808_SuBiao_Constants.GetCurrentAssembly());
+ var json = JT808Serializer.Instance.Analyze("000000010000000200BA7F0E07E4F11C0028003C00001807151010106420000000010C0605120A0B100F1100070000000D0000000E191211183100001334343434343434191210183100030200".ToHexBytes());
+ }
}
}
diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao/DependencyInjectionExtensions.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao/DependencyInjectionExtensions.cs
index 14f5392..18d4c16 100644
--- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao/DependencyInjectionExtensions.cs
+++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao/DependencyInjectionExtensions.cs
@@ -1,7 +1,6 @@
using JT808.Protocol.Extensions.SuBiao.Enums;
using JT808.Protocol.Extensions.SuBiao.MessageBody;
using JT808.Protocol.Interfaces;
-using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Reflection;
diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao/JT808.Protocol.Extensions.SuBiao.xml b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao/JT808.Protocol.Extensions.SuBiao.xml
index 9a2f40e..0cc9ee1 100644
--- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao/JT808.Protocol.Extensions.SuBiao.xml
+++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao/JT808.Protocol.Extensions.SuBiao.xml
@@ -298,6 +298,12 @@
信息查询
+
+
+
+
+
+
高级驾驶辅助系统报警信息
diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao/JT808_SuBiao_Constants.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao/JT808_SuBiao_Constants.cs
index a66350d..d10b6ec 100644
--- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao/JT808_SuBiao_Constants.cs
+++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao/JT808_SuBiao_Constants.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Reflection;
using System.Text;
namespace JT808.Protocol.Extensions.SuBiao
@@ -49,5 +50,13 @@ namespace JT808.Protocol.Extensions.SuBiao
/// 信息查询
///
public const byte JT808_0X0900_0xF8 = 0xF8;
+ ///
+ ///
+ ///
+ ///
+ public static Assembly GetCurrentAssembly()
+ {
+ return Assembly.GetExecutingAssembly();
+ }
}
}
diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao.Test/JT808.Protocol.Extensions.YueBiao.Test.csproj b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao.Test/JT808.Protocol.Extensions.YueBiao.Test.csproj
index b47847b..586e9af 100644
--- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao.Test/JT808.Protocol.Extensions.YueBiao.Test.csproj
+++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao.Test/JT808.Protocol.Extensions.YueBiao.Test.csproj
@@ -21,6 +21,7 @@
+
diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/DependencyInjectionExtensions.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/DependencyInjectionExtensions.cs
index 919f2ec..3efc414 100644
--- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/DependencyInjectionExtensions.cs
+++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/DependencyInjectionExtensions.cs
@@ -1,5 +1,4 @@
using JT808.Protocol.Interfaces;
-using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Reflection;
diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/JT808.Protocol.Extensions.YueBiao.xml b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/JT808.Protocol.Extensions.YueBiao.xml
index 2030c04..ea85acb 100644
--- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/JT808.Protocol.Extensions.YueBiao.xml
+++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/JT808.Protocol.Extensions.YueBiao.xml
@@ -387,6 +387,12 @@
信息查询
+
+
+
+
+
+
高级驾驶辅助系统报警信息
diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/JT808_YueBiao_Constants.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/JT808_YueBiao_Constants.cs
index 518f3c2..9775018 100644
--- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/JT808_YueBiao_Constants.cs
+++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/JT808_YueBiao_Constants.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Reflection;
using System.Text;
namespace JT808.Protocol.Extensions.YueBiao
@@ -62,5 +63,13 @@ namespace JT808.Protocol.Extensions.YueBiao
/// 信息查询
///
public const byte JT808_0X0900_0xF8 = 0xF8;
+ ///
+ ///
+ ///
+ ///
+ public static Assembly GetCurrentAssembly()
+ {
+ return Assembly.GetExecutingAssembly();
+ }
}
}
diff --git a/src/JT808.Protocol.Test/JT808.Protocol.Test.csproj b/src/JT808.Protocol.Test/JT808.Protocol.Test.csproj
index 7bf89dc..9282414 100644
--- a/src/JT808.Protocol.Test/JT808.Protocol.Test.csproj
+++ b/src/JT808.Protocol.Test/JT808.Protocol.Test.csproj
@@ -126,6 +126,7 @@
+
diff --git a/src/JT808.Protocol.Test/JT808SerializerTest.cs b/src/JT808.Protocol.Test/JT808SerializerTest.cs
index 1c35b09..ed574bb 100644
--- a/src/JT808.Protocol.Test/JT808SerializerTest.cs
+++ b/src/JT808.Protocol.Test/JT808SerializerTest.cs
@@ -29,31 +29,6 @@ namespace JT808.Protocol.Test
}
}
- [Fact]
- public void ReadOnlySpanTest1()
- {
- IJT808Config jT808Config = new DefaultGlobalConfig();
- JT808Serializer jT808Serializer = new JT808Serializer(jT808Config);
- JT808Package jT808Package = new JT808Package
- {
- Header = new JT808Header
- {
- MsgId = Enums.JT808MsgId._0x0001.ToUInt16Value(),
- MsgNum = 1203,
- TerminalPhoneNo = "012345678900",
- MessageBodyProperty=new JT808HeaderMessageBodyProperty()
- },
- Bodies = new JT808_0x0001
- {
- ReplyMsgId = Enums.JT808MsgId._0x0002.ToUInt16Value(),
- ReplyMsgNum = 1000,
- TerminalResult = Enums.JT808TerminalResult.Success
- }
- };
- var hexSpan = jT808Serializer.SerializeReadOnlySpan(jT808Package);
- Assert.Equal(0x7e, hexSpan[0]);
- }
-
[Fact]
public unsafe void DefaultGlobalConfigTest1()
{
diff --git a/src/JT808.Protocol.sln b/src/JT808.Protocol.sln
index acd871a..e6b51a6 100644
--- a/src/JT808.Protocol.sln
+++ b/src/JT808.Protocol.sln
@@ -33,6 +33,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Protocol.Extensions.S
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Protocol.Extensions.SuBiao.Test", "JT808.Protocol.Extensions\JT808.Protocol.Extensions.SuBiao.Test\JT808.Protocol.Extensions.SuBiao.Test.csproj", "{BEE2E12D-C123-4682-AB7E-210C2BF564B3}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JT808.Protocol.DependencyInjection", "JT808.Protocol.Extensions\JT808.Protocol.DependencyInjection\JT808.Protocol.DependencyInjection.csproj", "{7EB01F74-DFDB-4733-8F15-5785A9ED7DBD}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -75,6 +77,10 @@ Global
{BEE2E12D-C123-4682-AB7E-210C2BF564B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BEE2E12D-C123-4682-AB7E-210C2BF564B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BEE2E12D-C123-4682-AB7E-210C2BF564B3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {7EB01F74-DFDB-4733-8F15-5785A9ED7DBD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7EB01F74-DFDB-4733-8F15-5785A9ED7DBD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7EB01F74-DFDB-4733-8F15-5785A9ED7DBD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7EB01F74-DFDB-4733-8F15-5785A9ED7DBD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -86,6 +92,7 @@ Global
{4984E375-4B55-4188-A94E-844B694BBA5C} = {3A0EEA9A-9667-4386-BB46-4A9CB319CE30}
{001ECBA0-CF17-40B0-B983-B7AE824B8050} = {3A0EEA9A-9667-4386-BB46-4A9CB319CE30}
{BEE2E12D-C123-4682-AB7E-210C2BF564B3} = {3A0EEA9A-9667-4386-BB46-4A9CB319CE30}
+ {7EB01F74-DFDB-4733-8F15-5785A9ED7DBD} = {3A0EEA9A-9667-4386-BB46-4A9CB319CE30}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D58CCAA8-ED94-4048-A6DE-55A84814DF17}
diff --git a/src/JT808.Protocol/IJT808Builder.cs b/src/JT808.Protocol/IJT808Builder.cs
index 5846031..06d779d 100644
--- a/src/JT808.Protocol/IJT808Builder.cs
+++ b/src/JT808.Protocol/IJT808Builder.cs
@@ -1,5 +1,4 @@
using JT808.Protocol.Interfaces;
-using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Text;
@@ -15,9 +14,5 @@ namespace JT808.Protocol
/// JT808配置
///
IJT808Config Config { get; }
- ///
- /// 服务注册
- ///
- IServiceCollection Services { get; }
}
}
diff --git a/src/JT808.Protocol/Internal/DefaultBuilder.cs b/src/JT808.Protocol/Internal/DefaultBuilder.cs
index 2205cae..0a8c38f 100644
--- a/src/JT808.Protocol/Internal/DefaultBuilder.cs
+++ b/src/JT808.Protocol/Internal/DefaultBuilder.cs
@@ -1,5 +1,4 @@
using JT808.Protocol.Interfaces;
-using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Text;
@@ -11,10 +10,6 @@ namespace JT808.Protocol.Internal
///
class DefaultBuilder : IJT808Builder
{
- ///
- /// DI服务
- ///
- public IServiceCollection Services { get; }
///
/// JT808配置
///
@@ -22,11 +17,9 @@ namespace JT808.Protocol.Internal
///
///
///
- ///
///
- public DefaultBuilder(IServiceCollection services, IJT808Config config)
+ public DefaultBuilder(IJT808Config config)
{
- Services = services;
Config = config;
}
}
diff --git a/src/JT808.Protocol/Internal/DefaultGlobalConfig.cs b/src/JT808.Protocol/Internal/DefaultGlobalConfig.cs
index 8a072fb..bb52c32 100644
--- a/src/JT808.Protocol/Internal/DefaultGlobalConfig.cs
+++ b/src/JT808.Protocol/Internal/DefaultGlobalConfig.cs
@@ -1,10 +1,11 @@
using JT808.Protocol.Interfaces;
+using System.Runtime.CompilerServices;
namespace JT808.Protocol.Internal
{
///
/// 默认全局配置
- ///
+ ///
class DefaultGlobalConfig : GlobalConfigBase
{
///
diff --git a/src/JT808.Protocol/JT808.Protocol.csproj b/src/JT808.Protocol/JT808.Protocol.csproj
index 85d5407..92c91c1 100644
--- a/src/JT808.Protocol/JT808.Protocol.csproj
+++ b/src/JT808.Protocol/JT808.Protocol.csproj
@@ -27,6 +27,7 @@
+
@@ -40,12 +41,10 @@
-
+
-
-
TextTemplatingFileGenerator
diff --git a/src/JT808.Protocol/JT808.Protocol.xml b/src/JT808.Protocol/JT808.Protocol.xml
index 902c6ed..ac88296 100644
--- a/src/JT808.Protocol/JT808.Protocol.xml
+++ b/src/JT808.Protocol/JT808.Protocol.xml
@@ -15,50 +15,6 @@
编码之前的写入位置
-
-
- DI扩展
-
-
-
-
- 注册808配置
-
-
-
-
-
-
-
- 注册808配置
-
-
-
-
-
-
-
- 注册808配置
-
-
-
-
-
-
-
- 注册808配置
-
-
-
-
-
-
-
- 注册808配置
-
-
-
-
报警标志
@@ -4278,11 +4234,6 @@
JT808配置
-
-
- 服务注册
-
-
全局配置基类
@@ -4928,27 +4879,21 @@
默认JT808构造器
-
-
- DI服务
-
-
JT808配置
-
+
-
默认全局配置
-
+
@@ -6150,6 +6095,12 @@
JT808序列化器
+
+
+ 默认实例
+ default instance
+
+
@@ -6175,15 +6126,6 @@
-
-
-
-
-
-
-
-
-
@@ -6203,16 +6145,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -6314,6 +6246,13 @@
+
+
+ 外部注册
+
+
+
+
采集记录仪执行标准版本
diff --git a/src/JT808.Protocol/JT808Serializer.cs b/src/JT808.Protocol/JT808Serializer.cs
index c80413e..e901354 100644
--- a/src/JT808.Protocol/JT808Serializer.cs
+++ b/src/JT808.Protocol/JT808Serializer.cs
@@ -1,14 +1,14 @@
using JT808.Protocol.Enums;
using JT808.Protocol.Extensions;
using JT808.Protocol.Formatters;
-using JT808.Protocol.Interfaces;
using JT808.Protocol.Internal;
using JT808.Protocol.MessagePack;
-using System;
-using System.IO;
+using System.Reflection;
+using System.Runtime.CompilerServices;
using System.Text;
using System.Text.Json;
+[assembly: InternalsVisibleTo("JT808.Protocol.DependencyInjection")]
namespace JT808.Protocol
{
///
@@ -22,6 +22,17 @@ namespace JT808.Protocol
private readonly static Type JT808_Package_Type = typeof(JT808Package);
+ ///
+ /// 默认实例
+ /// default instance
+ ///
+ public readonly static JT808Serializer Instance;
+
+ static JT808Serializer()
+ {
+ Instance= new JT808Serializer();
+ }
+
///
///
///
@@ -30,6 +41,7 @@ namespace JT808.Protocol
{
this.jT808Config = jT808Config;
}
+
///
///
///
@@ -68,27 +80,6 @@ namespace JT808.Protocol
///
///
///
- ///
- ///
- ///
- ///
- public ReadOnlySpan SerializeReadOnlySpan(JT808Package package, JT808Version version = JT808Version.JTT2013, int minBufferSize = 4096)
- {
- byte[] buffer = JT808ArrayPool.Rent(minBufferSize);
- try
- {
- JT808MessagePackWriter jT808MessagePackWriter = new JT808MessagePackWriter(buffer, version);
- package.Serialize(ref jT808MessagePackWriter, package, jT808Config);
- return jT808MessagePackWriter.FlushAndGetEncodingReadOnlySpan();
- }
- finally
- {
- JT808ArrayPool.Return(buffer);
- }
- }
- ///
- ///
- ///
///
///
///
@@ -134,29 +125,6 @@ namespace JT808.Protocol
///
///
///
- ///
- ///
- ///
- ///
- public ReadOnlySpan SerializeReadOnlySpan(T obj, JT808Version version = JT808Version.JTT2013, int minBufferSize = 4096)
- {
- byte[] buffer = JT808ArrayPool.Rent(minBufferSize);
- try
- {
- var formatter = jT808Config.GetMessagePackFormatter();
- JT808MessagePackWriter jT808MessagePackWriter = new JT808MessagePackWriter(buffer, version);
- formatter.Serialize(ref jT808MessagePackWriter, obj, jT808Config);
- return jT808MessagePackWriter.FlushAndGetEncodingReadOnlySpan();
- }
- finally
- {
- JT808ArrayPool.Return(buffer);
- }
- }
- ///
- ///
- ///
- ///
///
///
///
@@ -217,7 +185,7 @@ namespace JT808.Protocol
///
///
///
- public dynamic Deserialize(ReadOnlySpan bytes, Type type, JT808Version version = JT808Version.JTT2013, int minBufferSize = 4096)
+ public object Deserialize(ReadOnlySpan bytes, Type type, JT808Version version = JT808Version.JTT2013, int minBufferSize = 4096)
{
byte[] buffer = JT808ArrayPool.Rent(minBufferSize);
try
@@ -424,5 +392,22 @@ namespace JT808.Protocol
JT808ArrayPool.Return(buffer);
}
}
+
+ ///
+ /// 外部注册
+ ///
+ ///
+ ///
+ public JT808Serializer Register(params Assembly[] externalAssemblies)
+ {
+ if(externalAssemblies!=null && externalAssemblies.Length > 0)
+ {
+ foreach(var asm in externalAssemblies)
+ {
+ jT808Config.Register(asm);
+ }
+ }
+ return this;
+ }
}
}