commit 4db0176004d19ba215bba101bdf18caa52f83cd2 Author: CortexCore <2630229280@qq.com> Date: Mon Apr 29 11:34:11 2024 +0800 1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6ceaa14 --- /dev/null +++ b/.gitignore @@ -0,0 +1,575 @@ +# ---> Unity +# This .gitignore file should be placed at the root of your Unity project directory +# +# Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore +# +/[Ll]ibrary/ +/[Tt]emp/ +/[Oo]bj/ +/[Bb]uild/ +/[Bb]uilds/ +/[Ll]ogs/ +/[Uu]ser[Ss]ettings/ + +# MemoryCaptures can get excessive in size. +# They also could contain extremely sensitive data +/[Mm]emoryCaptures/ + +# Recordings can get excessive in size +/[Rr]ecordings/ + +# Uncomment this line if you wish to ignore the asset store tools plugin +# /[Aa]ssets/AssetStoreTools* + +# Autogenerated Jetbrains Rider plugin +/[Aa]ssets/Plugins/Editor/JetBrains* + +# Visual Studio cache directory +.vs/ + +# Gradle cache directory +.gradle/ + +# Autogenerated VS/MD/Consulo solution and project files +ExportedObj/ +.consulo/ +*.csproj +*.unityproj +*.sln +*.suo +*.tmp +*.user +*.userprefs +*.pidb +*.booproj +*.svd +*.pdb +*.mdb +*.opendb +*.VC.db + +# Unity3D generated meta files +*.pidb.meta +*.pdb.meta +*.mdb.meta + +# Unity3D generated file on crash reports +sysinfo.txt + +# Builds +*.apk +*.aab +*.unitypackage +*.app + +# Crashlytics generated file +crashlytics-build.properties + +# Packed Addressables +/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin* + +# Temporary auto-generated Android Assets +/[Aa]ssets/[Ss]treamingAssets/aa.meta +/[Aa]ssets/[Ss]treamingAssets/aa/* + +# ---> JetBrains +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +# ---> VisualStudio +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml + +# ---> VisualStudioCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +# custom +.idea +.plastic +.vscode +/Assets/StreamingAssets/yoo +yoo/ +Bundles/ +Profiler/ diff --git a/samples/idis_query.json b/samples/idis_query.json new file mode 100644 index 0000000..39130a8 --- /dev/null +++ b/samples/idis_query.json @@ -0,0 +1,175 @@ +{ + "message": "success", + "status": 1, + "data": { + "prefixType": 4, + "metaDataInfo": { + "industryCategory": "制造业", + "industrySpecific": "通用设备制造业", + "itemVOS": [ + { + "minLength": "0", + "enName": "productName", + "type": "string", + "chName": "产品名称", + "maxLength": "200" + }, + { + "minLength": "0", + "enName": "batchNo", + "type": "string", + "chName": "批次号", + "maxLength": "100" + }, + { + "minLength": "0", + "enName": "categoryName", + "type": "string", + "chName": "应用行业", + "maxLength": "100" + }, + { + "minLength": "0", + "enName": "remark", + "type": "string", + "chName": "产品简介", + "maxLength": "500" + }, + { + "minLength": "0", + "enName": "CPU", + "type": "string", + "chName": "CPU", + "maxLength": "50" + }, + { + "minLength": "0", + "enName": "RAMROM", + "type": "string", + "chName": "内存", + "maxLength": "50" + }, + { + "minLength": "0", + "enName": "Interface", + "type": "string", + "chName": "接口", + "maxLength": "50" + }, + { + "minLength": "0", + "enName": "screenName", + "type": "string", + "chName": "显示屏", + "maxLength": "100" + }, + { + "minLength": "0", + "enName": "positionSystem", + "type": "string", + "chName": "定位系统", + "maxLength": "100" + }, + { + "minLength": "0", + "enName": "temperature", + "type": "string", + "chName": "工作温度", + "maxLength": "100" + } + ], + "prefix": "88.111.1315", + "name": "工业级手持PDA", + "description": "适用于工业级手持PDA,描述产品的规格特性", + "id": 3744, + "version": "工业级手持PDA", + "createDate": "2023-09-05 17:21:57", + "entName": "中国信息通信院" + }, + "pmsReg": true, + "titleBarInfo": { + "count": "764", + "handle": "88.111.1315/PX2R217049T1", + "type": 4 + }, + "idData": [ + { + "index": 0, + "type": "string", + "name": "标识", + "realVal": "88.111.1315/PX2R217049T1", + "references": null + }, + { + "index": 2, + "type": "string", + "name": "产品名称", + "realVal": "工业级手持终端PDA-ATUPX200", + "references": null + }, + { + "index": 3, + "type": "string", + "name": "批次号", + "realVal": "ATU-PX200MI04", + "references": null + }, + { + "index": 4, + "type": "string", + "name": "应用行业", + "realVal": "制造业", + "references": null + }, + { + "index": 5, + "type": "string", + "name": "产品简介", + "realVal": "工业级手持PDA,现场采集的优质智能工具,适用于仓储、零售、生产制造、物流等场景,助力企业数字化快速进阶。", + "references": null + }, + { + "index": 6, + "type": "string", + "name": "CPU", + "realVal": "Cortex™-A53八核2.0GHz", + "references": null + }, + { + "index": 7, + "type": "string", + "name": "内存", + "realVal": "4GB+64GB", + "references": null + }, + { + "index": 8, + "type": "string", + "name": "接口", + "realVal": "Type-c接口", + "references": null + }, + { + "index": 9, + "type": "string", + "name": "显示屏", + "realVal": "4英寸工业级耐低温IPS显示屏", + "references": null + }, + { + "index": 10, + "type": "string", + "name": "定位系统", + "realVal": "GPS、北斗、GLONASS", + "references": null + }, + { + "index": 11, + "type": "string", + "name": "工作温度", + "realVal": "-20℃至+50℃", + "references": null + } + ] + } +} \ No newline at end of file diff --git a/samples/idis_register.json b/samples/idis_register.json new file mode 100644 index 0000000..7999dfd --- /dev/null +++ b/samples/idis_register.json @@ -0,0 +1,8 @@ +{ + "handle": "88.123.99/202404281606", + "templateVersion": "1.0", + "value": { + "key1": "value1", + "key2": "value2" + } +} \ No newline at end of file diff --git a/src/IDIS.Model.asmdef b/src/IDIS.Model.asmdef new file mode 100644 index 0000000..bb99bec --- /dev/null +++ b/src/IDIS.Model.asmdef @@ -0,0 +1,17 @@ +{ + "name": "IDIS.Model", + "rootNamespace": "", + "references": [ + "GUID:14fe60d984bf9f84eac55c6ea033a8f4", + "GUID:f51ebe6a0ceec4240a699833d6309b23" + ], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/src/Models/IDIS_Code.cs b/src/Models/IDIS_Code.cs new file mode 100644 index 0000000..a837344 --- /dev/null +++ b/src/Models/IDIS_Code.cs @@ -0,0 +1,14 @@ +namespace IDIS.Models +{ + /// + /// IDIS的编码常量 + /// + public static class IDIS_Code + { + /// + /// 标识码的正则表达式,例如88.123.99/CN20230915 + /// + public const string AddressRegex = @"^\d{1,3}\.\d{1,3}\.\d{1,3}/[A-Za-z0-9]{1,32}$"; + public const string Prefix = @"^\d{1,3}\.\d{1,3}\.\d{1,3}$"; + } +} diff --git a/src/Models/IDIS_Data.cs b/src/Models/IDIS_Data.cs new file mode 100644 index 0000000..be44991 --- /dev/null +++ b/src/Models/IDIS_Data.cs @@ -0,0 +1,26 @@ + +using System; +using Newtonsoft.Json; + +namespace IDIS.Models +{ + + public record IDIS_Data + { + [JsonProperty("prefixType")] + public int PrefixType { get; set; } + + [JsonProperty("metaDataInfo")] + public IDIS_MetaDataInfo MetaDataInfo { get; set; } = new(); + + [JsonProperty("pmsReg")] + public bool PmsReg { get; set; } + + [JsonProperty("titleBarInfo")] + public TitleBarInfo TitleBarInfo { get; set; } = new(); + + [JsonProperty("IdData")] + public IDIS_IdData[] IdData { get; set; }=Array.Empty(); + + } +} \ No newline at end of file diff --git a/src/Models/IDIS_IdData.cs b/src/Models/IDIS_IdData.cs new file mode 100644 index 0000000..c759332 --- /dev/null +++ b/src/Models/IDIS_IdData.cs @@ -0,0 +1,52 @@ +using System; +using System.ComponentModel.DataAnnotations; +using Newtonsoft.Json; + +namespace IDIS.Models +{ + + /// + /// 标识的格式 + /// + [Serializable] + public class IDIS_IdData + { + public IDIS_IdData(int index,string type,string name, string realVal) + { + Index = index; + Type = type; + Name = name; + RealVal = realVal; + } + + /// + /// 索引,通常用于排序 + /// + [JsonProperty("index")] + public int Index { get; set; } + + /// + /// 记录的名称,通常为中文 + /// + [JsonProperty("name")] + public string Name { get; set; } + + /// + /// 值类型,例如string,url,site + /// + [JsonProperty("type")] + public string Type { get; set; } + + /// + /// 值 + /// + [JsonProperty("realVal")] + public string RealVal { get; set; } + + /// + /// 值的引用 + /// + [JsonProperty("references")] + public string[] References { get; set; } = Array.Empty(); + } +} \ No newline at end of file diff --git a/src/Models/IDIS_ItemVOS.cs b/src/Models/IDIS_ItemVOS.cs new file mode 100644 index 0000000..b0b1763 --- /dev/null +++ b/src/Models/IDIS_ItemVOS.cs @@ -0,0 +1,28 @@ + +using Newtonsoft.Json; + +namespace IDIS.Models +{ + public class IDIS_ItemVOS + { + public IDIS_ItemVOS(string minLength, string enName, string type, string chName, string maxLength) + { + MinLength = minLength; + EnName = enName; + Type = type; + ChName = chName; + MaxLength = maxLength; + } + + [JsonProperty("minLength")] + public string MinLength { get; set; } + [JsonProperty("enName")] + public string EnName { get; set; } + [JsonProperty("type")] + public string Type { get; set; } + [JsonProperty("chName")] + public string ChName { get; set; } + [JsonProperty("maxLength")] + public string MaxLength { get; set; } + } +} \ No newline at end of file diff --git a/src/Models/IDIS_MetaDataInfo.cs b/src/Models/IDIS_MetaDataInfo.cs new file mode 100644 index 0000000..eb0a00d --- /dev/null +++ b/src/Models/IDIS_MetaDataInfo.cs @@ -0,0 +1,28 @@ + +using System; +using Newtonsoft.Json; + +namespace IDIS.Models +{ + public class IDIS_MetaDataInfo + { + public IDIS_MetaDataInfo() + { + + } + public IDIS_MetaDataInfo(string industryCategory, string industrySpecific) + { + IndustryCategory = industryCategory; + IndustrySpecific = industrySpecific; + } + + [JsonProperty("industryCategory")] + public string IndustryCategory { get; set; } = nameof(IndustryCategory); + + [JsonProperty("industrySpecific")] + public string IndustrySpecific { get; set; } = nameof(IndustrySpecific); + + [JsonProperty("itemVOS")] + public IDIS_ItemVOS[] ItemVOS { get; set; } = Array.Empty(); + } +} \ No newline at end of file diff --git a/src/Models/IDIS_Register_Data.cs b/src/Models/IDIS_Register_Data.cs new file mode 100644 index 0000000..f7ff8f2 --- /dev/null +++ b/src/Models/IDIS_Register_Data.cs @@ -0,0 +1,16 @@ +using Newtonsoft.Json; + +namespace IDIS.Models; + +/// +/// 用于序列化的注册数据结构 +/// +public class IDIS_Register_Data +{ + [JsonProperty("handle")] + public required string Handle; + [JsonProperty("templateVersion")] + public required string TemplateVersion; + [JsonProperty("value")] + public required Dictionary Value; +} \ No newline at end of file diff --git a/src/Models/IDIS_Response.cs b/src/Models/IDIS_Response.cs new file mode 100644 index 0000000..a0ca49f --- /dev/null +++ b/src/Models/IDIS_Response.cs @@ -0,0 +1,106 @@ +using System; +using IDIS.Models; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace IDIS +{ + public class IDIS_Response + { + public static IDIS_Response CreateFromJson(string json) + { + var value = new IDIS_Response(); + var jObject = JObject.Parse(json); + if(jObject.TryGetValue(nameof(Message), out var message)) + value.Message = message.Value(); + if(jObject.TryGetValue(nameof(Status), out var status)) + value.Status = status.Value(); + value.jObject = jObject; + return value; + } + public static IDIS_Response CreateFromJsonAs(string json) + { + var value = CreateFromJson(json); + try + { + if (value.jObject is not null && value.Status is 1 && value.jObject.TryGetValue("data", out var data)) + { + value.Data = data.ToObject(); + } + } + catch (Exception) + { + return value; + } + return value; + } + public IDIS_Response() + { + + } + public IDIS_Response(string message) + { + Message = message; + } + + public IDIS_Response(object data) + { + Data = data; + } + public IDIS_Response(string message, object data) + { + Message = message; + Data = data; + } + public IDIS_Response(string message,int status, object data) + { + Message = message; + Status = status; + Data = data; + } + public IDIS_Response(string message,Enum status, object data) + { + Message = message; + Status =(int)Convert.ChangeType(status,typeof(int)); + Data = data; + } + + /// + /// 信息 + /// + [JsonProperty("message")] + public string Message { get; set; } = "success"; + + [JsonProperty("status")] + public int Status { get; set; } = 1; + + [JsonProperty("data")] + public object Data { get; set; } = true; + + [JsonIgnore] private JObject jObject; + + public T As() + { + if (Data is T value) + { + return value; + } + throw new InvalidOperationException("Data is not of type T"); + } + public bool TryAs(out T value) + { + switch (Data) + { + case T _value: + value = _value; + return true; + case null when jObject?.TryGetValue("data", out var data) is true: + value = data.Value(); + return true; + default: + value = default!; + return false; + } + } + } +} diff --git a/src/Models/IDIS_Template.cs b/src/Models/IDIS_Template.cs new file mode 100644 index 0000000..4965465 --- /dev/null +++ b/src/Models/IDIS_Template.cs @@ -0,0 +1,49 @@ +using System; +using Newtonsoft.Json; + +namespace IDIS.Models +{ + /// + /// 标识模板 + /// + public class IDIS_Template + { + public IDIS_Template() + { + + } + public IDIS_Template(string prefix, string version) + { + Prefix = prefix; + Version = version; + } + + /// + /// 前缀,例如 88.123.99 + /// 必填 + /// + [JsonProperty("prefix")] + public string Prefix { get; set; } = nameof(IDIS_Template); + + /// + /// 模板版本 + /// 必填 + /// + [JsonProperty("version")] + public string Version { get; set; } = "alpha-1.0"; + + /// + /// 描述 + /// 非必填 + /// + [JsonProperty("description")] + public string Description { get; set; } = string.Empty; + + /// + /// 模板内容 + /// 必填 + /// + [JsonProperty("items")] + public IDIS_Template_Item[] Items { get; set; } = Array.Empty(); + } +} \ No newline at end of file diff --git a/src/Models/IDIS_Template_Item.cs b/src/Models/IDIS_Template_Item.cs new file mode 100644 index 0000000..0c79da9 --- /dev/null +++ b/src/Models/IDIS_Template_Item.cs @@ -0,0 +1,24 @@ +using System; +using Newtonsoft.Json; + +namespace IDIS.Models +{ + /// + /// 基于IDIS v1的标识模板值 + /// + public class IDIS_Template_Item + { + public IDIS_Template_Item(){} + public IDIS_Template_Item(string name,string idType) + { + Name = name; + IdType = idType; + } + [JsonProperty("name")] + public string Name { get; set; } = string.Empty; + [JsonProperty("idType")] + public string IdType { get; set; } = string.Empty; + [JsonProperty("metaData")] + public IDIS_Template_Item_MetaData[] MetaData { get; set; } = Array.Empty(); + } +} \ No newline at end of file diff --git a/src/Models/IDIS_Template_Item_MetaData.cs b/src/Models/IDIS_Template_Item_MetaData.cs new file mode 100644 index 0000000..49caeed --- /dev/null +++ b/src/Models/IDIS_Template_Item_MetaData.cs @@ -0,0 +1,23 @@ +using System; +using Newtonsoft.Json; + +namespace IDIS +{ + + public class IDIS_Template_Item_MetaData + { + public IDIS_Template_Item_MetaData() + { + + } + public IDIS_Template_Item_MetaData(string type) + { + Type = type; + } + [JsonProperty("type")] public string Type { get; set; } = nameof(String); + [JsonProperty("minLength")] + public int MinLength { get; set; } + [JsonProperty("maxLength")] + public int MaxLength { get; set; } + } +} \ No newline at end of file diff --git a/src/Models/IDIS_TitleBarInfo.cs b/src/Models/IDIS_TitleBarInfo.cs new file mode 100644 index 0000000..a0fe97b --- /dev/null +++ b/src/Models/IDIS_TitleBarInfo.cs @@ -0,0 +1,23 @@ +using System; +using Newtonsoft.Json; + +namespace IDIS.Models +{ + public class TitleBarInfo + { + public TitleBarInfo() + { + Handle = $"88.123.99/{DateTime.Now.Ticks}"; + } + public TitleBarInfo(string handle) + { + Handle = handle; + } + [JsonProperty("count")] + public int Count { get; set; } + [JsonProperty("handle")] + public string Handle { get; set; } + [JsonProperty("type")] + public int Type { get; set; } + } +} \ No newline at end of file diff --git a/src/Services/IDIS_Service.cs b/src/Services/IDIS_Service.cs new file mode 100644 index 0000000..569cad5 --- /dev/null +++ b/src/Services/IDIS_Service.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using Cysharp.Threading.Tasks; +using IDIS.Models; + +namespace IDIS.Services +{ + /// + /// 标识解析节点的接口定义,包括了:增删改查,连接状态的回调 + /// + public interface IDIS_Service + { + /// + /// 已连接到服务的回调 + /// + event Action OnConnected; + + /// + /// 连接失败的回调 + /// + event Action OnConnectFailure; + + /// + /// 断开连接的回调 + /// + event Action OnDisconnected; + + /// + /// 基于标识模板注册标识 + /// + /// 标识码 + /// 标识模板 + /// 值,通常为字典 + /// + UniTask RegisterAsync(string handle, string templateVersion,IDictionary value); + + /// + /// 异步删除标识 + /// + /// 标识码 + /// 是否删除成功 + UniTask DeleteAsync(string code); + + /// + /// 异步删除标识 + /// + /// 标识码 + /// 标识索引 + /// + UniTask DeleteIdDataAsync(string code, int index); + + /// + /// 更新标识值 + /// + /// 标识码 + /// 需要更新的标识列表 + /// + UniTask UpdateAsync(string code, IDictionary value); + + /// + /// 异步解析标识 + /// + /// 标识码 + /// + UniTask QueryAsync(string code); + + /// + /// 标识码是否已注册 + /// + /// 标识码 + /// 是否已注册 + UniTask IsExistAsync(string code); + } +} \ No newline at end of file diff --git a/src/Services/IDIS_TemplateService.cs b/src/Services/IDIS_TemplateService.cs new file mode 100644 index 0000000..3623d48 --- /dev/null +++ b/src/Services/IDIS_TemplateService.cs @@ -0,0 +1,44 @@ +using System; +using Cysharp.Threading.Tasks; +using IDIS.Models; + +namespace IDIS.Services +{ + /// + /// 标识模板服务 + /// + public interface IDIS_TemplateService + { + event Action OnTemplateCreated; + event Action OnTemplateDeleted; + /// + /// 查询数据模板 + /// + /// 前缀 + /// 模板版本 + /// + UniTask QueryAsync(string prefix, string version); + + /// + /// 获取所有数据模板 + /// + /// + UniTask ToArrayAsync(); + + /// + /// 保存数据模板 + /// 模板不存在时为会新增模板信息 + /// + /// 模板信息 + /// + UniTask SaveAsync(IDIS_Template template); + + /// + /// 删除数据模板 + /// + /// + /// + /// + UniTask DeleteAsync (string prefix, string version); + } +} \ No newline at end of file