@@ -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.JT1078 |  | | |JT1078 extension JT808| | ||||
| Install-Package JT808.Protocol.Extensions.SuBiao|  | | |Active Safety (Su Biao) 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.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) | ## 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 | ## usage | ||||
```csharp | ```csharp | ||||
Use DI: | |||||
IServiceCollection serviceDescriptors1 = new ServiceCollection(); | IServiceCollection serviceDescriptors1 = new ServiceCollection(); | ||||
serviceDescriptors1.AddJT808Configure() | serviceDescriptors1.AddJT808Configure() | ||||
.AddJT1078Configure(); | .AddJT1078Configure(); | ||||
Use Global: | |||||
JT808Serializer.Instance.Register(JT808_JT1078_Constants.GetCurrentAssembly()); | |||||
``` | ``` | ||||
## Active Security (SuBiao) extended JT808 protocol message comparison table | ## Active Security (SuBiao) extended JT808 protocol message comparison table | ||||
@@ -564,9 +569,13 @@ serviceDescriptors1.AddJT808Configure() | |||||
## usage | ## usage | ||||
```csharp | ```csharp | ||||
Use DI: | |||||
IServiceCollection serviceDescriptors1 = new ServiceCollection(); | IServiceCollection serviceDescriptors1 = new ServiceCollection(); | ||||
serviceDescriptors1.AddJT808Configure() | serviceDescriptors1.AddJT808Configure() | ||||
.AddSuBiaoConfigure(); | .AddSuBiaoConfigure(); | ||||
Use Global: | |||||
JT808Serializer.Instance.Register(JT808_SuBiao_Constants.GetCurrentAssembly()); | |||||
``` | ``` | ||||
## Active Security (Yue Biao) extended JT808 protocol message comparison table | ## Active Security (Yue Biao) extended JT808 protocol message comparison table | ||||
@@ -600,7 +609,11 @@ serviceDescriptors1.AddJT808Configure() | |||||
## usage | ## usage | ||||
```csharp | ```csharp | ||||
Use DI: | |||||
IServiceCollection serviceDescriptors1 = new ServiceCollection(); | IServiceCollection serviceDescriptors1 = new ServiceCollection(); | ||||
serviceDescriptors1.AddJT808Configure() | serviceDescriptors1.AddJT808Configure() | ||||
.AddYueBiaoConfigure(); | .AddYueBiaoConfigure(); | ||||
Use Global: | |||||
JT808Serializer.Instance.Register(JT808_YueBiao_Constants.GetCurrentAssembly()); | |||||
``` | ``` |
@@ -382,6 +382,7 @@ JT808Serializer DT2JT808Serializer = new JT808Serializer(DT2JT808Config); | |||||
| Install-Package JT808.Protocol.Extensions.JT1078 |  | | |JT1078扩展JT808| | | Install-Package JT808.Protocol.Extensions.JT1078 |  | | |JT1078扩展JT808| | ||||
| Install-Package JT808.Protocol.Extensions.SuBiao|  | | |主动安全(苏标)扩展JT808| | | Install-Package JT808.Protocol.Extensions.SuBiao|  | | |主动安全(苏标)扩展JT808| | ||||
| Install-Package JT808.Protocol.Extensions.YueBiao|  | | |主动安全(粤标)扩展JT808| | | Install-Package JT808.Protocol.Extensions.YueBiao|  | | |主动安全(粤标)扩展JT808| | ||||
| Install-Package JT808.Protocol.DependencyInjection|  | | |JT808依赖注入扩展| | |||||
## 使用BenchmarkDotNet性能测试报告(只是玩玩,不能当真) | ## 使用BenchmarkDotNet性能测试报告(只是玩玩,不能当真) | ||||
@@ -532,9 +533,12 @@ Platform=AnyCpu Server=False Toolchain=.NET 7.0 | |||||
## 使用方法 | ## 使用方法 | ||||
```csharp | ```csharp | ||||
DI: | |||||
IServiceCollection serviceDescriptors1 = new ServiceCollection(); | IServiceCollection serviceDescriptors1 = new ServiceCollection(); | ||||
serviceDescriptors1.AddJT808Configure() | serviceDescriptors1.AddJT808Configure() | ||||
.AddJT1078Configure(); | .AddJT1078Configure(); | ||||
全局注册: | |||||
JT808Serializer.Instance.Register(JT808_JT1078_Constants.GetCurrentAssembly()); | |||||
``` | ``` | ||||
## 主动安全(苏标)扩展JT808协议消息对照表 | ## 主动安全(苏标)扩展JT808协议消息对照表 | ||||
@@ -564,9 +568,13 @@ serviceDescriptors1.AddJT808Configure() | |||||
## 使用方法 | ## 使用方法 | ||||
```csharp | ```csharp | ||||
DI: | |||||
IServiceCollection serviceDescriptors1 = new ServiceCollection(); | IServiceCollection serviceDescriptors1 = new ServiceCollection(); | ||||
serviceDescriptors1.AddJT808Configure() | serviceDescriptors1.AddJT808Configure() | ||||
.AddSuBiaoConfigure(); | .AddSuBiaoConfigure(); | ||||
全局注册: | |||||
JT808Serializer.Instance.Register(JT808_SuBiao_Constants.GetCurrentAssembly()); | |||||
``` | ``` | ||||
## 主动安全(粤标)扩展JT808协议消息对照表 | ## 主动安全(粤标)扩展JT808协议消息对照表 | ||||
@@ -600,7 +608,11 @@ serviceDescriptors1.AddJT808Configure() | |||||
## 使用方法 | ## 使用方法 | ||||
```csharp | ```csharp | ||||
DI: | |||||
IServiceCollection serviceDescriptors1 = new ServiceCollection(); | IServiceCollection serviceDescriptors1 = new ServiceCollection(); | ||||
serviceDescriptors1.AddJT808Configure() | serviceDescriptors1.AddJT808Configure() | ||||
.AddYueBiaoConfigure(); | .AddYueBiaoConfigure(); | ||||
全局注册: | |||||
JT808Serializer.Instance.Register(JT808_YueBiao_Constants.GetCurrentAssembly()); | |||||
``` | ``` |
@@ -1,4 +1,5 @@ | |||||
dotnet pack .\src\JT808.Protocol\JT808.Protocol.csproj -c Release --output nupkgs | 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.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.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 | dotnet pack .\src\JT808.Protocol.Extensions\JT808.Protocol.Extensions.YueBiao\JT808.Protocol.Extensions.YueBiao.csproj -c Release --output nupkgs | ||||
@@ -1,6 +1,6 @@ | |||||
<Project> | <Project> | ||||
<PropertyGroup> | <PropertyGroup> | ||||
<TargetFrameworks>net7.0;</TargetFrameworks> | |||||
<TargetFrameworks>net7.0;</TargetFrameworks> | |||||
<LangVersion>11.0</LangVersion> | <LangVersion>11.0</LangVersion> | ||||
<Copyright>Copyright 2018.</Copyright> | <Copyright>Copyright 2018.</Copyright> | ||||
<Authors>SmallChi(Koike)</Authors> | <Authors>SmallChi(Koike)</Authors> | ||||
@@ -8,7 +8,7 @@ | |||||
<PackageProjectUrl>https://github.com/SmallChi/JT808</PackageProjectUrl> | <PackageProjectUrl>https://github.com/SmallChi/JT808</PackageProjectUrl> | ||||
<licenseUrl>https://github.com/SmallChi/JT808/blob/master/LICENSE</licenseUrl> | <licenseUrl>https://github.com/SmallChi/JT808/blob/master/LICENSE</licenseUrl> | ||||
<license>https://github.com/SmallChi/JT808/blob/master/LICENSE</license> | <license>https://github.com/SmallChi/JT808/blob/master/LICENSE</license> | ||||
<Version>2.6.0</Version> | |||||
<Version>2.6.1</Version> | |||||
<ImplicitUsings>enable</ImplicitUsings> | <ImplicitUsings>enable</ImplicitUsings> | ||||
<PackageLicenseFile>LICENSE</PackageLicenseFile> | <PackageLicenseFile>LICENSE</PackageLicenseFile> | ||||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance> | <PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance> | ||||
@@ -21,6 +21,7 @@ | |||||
<PackageReference Include="System.Memory" Version="4.5.5" /> | <PackageReference Include="System.Memory" Version="4.5.5" /> | ||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<ProjectReference Include="..\JT808.Protocol.Extensions\JT808.Protocol.DependencyInjection\JT808.Protocol.DependencyInjection.csproj" /> | |||||
<ProjectReference Include="..\JT808.Protocol\JT808.Protocol.csproj" /> | <ProjectReference Include="..\JT808.Protocol\JT808.Protocol.csproj" /> | ||||
</ItemGroup> | </ItemGroup> | ||||
</Project> | </Project> |
@@ -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 | |||||
{ | |||||
/// <summary> | |||||
/// 默认JT808构造器 | |||||
/// </summary> | |||||
class DefaultDIBuilder : IJT808DIBuilder | |||||
{ | |||||
/// <summary> | |||||
/// JT808配置 | |||||
/// </summary> | |||||
public IJT808Config Config { get; } | |||||
/// <summary> | |||||
/// DI ServiceCollection | |||||
/// </summary> | |||||
public IServiceCollection Services { get; } | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="services"></param> | |||||
/// <param name="config"></param> | |||||
public DefaultDIBuilder(IServiceCollection services,IJT808Config config) | |||||
{ | |||||
Config = config; | |||||
Services = services; | |||||
} | |||||
} | |||||
} |
@@ -1,4 +1,5 @@ | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.DependencyInjection; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.Internal; | using JT808.Protocol.Internal; | ||||
using Microsoft.Extensions.DependencyInjection; | using Microsoft.Extensions.DependencyInjection; | ||||
using System; | using System; | ||||
@@ -8,7 +9,8 @@ using System.Text; | |||||
namespace JT808.Protocol | namespace JT808.Protocol | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// DI扩展 | |||||
/// JT808 DI扩展 | |||||
/// JT808 DependencyInjectionExtensions | |||||
/// </summary> | /// </summary> | ||||
public static class DependencyInjectionExtensions | public static class DependencyInjectionExtensions | ||||
{ | { | ||||
@@ -18,10 +20,10 @@ namespace JT808.Protocol | |||||
/// <param name="services"></param> | /// <param name="services"></param> | ||||
/// <param name="jT808Config"></param> | /// <param name="jT808Config"></param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
public static IJT808Builder AddJT808Configure(this IServiceCollection services, IJT808Config jT808Config) | |||||
public static IJT808DIBuilder AddJT808Configure(this IServiceCollection services, IJT808Config jT808Config) | |||||
{ | { | ||||
services.AddSingleton(jT808Config.GetType(), jT808Config); | services.AddSingleton(jT808Config.GetType(), jT808Config); | ||||
return new DefaultBuilder(services, jT808Config); | |||||
return new DefaultDIBuilder(services,jT808Config); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 注册808配置 | /// 注册808配置 | ||||
@@ -29,7 +31,7 @@ namespace JT808.Protocol | |||||
/// <param name="builder"></param> | /// <param name="builder"></param> | ||||
/// <param name="jT808Config"></param> | /// <param name="jT808Config"></param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
public static IJT808Builder AddJT808Configure(this IJT808Builder builder, IJT808Config jT808Config) | |||||
public static IJT808DIBuilder AddJT808Configure(this IJT808DIBuilder builder, IJT808Config jT808Config) | |||||
{ | { | ||||
builder.Services.AddSingleton(jT808Config.GetType(), jT808Config); | builder.Services.AddSingleton(jT808Config.GetType(), jT808Config); | ||||
return builder; | return builder; | ||||
@@ -40,11 +42,11 @@ namespace JT808.Protocol | |||||
/// <typeparam name="TJT808Config"></typeparam> | /// <typeparam name="TJT808Config"></typeparam> | ||||
/// <param name="services"></param> | /// <param name="services"></param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
public static IJT808Builder AddJT808Configure<TJT808Config>(this IServiceCollection services)where TJT808Config : IJT808Config,new() | |||||
public static IJT808DIBuilder AddJT808Configure<TJT808Config>(this IServiceCollection services)where TJT808Config : IJT808Config,new() | |||||
{ | { | ||||
var config = new TJT808Config(); | var config = new TJT808Config(); | ||||
services.AddSingleton(typeof(TJT808Config), config); | services.AddSingleton(typeof(TJT808Config), config); | ||||
return new DefaultBuilder(services, config); | |||||
return new DefaultDIBuilder(services, config); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 注册808配置 | /// 注册808配置 | ||||
@@ -52,7 +54,7 @@ namespace JT808.Protocol | |||||
/// <typeparam name="TJT808Config"></typeparam> | /// <typeparam name="TJT808Config"></typeparam> | ||||
/// <param name="builder"></param> | /// <param name="builder"></param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
public static IJT808Builder AddJT808Configure<TJT808Config>(this IJT808Builder builder) where TJT808Config : IJT808Config, new() | |||||
public static IJT808DIBuilder AddJT808Configure<TJT808Config>(this IJT808DIBuilder builder) where TJT808Config : IJT808Config, new() | |||||
{ | { | ||||
var config = new TJT808Config(); | var config = new TJT808Config(); | ||||
builder.Services.AddSingleton(typeof(TJT808Config), config); | builder.Services.AddSingleton(typeof(TJT808Config), config); | ||||
@@ -63,11 +65,11 @@ namespace JT808.Protocol | |||||
/// </summary> | /// </summary> | ||||
/// <param name="services"></param> | /// <param name="services"></param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
public static IJT808Builder AddJT808Configure(this IServiceCollection services) | |||||
public static IJT808DIBuilder AddJT808Configure(this IServiceCollection services) | |||||
{ | { | ||||
DefaultGlobalConfig config = new DefaultGlobalConfig(); | DefaultGlobalConfig config = new DefaultGlobalConfig(); | ||||
services.AddSingleton<IJT808Config>(config); | services.AddSingleton<IJT808Config>(config); | ||||
return new DefaultBuilder(services, config); | |||||
return new DefaultDIBuilder(services,config); | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -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 | |||||
{ | |||||
/// <summary> | |||||
/// JT808 DI Builder | |||||
/// </summary> | |||||
public interface IJT808DIBuilder: IJT808Builder | |||||
{ | |||||
/// <summary> | |||||
/// 服务注册 | |||||
/// </summary> | |||||
IServiceCollection Services { get; } | |||||
} | |||||
} |
@@ -0,0 +1,29 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<Import Project="..\..\Info.props" /> | |||||
<PropertyGroup> | |||||
<PackageId>JT808.Protocol.DependencyInjection</PackageId> | |||||
<Product>JT808.Protocol.DependencyInjection</Product> | |||||
<Description> | |||||
JT808.Protocol.DependencyInjection. | |||||
</Description> | |||||
<PackageReleaseNotes> | |||||
JT808.Protocol.DependencyInjection. | |||||
</PackageReleaseNotes> | |||||
<DocumentationFile>JT808.Protocol.DependencyInjection.xml</DocumentationFile> | |||||
</PropertyGroup> | |||||
<ItemGroup> | |||||
<None Include="..\..\..\LICENSE" Pack="true" PackagePath="" /> | |||||
<None Include="..\..\..\README.md" Pack="true" PackagePath="" /> | |||||
<None Include="..\..\..\README.en.md" Pack="true" PackagePath="" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<ProjectReference Include="..\..\JT808.Protocol\JT808.Protocol.csproj" /> | |||||
</ItemGroup> | |||||
</Project> |
@@ -0,0 +1,85 @@ | |||||
<?xml version="1.0"?> | |||||
<doc> | |||||
<assembly> | |||||
<name>JT808.Protocol.DependencyInjection</name> | |||||
</assembly> | |||||
<members> | |||||
<member name="T:JT808.Protocol.DependencyInjection.DefaultDIBuilder"> | |||||
<summary> | |||||
默认JT808构造器 | |||||
</summary> | |||||
</member> | |||||
<member name="P:JT808.Protocol.DependencyInjection.DefaultDIBuilder.Config"> | |||||
<summary> | |||||
JT808配置 | |||||
</summary> | |||||
</member> | |||||
<member name="P:JT808.Protocol.DependencyInjection.DefaultDIBuilder.Services"> | |||||
<summary> | |||||
DI ServiceCollection | |||||
</summary> | |||||
</member> | |||||
<member name="M:JT808.Protocol.DependencyInjection.DefaultDIBuilder.#ctor(Microsoft.Extensions.DependencyInjection.IServiceCollection,JT808.Protocol.IJT808Config)"> | |||||
<summary> | |||||
</summary> | |||||
<param name="services"></param> | |||||
<param name="config"></param> | |||||
</member> | |||||
<member name="T:JT808.Protocol.DependencyInjection.IJT808DIBuilder"> | |||||
<summary> | |||||
JT808 DI Builder | |||||
</summary> | |||||
</member> | |||||
<member name="P:JT808.Protocol.DependencyInjection.IJT808DIBuilder.Services"> | |||||
<summary> | |||||
服务注册 | |||||
</summary> | |||||
</member> | |||||
<member name="T:JT808.Protocol.DependencyInjectionExtensions"> | |||||
<summary> | |||||
JT808 DI扩展 | |||||
JT808 DependencyInjectionExtensions | |||||
</summary> | |||||
</member> | |||||
<member name="M:JT808.Protocol.DependencyInjectionExtensions.AddJT808Configure(Microsoft.Extensions.DependencyInjection.IServiceCollection,JT808.Protocol.IJT808Config)"> | |||||
<summary> | |||||
注册808配置 | |||||
</summary> | |||||
<param name="services"></param> | |||||
<param name="jT808Config"></param> | |||||
<returns></returns> | |||||
</member> | |||||
<member name="M:JT808.Protocol.DependencyInjectionExtensions.AddJT808Configure(JT808.Protocol.DependencyInjection.IJT808DIBuilder,JT808.Protocol.IJT808Config)"> | |||||
<summary> | |||||
注册808配置 | |||||
</summary> | |||||
<param name="builder"></param> | |||||
<param name="jT808Config"></param> | |||||
<returns></returns> | |||||
</member> | |||||
<member name="M:JT808.Protocol.DependencyInjectionExtensions.AddJT808Configure``1(Microsoft.Extensions.DependencyInjection.IServiceCollection)"> | |||||
<summary> | |||||
注册808配置 | |||||
</summary> | |||||
<typeparam name="TJT808Config"></typeparam> | |||||
<param name="services"></param> | |||||
<returns></returns> | |||||
</member> | |||||
<member name="M:JT808.Protocol.DependencyInjectionExtensions.AddJT808Configure``1(JT808.Protocol.DependencyInjection.IJT808DIBuilder)"> | |||||
<summary> | |||||
注册808配置 | |||||
</summary> | |||||
<typeparam name="TJT808Config"></typeparam> | |||||
<param name="builder"></param> | |||||
<returns></returns> | |||||
</member> | |||||
<member name="M:JT808.Protocol.DependencyInjectionExtensions.AddJT808Configure(Microsoft.Extensions.DependencyInjection.IServiceCollection)"> | |||||
<summary> | |||||
注册808配置 | |||||
</summary> | |||||
<param name="services"></param> | |||||
<returns></returns> | |||||
</member> | |||||
</members> | |||||
</doc> |
@@ -16,6 +16,7 @@ | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<ProjectReference Include="..\JT808.Protocol.DependencyInjection\JT808.Protocol.DependencyInjection.csproj" /> | |||||
<ProjectReference Include="..\JT808.Protocol.Extensions.JT1078\JT808.Protocol.Extensions.JT1078.csproj" /> | <ProjectReference Include="..\JT808.Protocol.Extensions.JT1078\JT808.Protocol.Extensions.JT1078.csproj" /> | ||||
</ItemGroup> | </ItemGroup> | ||||
@@ -6,6 +6,7 @@ using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Text; | using System.Text; | ||||
using Xunit; | using Xunit; | ||||
using System.Reflection; | |||||
namespace JT808.Protocol.Extensions.JT1078.Test | namespace JT808.Protocol.Extensions.JT1078.Test | ||||
{ | { | ||||
@@ -121,5 +122,16 @@ namespace JT808.Protocol.Extensions.JT1078.Test | |||||
byte[] bodys = "7e020040420100000000013419905507021200040000001410010213679206c4a97d01001300000002220720103957010400000e3e020200000302025825040000001030014531010814040000000115040000000c797e".ToHexBytes(); | byte[] bodys = "7e020040420100000000013419905507021200040000001410010213679206c4a97d01001300000002220720103957010400000e3e020200000302025825040000001030014531010814040000000115040000000c797e".ToHexBytes(); | ||||
string json = JT808Serializer.Analyze<JT808Package>(bodys); | string json = JT808Serializer.Analyze<JT808Package>(bodys); | ||||
} | } | ||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
[Fact] | |||||
public void Test_0x15_5() | |||||
{ | |||||
JT808Serializer.Instance.Register(JT808_JT1078_Constants.GetCurrentAssembly()); | |||||
byte[] bodys = "7e020040420100000000013419905507021200040000001410010213679206c4a97d01001300000002220720103957010400000e3e020200000302025825040000001030014531010814040000000115040000000c797e".ToHexBytes(); | |||||
string json = JT808Serializer.Instance.Analyze<JT808Package>(bodys); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,7 +1,6 @@ | |||||
using JT808.Protocol.Extensions.JT1078.Enums; | using JT808.Protocol.Extensions.JT1078.Enums; | ||||
using JT808.Protocol.Extensions.JT1078.MessageBody; | using JT808.Protocol.Extensions.JT1078.MessageBody; | ||||
using JT808.Protocol.Interfaces; | using JT808.Protocol.Interfaces; | ||||
using Microsoft.Extensions.DependencyInjection; | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Reflection; | using System.Reflection; | ||||
@@ -262,6 +262,12 @@ | |||||
Wake up in hibernation mode | Wake up in hibernation mode | ||||
</summary> | </summary> | ||||
</member> | </member> | ||||
<member name="M:JT808.Protocol.Extensions.JT1078.JT808_JT1078_Constants.GetCurrentAssembly"> | |||||
<summary> | |||||
</summary> | |||||
<returns></returns> | |||||
</member> | |||||
<member name="T:JT808.Protocol.Extensions.JT1078.MessageBody.JT808_0x0200_0x14"> | <member name="T:JT808.Protocol.Extensions.JT1078.MessageBody.JT808_0x0200_0x14"> | ||||
<summary> | <summary> | ||||
视频相关报警 | 视频相关报警 | ||||
@@ -1,5 +1,6 @@ | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Reflection; | |||||
using System.Text; | using System.Text; | ||||
namespace JT808.Protocol.Extensions.JT1078 | namespace JT808.Protocol.Extensions.JT1078 | ||||
@@ -69,5 +70,13 @@ namespace JT808.Protocol.Extensions.JT1078 | |||||
/// Wake up in hibernation mode | /// Wake up in hibernation mode | ||||
/// </summary> | /// </summary> | ||||
public const uint JT808_0X8103_0x007C = 0x007C; | public const uint JT808_0X8103_0x007C = 0x007C; | ||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <returns></returns> | |||||
public static Assembly GetCurrentAssembly() | |||||
{ | |||||
return Assembly.GetExecutingAssembly(); | |||||
} | |||||
} | } | ||||
} | } |
@@ -17,6 +17,7 @@ | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<ProjectReference Include="..\JT808.Protocol.DependencyInjection\JT808.Protocol.DependencyInjection.csproj" /> | |||||
<ProjectReference Include="..\JT808.Protocol.Extensions.SuBiao\JT808.Protocol.Extensions.SuBiao.csproj" /> | <ProjectReference Include="..\JT808.Protocol.Extensions.SuBiao\JT808.Protocol.Extensions.SuBiao.csproj" /> | ||||
</ItemGroup> | </ItemGroup> | ||||
@@ -96,5 +96,12 @@ namespace JT808.Protocol.Extensions.SuBiao.Test | |||||
{ | { | ||||
var json = JT808Serializer.Analyze<JT808_0x0200>("000000010000000200BA7F0E07E4F11C0028003C00001807151010106420000000010C0605120A0B100F1100070000000D0000000E191211183100001334343434343434191210183100030200".ToHexBytes()); | var json = JT808Serializer.Analyze<JT808_0x0200>("000000010000000200BA7F0E07E4F11C0028003C00001807151010106420000000010C0605120A0B100F1100070000000D0000000E191211183100001334343434343434191210183100030200".ToHexBytes()); | ||||
} | } | ||||
[Fact] | |||||
public void Deserialize2() | |||||
{ | |||||
JT808Serializer.Instance.Register(JT808_SuBiao_Constants.GetCurrentAssembly()); | |||||
var json = JT808Serializer.Instance.Analyze<JT808_0x0200>("000000010000000200BA7F0E07E4F11C0028003C00001807151010106420000000010C0605120A0B100F1100070000000D0000000E191211183100001334343434343434191210183100030200".ToHexBytes()); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,7 +1,6 @@ | |||||
using JT808.Protocol.Extensions.SuBiao.Enums; | using JT808.Protocol.Extensions.SuBiao.Enums; | ||||
using JT808.Protocol.Extensions.SuBiao.MessageBody; | using JT808.Protocol.Extensions.SuBiao.MessageBody; | ||||
using JT808.Protocol.Interfaces; | using JT808.Protocol.Interfaces; | ||||
using Microsoft.Extensions.DependencyInjection; | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Reflection; | using System.Reflection; | ||||
@@ -298,6 +298,12 @@ | |||||
信息查询 | 信息查询 | ||||
</summary> | </summary> | ||||
</member> | </member> | ||||
<member name="M:JT808.Protocol.Extensions.SuBiao.JT808_SuBiao_Constants.GetCurrentAssembly"> | |||||
<summary> | |||||
</summary> | |||||
<returns></returns> | |||||
</member> | |||||
<member name="T:JT808.Protocol.Extensions.SuBiao.MessageBody.JT808_0x0200_0x64"> | <member name="T:JT808.Protocol.Extensions.SuBiao.MessageBody.JT808_0x0200_0x64"> | ||||
<summary> | <summary> | ||||
高级驾驶辅助系统报警信息 | 高级驾驶辅助系统报警信息 | ||||
@@ -1,5 +1,6 @@ | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Reflection; | |||||
using System.Text; | using System.Text; | ||||
namespace JT808.Protocol.Extensions.SuBiao | namespace JT808.Protocol.Extensions.SuBiao | ||||
@@ -49,5 +50,13 @@ namespace JT808.Protocol.Extensions.SuBiao | |||||
/// 信息查询 | /// 信息查询 | ||||
/// </summary> | /// </summary> | ||||
public const byte JT808_0X0900_0xF8 = 0xF8; | public const byte JT808_0X0900_0xF8 = 0xF8; | ||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <returns></returns> | |||||
public static Assembly GetCurrentAssembly() | |||||
{ | |||||
return Assembly.GetExecutingAssembly(); | |||||
} | |||||
} | } | ||||
} | } |
@@ -21,6 +21,7 @@ | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<ProjectReference Include="..\JT808.Protocol.DependencyInjection\JT808.Protocol.DependencyInjection.csproj" /> | |||||
<ProjectReference Include="..\JT808.Protocol.Extensions.YueBiao\JT808.Protocol.Extensions.YueBiao.csproj" /> | <ProjectReference Include="..\JT808.Protocol.Extensions.YueBiao\JT808.Protocol.Extensions.YueBiao.csproj" /> | ||||
</ItemGroup> | </ItemGroup> | ||||
@@ -1,5 +1,4 @@ | |||||
using JT808.Protocol.Interfaces; | using JT808.Protocol.Interfaces; | ||||
using Microsoft.Extensions.DependencyInjection; | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Reflection; | using System.Reflection; | ||||
@@ -387,6 +387,12 @@ | |||||
信息查询 | 信息查询 | ||||
</summary> | </summary> | ||||
</member> | </member> | ||||
<member name="M:JT808.Protocol.Extensions.YueBiao.JT808_YueBiao_Constants.GetCurrentAssembly"> | |||||
<summary> | |||||
</summary> | |||||
<returns></returns> | |||||
</member> | |||||
<member name="T:JT808.Protocol.Extensions.YueBiao.MessageBody.JT808_0x0200_0x64"> | <member name="T:JT808.Protocol.Extensions.YueBiao.MessageBody.JT808_0x0200_0x64"> | ||||
<summary> | <summary> | ||||
高级驾驶辅助系统报警信息 | 高级驾驶辅助系统报警信息 | ||||
@@ -1,5 +1,6 @@ | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Reflection; | |||||
using System.Text; | using System.Text; | ||||
namespace JT808.Protocol.Extensions.YueBiao | namespace JT808.Protocol.Extensions.YueBiao | ||||
@@ -62,5 +63,13 @@ namespace JT808.Protocol.Extensions.YueBiao | |||||
/// 信息查询 | /// 信息查询 | ||||
/// </summary> | /// </summary> | ||||
public const byte JT808_0X0900_0xF8 = 0xF8; | public const byte JT808_0X0900_0xF8 = 0xF8; | ||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <returns></returns> | |||||
public static Assembly GetCurrentAssembly() | |||||
{ | |||||
return Assembly.GetExecutingAssembly(); | |||||
} | |||||
} | } | ||||
} | } |
@@ -126,6 +126,7 @@ | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<ProjectReference Include="..\JT808.Protocol.Extensions\JT808.Protocol.DependencyInjection\JT808.Protocol.DependencyInjection.csproj" /> | |||||
<ProjectReference Include="..\JT808.Protocol\JT808.Protocol.csproj" /> | <ProjectReference Include="..\JT808.Protocol\JT808.Protocol.csproj" /> | ||||
</ItemGroup> | </ItemGroup> | ||||
@@ -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] | [Fact] | ||||
public unsafe void DefaultGlobalConfigTest1() | public unsafe void DefaultGlobalConfigTest1() | ||||
{ | { | ||||
@@ -33,6 +33,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Protocol.Extensions.S | |||||
EndProject | 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}" | 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 | 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 | Global | ||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||||
Debug|Any CPU = Debug|Any CPU | 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}.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.ActiveCfg = Release|Any CPU | ||||
{BEE2E12D-C123-4682-AB7E-210C2BF564B3}.Release|Any CPU.Build.0 = 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 | EndGlobalSection | ||||
GlobalSection(SolutionProperties) = preSolution | GlobalSection(SolutionProperties) = preSolution | ||||
HideSolutionNode = FALSE | HideSolutionNode = FALSE | ||||
@@ -86,6 +92,7 @@ Global | |||||
{4984E375-4B55-4188-A94E-844B694BBA5C} = {3A0EEA9A-9667-4386-BB46-4A9CB319CE30} | {4984E375-4B55-4188-A94E-844B694BBA5C} = {3A0EEA9A-9667-4386-BB46-4A9CB319CE30} | ||||
{001ECBA0-CF17-40B0-B983-B7AE824B8050} = {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} | {BEE2E12D-C123-4682-AB7E-210C2BF564B3} = {3A0EEA9A-9667-4386-BB46-4A9CB319CE30} | ||||
{7EB01F74-DFDB-4733-8F15-5785A9ED7DBD} = {3A0EEA9A-9667-4386-BB46-4A9CB319CE30} | |||||
EndGlobalSection | EndGlobalSection | ||||
GlobalSection(ExtensibilityGlobals) = postSolution | GlobalSection(ExtensibilityGlobals) = postSolution | ||||
SolutionGuid = {D58CCAA8-ED94-4048-A6DE-55A84814DF17} | SolutionGuid = {D58CCAA8-ED94-4048-A6DE-55A84814DF17} | ||||
@@ -1,5 +1,4 @@ | |||||
using JT808.Protocol.Interfaces; | using JT808.Protocol.Interfaces; | ||||
using Microsoft.Extensions.DependencyInjection; | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Text; | using System.Text; | ||||
@@ -15,9 +14,5 @@ namespace JT808.Protocol | |||||
/// JT808配置 | /// JT808配置 | ||||
/// </summary> | /// </summary> | ||||
IJT808Config Config { get; } | IJT808Config Config { get; } | ||||
/// <summary> | |||||
/// 服务注册 | |||||
/// </summary> | |||||
IServiceCollection Services { get; } | |||||
} | } | ||||
} | } |
@@ -1,5 +1,4 @@ | |||||
using JT808.Protocol.Interfaces; | using JT808.Protocol.Interfaces; | ||||
using Microsoft.Extensions.DependencyInjection; | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Text; | using System.Text; | ||||
@@ -11,10 +10,6 @@ namespace JT808.Protocol.Internal | |||||
/// </summary> | /// </summary> | ||||
class DefaultBuilder : IJT808Builder | class DefaultBuilder : IJT808Builder | ||||
{ | { | ||||
/// <summary> | |||||
/// DI服务 | |||||
/// </summary> | |||||
public IServiceCollection Services { get; } | |||||
/// <summary> | /// <summary> | ||||
/// JT808配置 | /// JT808配置 | ||||
/// </summary> | /// </summary> | ||||
@@ -22,11 +17,9 @@ namespace JT808.Protocol.Internal | |||||
/// <summary> | /// <summary> | ||||
/// | /// | ||||
/// </summary> | /// </summary> | ||||
/// <param name="services"></param> | |||||
/// <param name="config"></param> | /// <param name="config"></param> | ||||
public DefaultBuilder(IServiceCollection services, IJT808Config config) | |||||
public DefaultBuilder(IJT808Config config) | |||||
{ | { | ||||
Services = services; | |||||
Config = config; | Config = config; | ||||
} | } | ||||
} | } | ||||
@@ -1,10 +1,11 @@ | |||||
using JT808.Protocol.Interfaces; | using JT808.Protocol.Interfaces; | ||||
using System.Runtime.CompilerServices; | |||||
namespace JT808.Protocol.Internal | namespace JT808.Protocol.Internal | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 默认全局配置 | /// 默认全局配置 | ||||
/// </summary> | |||||
/// </summary> | |||||
class DefaultGlobalConfig : GlobalConfigBase | class DefaultGlobalConfig : GlobalConfigBase | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
@@ -27,6 +27,7 @@ | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<Compile Remove="DependencyInjectionExtensions.cs" /> | |||||
<Compile Remove="Formatters\JT808HeaderFormatter.cs" /> | <Compile Remove="Formatters\JT808HeaderFormatter.cs" /> | ||||
<Compile Remove="Formatters\JT808HeaderPackageFormatter.cs" /> | <Compile Remove="Formatters\JT808HeaderPackageFormatter.cs" /> | ||||
<Compile Remove="Formatters\JT808PackageFormatter.cs" /> | <Compile Remove="Formatters\JT808PackageFormatter.cs" /> | ||||
@@ -40,12 +41,10 @@ | |||||
<Compile Remove="Metadata\JT808UploadLocationRequestProperty.cs" /> | <Compile Remove="Metadata\JT808UploadLocationRequestProperty.cs" /> | ||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup Condition=" '$(TargetFramework)' == 'net7.0' "> | |||||
<ItemGroup> | |||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" /> | <PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" /> | ||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<None Update="Extensions\JT808PackageExtensionsTemplate.tt"> | <None Update="Extensions\JT808PackageExtensionsTemplate.tt"> | ||||
<Generator>TextTemplatingFileGenerator</Generator> | <Generator>TextTemplatingFileGenerator</Generator> | ||||
@@ -15,50 +15,6 @@ | |||||
编码之前的写入位置 | 编码之前的写入位置 | ||||
</summary> | </summary> | ||||
</member> | </member> | ||||
<member name="T:JT808.Protocol.DependencyInjectionExtensions"> | |||||
<summary> | |||||
DI扩展 | |||||
</summary> | |||||
</member> | |||||
<member name="M:JT808.Protocol.DependencyInjectionExtensions.AddJT808Configure(Microsoft.Extensions.DependencyInjection.IServiceCollection,JT808.Protocol.IJT808Config)"> | |||||
<summary> | |||||
注册808配置 | |||||
</summary> | |||||
<param name="services"></param> | |||||
<param name="jT808Config"></param> | |||||
<returns></returns> | |||||
</member> | |||||
<member name="M:JT808.Protocol.DependencyInjectionExtensions.AddJT808Configure(JT808.Protocol.IJT808Builder,JT808.Protocol.IJT808Config)"> | |||||
<summary> | |||||
注册808配置 | |||||
</summary> | |||||
<param name="builder"></param> | |||||
<param name="jT808Config"></param> | |||||
<returns></returns> | |||||
</member> | |||||
<member name="M:JT808.Protocol.DependencyInjectionExtensions.AddJT808Configure``1(Microsoft.Extensions.DependencyInjection.IServiceCollection)"> | |||||
<summary> | |||||
注册808配置 | |||||
</summary> | |||||
<typeparam name="TJT808Config"></typeparam> | |||||
<param name="services"></param> | |||||
<returns></returns> | |||||
</member> | |||||
<member name="M:JT808.Protocol.DependencyInjectionExtensions.AddJT808Configure``1(JT808.Protocol.IJT808Builder)"> | |||||
<summary> | |||||
注册808配置 | |||||
</summary> | |||||
<typeparam name="TJT808Config"></typeparam> | |||||
<param name="builder"></param> | |||||
<returns></returns> | |||||
</member> | |||||
<member name="M:JT808.Protocol.DependencyInjectionExtensions.AddJT808Configure(Microsoft.Extensions.DependencyInjection.IServiceCollection)"> | |||||
<summary> | |||||
注册808配置 | |||||
</summary> | |||||
<param name="services"></param> | |||||
<returns></returns> | |||||
</member> | |||||
<member name="T:JT808.Protocol.Enums.JT808Alarm"> | <member name="T:JT808.Protocol.Enums.JT808Alarm"> | ||||
<summary> | <summary> | ||||
报警标志 | 报警标志 | ||||
@@ -4278,11 +4234,6 @@ | |||||
JT808配置 | JT808配置 | ||||
</summary> | </summary> | ||||
</member> | </member> | ||||
<member name="P:JT808.Protocol.IJT808Builder.Services"> | |||||
<summary> | |||||
服务注册 | |||||
</summary> | |||||
</member> | |||||
<member name="T:JT808.Protocol.Interfaces.GlobalConfigBase"> | <member name="T:JT808.Protocol.Interfaces.GlobalConfigBase"> | ||||
<summary> | <summary> | ||||
全局配置基类 | 全局配置基类 | ||||
@@ -4928,27 +4879,21 @@ | |||||
默认JT808构造器 | 默认JT808构造器 | ||||
</summary> | </summary> | ||||
</member> | </member> | ||||
<member name="P:JT808.Protocol.Internal.DefaultBuilder.Services"> | |||||
<summary> | |||||
DI服务 | |||||
</summary> | |||||
</member> | |||||
<member name="P:JT808.Protocol.Internal.DefaultBuilder.Config"> | <member name="P:JT808.Protocol.Internal.DefaultBuilder.Config"> | ||||
<summary> | <summary> | ||||
JT808配置 | JT808配置 | ||||
</summary> | </summary> | ||||
</member> | </member> | ||||
<member name="M:JT808.Protocol.Internal.DefaultBuilder.#ctor(Microsoft.Extensions.DependencyInjection.IServiceCollection,JT808.Protocol.IJT808Config)"> | |||||
<member name="M:JT808.Protocol.Internal.DefaultBuilder.#ctor(JT808.Protocol.IJT808Config)"> | |||||
<summary> | <summary> | ||||
</summary> | </summary> | ||||
<param name="services"></param> | |||||
<param name="config"></param> | <param name="config"></param> | ||||
</member> | </member> | ||||
<member name="T:JT808.Protocol.Internal.DefaultGlobalConfig"> | <member name="T:JT808.Protocol.Internal.DefaultGlobalConfig"> | ||||
<summary> | <summary> | ||||
默认全局配置 | 默认全局配置 | ||||
</summary> | |||||
</summary> | |||||
</member> | </member> | ||||
<member name="P:JT808.Protocol.Internal.DefaultGlobalConfig.ConfigId"> | <member name="P:JT808.Protocol.Internal.DefaultGlobalConfig.ConfigId"> | ||||
<summary> | <summary> | ||||
@@ -6150,6 +6095,12 @@ | |||||
JT808序列化器 | JT808序列化器 | ||||
</summary> | </summary> | ||||
</member> | </member> | ||||
<member name="F:JT808.Protocol.JT808Serializer.Instance"> | |||||
<summary> | |||||
默认实例 | |||||
default instance | |||||
</summary> | |||||
</member> | |||||
<member name="M:JT808.Protocol.JT808Serializer.#ctor(JT808.Protocol.IJT808Config)"> | <member name="M:JT808.Protocol.JT808Serializer.#ctor(JT808.Protocol.IJT808Config)"> | ||||
<summary> | <summary> | ||||
@@ -6175,15 +6126,6 @@ | |||||
<param name="minBufferSize"></param> | <param name="minBufferSize"></param> | ||||
<returns></returns> | <returns></returns> | ||||
</member> | </member> | ||||
<member name="M:JT808.Protocol.JT808Serializer.SerializeReadOnlySpan(JT808.Protocol.JT808Package,JT808.Protocol.Enums.JT808Version,System.Int32)"> | |||||
<summary> | |||||
</summary> | |||||
<param name="package"></param> | |||||
<param name="version"></param> | |||||
<param name="minBufferSize"></param> | |||||
<returns></returns> | |||||
</member> | |||||
<member name="M:JT808.Protocol.JT808Serializer.Deserialize(System.ReadOnlySpan{System.Byte},JT808.Protocol.Enums.JT808Version,System.Int32)"> | <member name="M:JT808.Protocol.JT808Serializer.Deserialize(System.ReadOnlySpan{System.Byte},JT808.Protocol.Enums.JT808Version,System.Int32)"> | ||||
<summary> | <summary> | ||||
@@ -6203,16 +6145,6 @@ | |||||
<param name="minBufferSize"></param> | <param name="minBufferSize"></param> | ||||
<returns></returns> | <returns></returns> | ||||
</member> | </member> | ||||
<member name="M:JT808.Protocol.JT808Serializer.SerializeReadOnlySpan``1(``0,JT808.Protocol.Enums.JT808Version,System.Int32)"> | |||||
<summary> | |||||
</summary> | |||||
<typeparam name="T"></typeparam> | |||||
<param name="obj"></param> | |||||
<param name="version"></param> | |||||
<param name="minBufferSize"></param> | |||||
<returns></returns> | |||||
</member> | |||||
<member name="M:JT808.Protocol.JT808Serializer.Deserialize``1(System.ReadOnlySpan{System.Byte},JT808.Protocol.Enums.JT808Version,System.Int32)"> | <member name="M:JT808.Protocol.JT808Serializer.Deserialize``1(System.ReadOnlySpan{System.Byte},JT808.Protocol.Enums.JT808Version,System.Int32)"> | ||||
<summary> | <summary> | ||||
@@ -6314,6 +6246,13 @@ | |||||
<param name="minBufferSize"></param> | <param name="minBufferSize"></param> | ||||
<returns></returns> | <returns></returns> | ||||
</member> | </member> | ||||
<member name="M:JT808.Protocol.JT808Serializer.Register(System.Reflection.Assembly[])"> | |||||
<summary> | |||||
外部注册 | |||||
</summary> | |||||
<param name="externalAssemblies"></param> | |||||
<returns></returns> | |||||
</member> | |||||
<member name="T:JT808.Protocol.MessageBody.CarDVR.JT808_CarDVR_Down_0x00"> | <member name="T:JT808.Protocol.MessageBody.CarDVR.JT808_CarDVR_Down_0x00"> | ||||
<summary> | <summary> | ||||
采集记录仪执行标准版本 | 采集记录仪执行标准版本 | ||||
@@ -1,14 +1,14 @@ | |||||
using JT808.Protocol.Enums; | using JT808.Protocol.Enums; | ||||
using JT808.Protocol.Extensions; | using JT808.Protocol.Extensions; | ||||
using JT808.Protocol.Formatters; | using JT808.Protocol.Formatters; | ||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.Internal; | using JT808.Protocol.Internal; | ||||
using JT808.Protocol.MessagePack; | using JT808.Protocol.MessagePack; | ||||
using System; | |||||
using System.IO; | |||||
using System.Reflection; | |||||
using System.Runtime.CompilerServices; | |||||
using System.Text; | using System.Text; | ||||
using System.Text.Json; | using System.Text.Json; | ||||
[assembly: InternalsVisibleTo("JT808.Protocol.DependencyInjection")] | |||||
namespace JT808.Protocol | namespace JT808.Protocol | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
@@ -22,6 +22,17 @@ namespace JT808.Protocol | |||||
private readonly static Type JT808_Package_Type = typeof(JT808Package); | private readonly static Type JT808_Package_Type = typeof(JT808Package); | ||||
/// <summary> | |||||
/// 默认实例 | |||||
/// default instance | |||||
/// </summary> | |||||
public readonly static JT808Serializer Instance; | |||||
static JT808Serializer() | |||||
{ | |||||
Instance= new JT808Serializer(); | |||||
} | |||||
/// <summary> | /// <summary> | ||||
/// | /// | ||||
/// </summary> | /// </summary> | ||||
@@ -30,6 +41,7 @@ namespace JT808.Protocol | |||||
{ | { | ||||
this.jT808Config = jT808Config; | this.jT808Config = jT808Config; | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// | /// | ||||
/// </summary> | /// </summary> | ||||
@@ -68,27 +80,6 @@ namespace JT808.Protocol | |||||
/// <summary> | /// <summary> | ||||
/// | /// | ||||
/// </summary> | /// </summary> | ||||
/// <param name="package"></param> | |||||
/// <param name="version"></param> | |||||
/// <param name="minBufferSize"></param> | |||||
/// <returns></returns> | |||||
public ReadOnlySpan<byte> 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); | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="bytes"></param> | /// <param name="bytes"></param> | ||||
/// <param name="version"></param> | /// <param name="version"></param> | ||||
/// <param name="minBufferSize"></param> | /// <param name="minBufferSize"></param> | ||||
@@ -134,29 +125,6 @@ namespace JT808.Protocol | |||||
/// | /// | ||||
/// </summary> | /// </summary> | ||||
/// <typeparam name="T"></typeparam> | /// <typeparam name="T"></typeparam> | ||||
/// <param name="obj"></param> | |||||
/// <param name="version"></param> | |||||
/// <param name="minBufferSize"></param> | |||||
/// <returns></returns> | |||||
public ReadOnlySpan<byte> SerializeReadOnlySpan<T>(T obj, JT808Version version = JT808Version.JTT2013, int minBufferSize = 4096) | |||||
{ | |||||
byte[] buffer = JT808ArrayPool.Rent(minBufferSize); | |||||
try | |||||
{ | |||||
var formatter = jT808Config.GetMessagePackFormatter<T>(); | |||||
JT808MessagePackWriter jT808MessagePackWriter = new JT808MessagePackWriter(buffer, version); | |||||
formatter.Serialize(ref jT808MessagePackWriter, obj, jT808Config); | |||||
return jT808MessagePackWriter.FlushAndGetEncodingReadOnlySpan(); | |||||
} | |||||
finally | |||||
{ | |||||
JT808ArrayPool.Return(buffer); | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <typeparam name="T"></typeparam> | |||||
/// <param name="bytes"></param> | /// <param name="bytes"></param> | ||||
/// <param name="version"></param> | /// <param name="version"></param> | ||||
/// <param name="minBufferSize"></param> | /// <param name="minBufferSize"></param> | ||||
@@ -217,7 +185,7 @@ namespace JT808.Protocol | |||||
/// <param name="version"></param> | /// <param name="version"></param> | ||||
/// <param name="minBufferSize"></param> | /// <param name="minBufferSize"></param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
public dynamic Deserialize(ReadOnlySpan<byte> bytes, Type type, JT808Version version = JT808Version.JTT2013, int minBufferSize = 4096) | |||||
public object Deserialize(ReadOnlySpan<byte> bytes, Type type, JT808Version version = JT808Version.JTT2013, int minBufferSize = 4096) | |||||
{ | { | ||||
byte[] buffer = JT808ArrayPool.Rent(minBufferSize); | byte[] buffer = JT808ArrayPool.Rent(minBufferSize); | ||||
try | try | ||||
@@ -424,5 +392,22 @@ namespace JT808.Protocol | |||||
JT808ArrayPool.Return(buffer); | JT808ArrayPool.Return(buffer); | ||||
} | } | ||||
} | } | ||||
/// <summary> | |||||
/// 外部注册 | |||||
/// </summary> | |||||
/// <param name="externalAssemblies"></param> | |||||
/// <returns></returns> | |||||
public JT808Serializer Register(params Assembly[] externalAssemblies) | |||||
{ | |||||
if(externalAssemblies!=null && externalAssemblies.Length > 0) | |||||
{ | |||||
foreach(var asm in externalAssemblies) | |||||
{ | |||||
jT808Config.Register(asm); | |||||
} | |||||
} | |||||
return this; | |||||
} | |||||
} | } | ||||
} | } |