饭太稀
This commit is contained in:
BIN
Tools/Exporter/ConfigTable/CommandLine.dll
Normal file
BIN
Tools/Exporter/ConfigTable/CommandLine.dll
Normal file
Binary file not shown.
BIN
Tools/Exporter/ConfigTable/EPPlus.Interfaces.dll
Normal file
BIN
Tools/Exporter/ConfigTable/EPPlus.Interfaces.dll
Normal file
Binary file not shown.
BIN
Tools/Exporter/ConfigTable/EPPlus.System.Drawing.dll
Normal file
BIN
Tools/Exporter/ConfigTable/EPPlus.System.Drawing.dll
Normal file
Binary file not shown.
BIN
Tools/Exporter/ConfigTable/EPPlus.dll
Normal file
BIN
Tools/Exporter/ConfigTable/EPPlus.dll
Normal file
Binary file not shown.
44
Tools/Exporter/ConfigTable/ExporterSettings.json
Normal file
44
Tools/Exporter/ConfigTable/ExporterSettings.json
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"Export": {
|
||||
"ExcelProgramPath": {
|
||||
"Value": "../../../Examples/Config/Excel/",
|
||||
"Comment": "Excel文件夹的根目录"
|
||||
},
|
||||
"ExcelVersionFile": {
|
||||
"Value": "../../../Examples/Config/Excel/Version.txt",
|
||||
"Comment": "Excel的Version文件位置、这个文件用于记录每次导出对比是否需要再次导出的文件"
|
||||
},
|
||||
"ExcelServerFileDirectory": {
|
||||
"Value": "../../../Examples/Server/Entity/Generate/ConfigTable/Entity/",
|
||||
"Comment": "Excel生成的代码文件、在服务端文件夹位置"
|
||||
},
|
||||
"ExcelClientFileDirectory": {
|
||||
"Value": "../../../Examples/Client/Unity/Assets/Scripts/Hotfix/Generate/ConfigTable/Entity/",
|
||||
"Comment": "Excel生成的代码文件、在客户端文件夹位置"
|
||||
},
|
||||
"ExcelServerBinaryDirectory": {
|
||||
"Value": "../../../Examples/Config/Binary/",
|
||||
"Comment": "Excel生成服务器二进制数据文件夹位置"
|
||||
},
|
||||
"ExcelClientBinaryDirectory": {
|
||||
"Value": "../../../Examples/Client/Unity/Assets/Bundles/Config/",
|
||||
"Comment": "Excel生成在客户端的二进制数据文件夹位置"
|
||||
},
|
||||
"ExcelServerJsonDirectory": {
|
||||
"Value": "../../../Examples/Config/Json/Server/",
|
||||
"Comment": "Excel生成在服务端的Json数据文件夹位置"
|
||||
},
|
||||
"ExcelClientJsonDirectory": {
|
||||
"Value": "../../../Examples/Config/Json/Client/",
|
||||
"Comment": "Excel生成在客户端的Json数据文件夹位置"
|
||||
},
|
||||
"ServerCustomExportDirectory": {
|
||||
"Value": "../../../Examples/Server/Entity/Generate/CustomExport/",
|
||||
"Comment": "Excel在服务端生成自定义代码的文件夹位置"
|
||||
},
|
||||
"ClientCustomExportDirectory": {
|
||||
"Value": "../../../Examples/Client/Unity/Assets/Scripts/Hotfix/Generate/CustomExport",
|
||||
"Comment": "Excel在客户端端生成自定义代码的文件夹位置"
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
Tools/Exporter/ConfigTable/Fantasy.Tools.ConfigTable
Normal file
BIN
Tools/Exporter/ConfigTable/Fantasy.Tools.ConfigTable
Normal file
Binary file not shown.
433
Tools/Exporter/ConfigTable/Fantasy.Tools.ConfigTable.deps.json
Normal file
433
Tools/Exporter/ConfigTable/Fantasy.Tools.ConfigTable.deps.json
Normal file
@@ -0,0 +1,433 @@
|
||||
{
|
||||
"runtimeTarget": {
|
||||
"name": ".NETCoreApp,Version=v9.0",
|
||||
"signature": ""
|
||||
},
|
||||
"compilationOptions": {},
|
||||
"targets": {
|
||||
".NETCoreApp,Version=v9.0": {
|
||||
"Fantasy.Tools.ConfigTable/1.0.0": {
|
||||
"dependencies": {
|
||||
"CommandLineParser": "2.9.1",
|
||||
"EPPlus": "8.0.5",
|
||||
"Microsoft.CodeAnalysis.CSharp": "4.14.0",
|
||||
"Microsoft.Extensions.Configuration.Json": "9.0.6",
|
||||
"Newtonsoft.Json": "13.0.3",
|
||||
"protobuf-net": "3.2.52"
|
||||
},
|
||||
"runtime": {
|
||||
"Fantasy.Tools.ConfigTable.dll": {}
|
||||
}
|
||||
},
|
||||
"CommandLineParser/2.9.1": {
|
||||
"runtime": {
|
||||
"lib/netstandard2.0/CommandLine.dll": {
|
||||
"assemblyVersion": "2.9.1.0",
|
||||
"fileVersion": "2.9.1.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"EPPlus/8.0.5": {
|
||||
"dependencies": {
|
||||
"EPPlus.Interfaces": "8.0.0",
|
||||
"Microsoft.Extensions.Configuration.Json": "9.0.6",
|
||||
"Microsoft.IO.RecyclableMemoryStream": "3.0.1",
|
||||
"System.ComponentModel.Annotations": "5.0.0",
|
||||
"System.Security.Cryptography.Pkcs": "9.0.3",
|
||||
"System.Security.Cryptography.Xml": "9.0.3",
|
||||
"System.Text.Encoding.CodePages": "9.0.3"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net9.0/EPPlus.dll": {
|
||||
"assemblyVersion": "8.0.5.0",
|
||||
"fileVersion": "8.0.5.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"EPPlus.Interfaces/8.0.0": {
|
||||
"runtime": {
|
||||
"lib/net9.0/EPPlus.Interfaces.dll": {
|
||||
"assemblyVersion": "8.0.0.0",
|
||||
"fileVersion": "8.0.0.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.CodeAnalysis.Analyzers/3.11.0": {},
|
||||
"Microsoft.CodeAnalysis.Common/4.14.0": {
|
||||
"dependencies": {
|
||||
"Microsoft.CodeAnalysis.Analyzers": "3.11.0",
|
||||
"System.Collections.Immutable": "9.0.0",
|
||||
"System.Reflection.Metadata": "9.0.0"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net9.0/Microsoft.CodeAnalysis.dll": {
|
||||
"assemblyVersion": "4.14.0.0",
|
||||
"fileVersion": "4.1400.25.26210"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.CodeAnalysis.CSharp/4.14.0": {
|
||||
"dependencies": {
|
||||
"Microsoft.CodeAnalysis.Analyzers": "3.11.0",
|
||||
"Microsoft.CodeAnalysis.Common": "4.14.0",
|
||||
"System.Collections.Immutable": "9.0.0",
|
||||
"System.Reflection.Metadata": "9.0.0"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net9.0/Microsoft.CodeAnalysis.CSharp.dll": {
|
||||
"assemblyVersion": "4.14.0.0",
|
||||
"fileVersion": "4.1400.25.26210"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.Configuration/9.0.6": {
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.Configuration.Abstractions": "9.0.6",
|
||||
"Microsoft.Extensions.Primitives": "9.0.6"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net9.0/Microsoft.Extensions.Configuration.dll": {
|
||||
"assemblyVersion": "9.0.0.0",
|
||||
"fileVersion": "9.0.625.26613"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.Configuration.Abstractions/9.0.6": {
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.Primitives": "9.0.6"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net9.0/Microsoft.Extensions.Configuration.Abstractions.dll": {
|
||||
"assemblyVersion": "9.0.0.0",
|
||||
"fileVersion": "9.0.625.26613"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.Configuration.FileExtensions/9.0.6": {
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.Configuration": "9.0.6",
|
||||
"Microsoft.Extensions.Configuration.Abstractions": "9.0.6",
|
||||
"Microsoft.Extensions.FileProviders.Abstractions": "9.0.6",
|
||||
"Microsoft.Extensions.FileProviders.Physical": "9.0.6",
|
||||
"Microsoft.Extensions.Primitives": "9.0.6"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net9.0/Microsoft.Extensions.Configuration.FileExtensions.dll": {
|
||||
"assemblyVersion": "9.0.0.0",
|
||||
"fileVersion": "9.0.625.26613"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.Configuration.Json/9.0.6": {
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.Configuration": "9.0.6",
|
||||
"Microsoft.Extensions.Configuration.Abstractions": "9.0.6",
|
||||
"Microsoft.Extensions.Configuration.FileExtensions": "9.0.6",
|
||||
"Microsoft.Extensions.FileProviders.Abstractions": "9.0.6"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net9.0/Microsoft.Extensions.Configuration.Json.dll": {
|
||||
"assemblyVersion": "9.0.0.0",
|
||||
"fileVersion": "9.0.625.26613"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.FileProviders.Abstractions/9.0.6": {
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.Primitives": "9.0.6"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net9.0/Microsoft.Extensions.FileProviders.Abstractions.dll": {
|
||||
"assemblyVersion": "9.0.0.0",
|
||||
"fileVersion": "9.0.625.26613"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.FileProviders.Physical/9.0.6": {
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.FileProviders.Abstractions": "9.0.6",
|
||||
"Microsoft.Extensions.FileSystemGlobbing": "9.0.6",
|
||||
"Microsoft.Extensions.Primitives": "9.0.6"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net9.0/Microsoft.Extensions.FileProviders.Physical.dll": {
|
||||
"assemblyVersion": "9.0.0.0",
|
||||
"fileVersion": "9.0.625.26613"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.FileSystemGlobbing/9.0.6": {
|
||||
"runtime": {
|
||||
"lib/net9.0/Microsoft.Extensions.FileSystemGlobbing.dll": {
|
||||
"assemblyVersion": "9.0.0.0",
|
||||
"fileVersion": "9.0.625.26613"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.Primitives/9.0.6": {
|
||||
"runtime": {
|
||||
"lib/net9.0/Microsoft.Extensions.Primitives.dll": {
|
||||
"assemblyVersion": "9.0.0.0",
|
||||
"fileVersion": "9.0.625.26613"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.IO.RecyclableMemoryStream/3.0.1": {
|
||||
"runtime": {
|
||||
"lib/net6.0/Microsoft.IO.RecyclableMemoryStream.dll": {
|
||||
"assemblyVersion": "3.0.1.0",
|
||||
"fileVersion": "3.0.1.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Newtonsoft.Json/13.0.3": {
|
||||
"runtime": {
|
||||
"lib/net6.0/Newtonsoft.Json.dll": {
|
||||
"assemblyVersion": "13.0.0.0",
|
||||
"fileVersion": "13.0.3.27908"
|
||||
}
|
||||
}
|
||||
},
|
||||
"protobuf-net/3.2.52": {
|
||||
"dependencies": {
|
||||
"protobuf-net.Core": "3.2.52"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net8.0/protobuf-net.dll": {
|
||||
"assemblyVersion": "3.0.0.0",
|
||||
"fileVersion": "3.2.52.62683"
|
||||
}
|
||||
}
|
||||
},
|
||||
"protobuf-net.Core/3.2.52": {
|
||||
"runtime": {
|
||||
"lib/net8.0/protobuf-net.Core.dll": {
|
||||
"assemblyVersion": "3.0.0.0",
|
||||
"fileVersion": "3.2.52.62683"
|
||||
}
|
||||
}
|
||||
},
|
||||
"System.Collections.Immutable/9.0.0": {},
|
||||
"System.ComponentModel.Annotations/5.0.0": {},
|
||||
"System.Reflection.Metadata/9.0.0": {},
|
||||
"System.Security.Cryptography.Pkcs/9.0.3": {
|
||||
"runtime": {
|
||||
"lib/net9.0/System.Security.Cryptography.Pkcs.dll": {
|
||||
"assemblyVersion": "9.0.0.0",
|
||||
"fileVersion": "9.0.325.11113"
|
||||
}
|
||||
},
|
||||
"runtimeTargets": {
|
||||
"runtimes/win/lib/net9.0/System.Security.Cryptography.Pkcs.dll": {
|
||||
"rid": "win",
|
||||
"assetType": "runtime",
|
||||
"assemblyVersion": "9.0.0.0",
|
||||
"fileVersion": "9.0.325.11113"
|
||||
}
|
||||
}
|
||||
},
|
||||
"System.Security.Cryptography.Xml/9.0.3": {
|
||||
"dependencies": {
|
||||
"System.Security.Cryptography.Pkcs": "9.0.3"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net9.0/System.Security.Cryptography.Xml.dll": {
|
||||
"assemblyVersion": "9.0.0.0",
|
||||
"fileVersion": "9.0.325.11113"
|
||||
}
|
||||
}
|
||||
},
|
||||
"System.Text.Encoding.CodePages/9.0.3": {
|
||||
"runtime": {
|
||||
"lib/net9.0/System.Text.Encoding.CodePages.dll": {
|
||||
"assemblyVersion": "9.0.0.0",
|
||||
"fileVersion": "9.0.325.11113"
|
||||
}
|
||||
},
|
||||
"runtimeTargets": {
|
||||
"runtimes/win/lib/net9.0/System.Text.Encoding.CodePages.dll": {
|
||||
"rid": "win",
|
||||
"assetType": "runtime",
|
||||
"assemblyVersion": "9.0.0.0",
|
||||
"fileVersion": "9.0.325.11113"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"libraries": {
|
||||
"Fantasy.Tools.ConfigTable/1.0.0": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
"sha512": ""
|
||||
},
|
||||
"CommandLineParser/2.9.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-OE0sl1/sQ37bjVsPKKtwQlWDgqaxWgtme3xZz7JssWUzg5JpMIyHgCTY9MVMxOg48fJ1AgGT3tgdH5m/kQ5xhA==",
|
||||
"path": "commandlineparser/2.9.1",
|
||||
"hashPath": "commandlineparser.2.9.1.nupkg.sha512"
|
||||
},
|
||||
"EPPlus/8.0.5": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-Q8H+E7yDy71I4hCONrb2OSUzkhJI9WSbSeJOCLji5iry45QAiffd14mLtdYocQCYFjQA04iCXomHjZitAJgm4Q==",
|
||||
"path": "epplus/8.0.5",
|
||||
"hashPath": "epplus.8.0.5.nupkg.sha512"
|
||||
},
|
||||
"EPPlus.Interfaces/8.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-EFr/vUbDYK55sxjfUfLUiv7oiz1f6ZLRYMKILHyfnWS019cYX5zJaQ1U3OojRuED8tgEeXX9QeG7Kj/b0XE7hQ==",
|
||||
"path": "epplus.interfaces/8.0.0",
|
||||
"hashPath": "epplus.interfaces.8.0.0.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.CodeAnalysis.Analyzers/3.11.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-v/EW3UE8/lbEYHoC2Qq7AR/DnmvpgdtAMndfQNmpuIMx/Mto8L5JnuCfdBYtgvalQOtfNCnxFejxuRrryvUTsg==",
|
||||
"path": "microsoft.codeanalysis.analyzers/3.11.0",
|
||||
"hashPath": "microsoft.codeanalysis.analyzers.3.11.0.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.CodeAnalysis.Common/4.14.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-PC3tuwZYnC+idaPuoC/AZpEdwrtX7qFpmnrfQkgobGIWiYmGi5MCRtl5mx6QrfMGQpK78X2lfIEoZDLg/qnuHg==",
|
||||
"path": "microsoft.codeanalysis.common/4.14.0",
|
||||
"hashPath": "microsoft.codeanalysis.common.4.14.0.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.CodeAnalysis.CSharp/4.14.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-568a6wcTivauIhbeWcCwfWwIn7UV7MeHEBvFB2uzGIpM2OhJ4eM/FZ8KS0yhPoNxnSpjGzz7x7CIjTxhslojQA==",
|
||||
"path": "microsoft.codeanalysis.csharp/4.14.0",
|
||||
"hashPath": "microsoft.codeanalysis.csharp.4.14.0.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.Extensions.Configuration/9.0.6": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-VWB5jdkxHsRiuoniTqwOL32R4OWyp5If/bAucLjRJczRVNcwb8iCXKLjn3Inv8fv+jHMVMnvQLg7xhSys+y5PA==",
|
||||
"path": "microsoft.extensions.configuration/9.0.6",
|
||||
"hashPath": "microsoft.extensions.configuration.9.0.6.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.Extensions.Configuration.Abstractions/9.0.6": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-3GgMIi2jP8g1fBW93Z9b9Unamc0SIsgyhiCmC91gq4loTixK9vQMuxxUsfJ1kRGwn+/FqLKwOHqmn0oYWn3Fvw==",
|
||||
"path": "microsoft.extensions.configuration.abstractions/9.0.6",
|
||||
"hashPath": "microsoft.extensions.configuration.abstractions.9.0.6.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.Extensions.Configuration.FileExtensions/9.0.6": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-pCEueasI5JhJ24KYzMFxtG40zyLnWpcQYawpARh9FNq9XbWozuWgexmdkPa8p8YoVNlpi3ecKfcjfoRMkKAufw==",
|
||||
"path": "microsoft.extensions.configuration.fileextensions/9.0.6",
|
||||
"hashPath": "microsoft.extensions.configuration.fileextensions.9.0.6.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.Extensions.Configuration.Json/9.0.6": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-N0dgOYQ9tDzJouL9Tyx2dgMCcHV2pBaY8yVtorbDqYYwiDRS2zd1TbhTA2FMHqXF3SMjBoO+gONZcDoA79gdSA==",
|
||||
"path": "microsoft.extensions.configuration.json/9.0.6",
|
||||
"hashPath": "microsoft.extensions.configuration.json.9.0.6.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.Extensions.FileProviders.Abstractions/9.0.6": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-q9FPkSGVA9ipI255p3PBAvWNXas5Tzjyp/DwYSwT+46mIFw9fWZahsF6vHpoxLt5/vtANotH2sAm7HunuFIx9g==",
|
||||
"path": "microsoft.extensions.fileproviders.abstractions/9.0.6",
|
||||
"hashPath": "microsoft.extensions.fileproviders.abstractions.9.0.6.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.Extensions.FileProviders.Physical/9.0.6": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-l+dFA0NRl90vSIiJNy5d7V0kpTEOWHTqbgoWYzlTwF5uiM5sWJ953haaELKE05jkyJdnemVTnqjrlgo4wo7oyg==",
|
||||
"path": "microsoft.extensions.fileproviders.physical/9.0.6",
|
||||
"hashPath": "microsoft.extensions.fileproviders.physical.9.0.6.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.Extensions.FileSystemGlobbing/9.0.6": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-1HJCAbwukNEoYbHgHbKHmenU0V/0huw8+i7Qtf5rLUG1E+3kEwRJQxpwD3wbTEagIgPSQisNgJTvmUX9yYVc6g==",
|
||||
"path": "microsoft.extensions.filesystemglobbing/9.0.6",
|
||||
"hashPath": "microsoft.extensions.filesystemglobbing.9.0.6.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.Extensions.Primitives/9.0.6": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-BHniU24QV67qp1pJknqYSofAPYGmijGI8D+ci9yfw33iuFdyOeB9lWTg78ThyYLyQwZw3s0vZ36VMb0MqbUuLw==",
|
||||
"path": "microsoft.extensions.primitives/9.0.6",
|
||||
"hashPath": "microsoft.extensions.primitives.9.0.6.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.IO.RecyclableMemoryStream/3.0.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-s/s20YTVY9r9TPfTrN5g8zPF1YhwxyqO6PxUkrYTGI2B+OGPe9AdajWZrLhFqXIvqIW23fnUE4+ztrUWNU1+9g==",
|
||||
"path": "microsoft.io.recyclablememorystream/3.0.1",
|
||||
"hashPath": "microsoft.io.recyclablememorystream.3.0.1.nupkg.sha512"
|
||||
},
|
||||
"Newtonsoft.Json/13.0.3": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ==",
|
||||
"path": "newtonsoft.json/13.0.3",
|
||||
"hashPath": "newtonsoft.json.13.0.3.nupkg.sha512"
|
||||
},
|
||||
"protobuf-net/3.2.52": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-XbZurNU3B/VaL/5OJ0kshO+AWxsZroI1saKuLfZpDwH2ngb2K9bdF1nIW6elFOViZw7TQCmfVZapxrMKCDqecQ==",
|
||||
"path": "protobuf-net/3.2.52",
|
||||
"hashPath": "protobuf-net.3.2.52.nupkg.sha512"
|
||||
},
|
||||
"protobuf-net.Core/3.2.52": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-zOpGtUo2QTgbsiI0D0yCe8aUTgDPov6kqIu1CDHI6isqhYcAHdirRrdnfsQXmAUfAWx1LwVYGgC6xe6fNS4UAg==",
|
||||
"path": "protobuf-net.core/3.2.52",
|
||||
"hashPath": "protobuf-net.core.3.2.52.nupkg.sha512"
|
||||
},
|
||||
"System.Collections.Immutable/9.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-QhkXUl2gNrQtvPmtBTQHb0YsUrDiDQ2QS09YbtTTiSjGcf7NBqtYbrG/BE06zcBPCKEwQGzIv13IVdXNOSub2w==",
|
||||
"path": "system.collections.immutable/9.0.0",
|
||||
"hashPath": "system.collections.immutable.9.0.0.nupkg.sha512"
|
||||
},
|
||||
"System.ComponentModel.Annotations/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-dMkqfy2el8A8/I76n2Hi1oBFEbG1SfxD2l5nhwXV3XjlnOmwxJlQbYpJH4W51odnU9sARCSAgv7S3CyAFMkpYg==",
|
||||
"path": "system.componentmodel.annotations/5.0.0",
|
||||
"hashPath": "system.componentmodel.annotations.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"System.Reflection.Metadata/9.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-ANiqLu3DxW9kol/hMmTWbt3414t9ftdIuiIU7j80okq2YzAueo120M442xk1kDJWtmZTqWQn7wHDvMRipVOEOQ==",
|
||||
"path": "system.reflection.metadata/9.0.0",
|
||||
"hashPath": "system.reflection.metadata.9.0.0.nupkg.sha512"
|
||||
},
|
||||
"System.Security.Cryptography.Pkcs/9.0.3": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-4XYeGOYBYtvaF2bH+cps+vPWjI5jQCWR7R1B4dI9I1Da9JQrXYP7mxdci+zKV2Ie4JafaOnOoNaDtzxkaXUxCg==",
|
||||
"path": "system.security.cryptography.pkcs/9.0.3",
|
||||
"hashPath": "system.security.cryptography.pkcs.9.0.3.nupkg.sha512"
|
||||
},
|
||||
"System.Security.Cryptography.Xml/9.0.3": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-dPG84G5/szhNQ8utXUB4NmrJLGvFe8yd4P0MFjy0/VNxkQNGR6CkkLjptkO5b5rcnw/4c2xDKcrwLxgc1zKWgg==",
|
||||
"path": "system.security.cryptography.xml/9.0.3",
|
||||
"hashPath": "system.security.cryptography.xml.9.0.3.nupkg.sha512"
|
||||
},
|
||||
"System.Text.Encoding.CodePages/9.0.3": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-80ABiml18jG+6PB6GmrOyMlWla66f4Tp6RgUCJXZLki1Zu+yqbflXvweT86j2xImKHXoVgivto25Z8P5+FO85w==",
|
||||
"path": "system.text.encoding.codepages/9.0.3",
|
||||
"hashPath": "system.text.encoding.codepages.9.0.3.nupkg.sha512"
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
Tools/Exporter/ConfigTable/Fantasy.Tools.ConfigTable.dll
Normal file
BIN
Tools/Exporter/ConfigTable/Fantasy.Tools.ConfigTable.dll
Normal file
Binary file not shown.
BIN
Tools/Exporter/ConfigTable/Fantasy.Tools.ConfigTable.pdb
Normal file
BIN
Tools/Exporter/ConfigTable/Fantasy.Tools.ConfigTable.pdb
Normal file
Binary file not shown.
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"runtimeOptions": {
|
||||
"tfm": "net9.0",
|
||||
"framework": {
|
||||
"name": "Microsoft.NETCore.App",
|
||||
"version": "9.0.0"
|
||||
},
|
||||
"configProperties": {
|
||||
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
Tools/Exporter/ConfigTable/Microsoft.CodeAnalysis.CSharp.dll
Normal file
BIN
Tools/Exporter/ConfigTable/Microsoft.CodeAnalysis.CSharp.dll
Normal file
Binary file not shown.
BIN
Tools/Exporter/ConfigTable/Microsoft.CodeAnalysis.dll
Normal file
BIN
Tools/Exporter/ConfigTable/Microsoft.CodeAnalysis.dll
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Tools/Exporter/ConfigTable/Microsoft.Extensions.Primitives.dll
Normal file
BIN
Tools/Exporter/ConfigTable/Microsoft.Extensions.Primitives.dll
Normal file
Binary file not shown.
Binary file not shown.
BIN
Tools/Exporter/ConfigTable/Microsoft.Win32.SystemEvents.dll
Normal file
BIN
Tools/Exporter/ConfigTable/Microsoft.Win32.SystemEvents.dll
Normal file
Binary file not shown.
BIN
Tools/Exporter/ConfigTable/Newtonsoft.Json.dll
Normal file
BIN
Tools/Exporter/ConfigTable/Newtonsoft.Json.dll
Normal file
Binary file not shown.
33
Tools/Exporter/ConfigTable/Run.bat
Normal file
33
Tools/Exporter/ConfigTable/Run.bat
Normal file
@@ -0,0 +1,33 @@
|
||||
@echo off
|
||||
|
||||
echo Please select an option:
|
||||
echo 1. Client Increment
|
||||
echo 2. Client all
|
||||
echo 3. Server Increment
|
||||
echo 4. Server all
|
||||
echo 5. Client and Server Increment
|
||||
echo 6. Client and Server all
|
||||
|
||||
set /p choice=Please select an option:
|
||||
|
||||
if "%choice%"=="1" (
|
||||
echo Client Increment
|
||||
dotnet Fantasy.Tools.ConfigTable.dll --p 1 --e 1
|
||||
) else if "%choice%"=="2" (
|
||||
echo Client all
|
||||
dotnet Fantasy.Tools.ConfigTable.dll --p 1 --e 2
|
||||
) else if "%choice%"=="3" (
|
||||
echo Server Increment
|
||||
dotnet Fantasy.Tools.ConfigTable.dll --p 2 --e 1
|
||||
) else if "%choice%"=="4" (
|
||||
echo Server all
|
||||
dotnet Fantasy.Tools.ConfigTable.dll --p 2 --e 2
|
||||
) else if "%choice%"=="5" (
|
||||
echo Client and Server Increment
|
||||
dotnet Fantasy.Tools.ConfigTable.dll --p 3 --e 1
|
||||
) else if "%choice%"=="6" (
|
||||
echo Client and Server all
|
||||
dotnet Fantasy.Tools.ConfigTable.dll --p 3 --e 2
|
||||
) else (
|
||||
echo Invalid option
|
||||
)
|
||||
34
Tools/Exporter/ConfigTable/Run.sh
Normal file
34
Tools/Exporter/ConfigTable/Run.sh
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "1. Client Increment"
|
||||
echo "2. Client all"
|
||||
echo "3. Server Increment"
|
||||
echo "4. Server all"
|
||||
echo "5. Client and Server Increment"
|
||||
echo "6. Client and Server all"
|
||||
|
||||
read -n 1 -p "Please select an option:" choice
|
||||
echo ""
|
||||
case $choice in
|
||||
1)
|
||||
dotnet Fantasy.Tools.ConfigTable.dll --p 1 --e 1
|
||||
;;
|
||||
2)
|
||||
dotnet Fantasy.Tools.ConfigTable.dll --p 1 --e 2
|
||||
;;
|
||||
3)
|
||||
dotnet Fantasy.Tools.ConfigTable.dll --p 2 --e 1
|
||||
;;
|
||||
4)
|
||||
dotnet Fantasy.Tools.ConfigTable.dll --p 2 --e 2
|
||||
;;
|
||||
5)
|
||||
dotnet Fantasy.Tools.ConfigTable.dll --p 3 --e 1
|
||||
;;
|
||||
6)
|
||||
dotnet Fantasy.Tools.ConfigTable.dll --p 3 --e 2
|
||||
;;
|
||||
*)
|
||||
echo "Invalid option"
|
||||
;;
|
||||
esac
|
||||
BIN
Tools/Exporter/ConfigTable/System.Collections.Immutable.dll
Normal file
BIN
Tools/Exporter/ConfigTable/System.Collections.Immutable.dll
Normal file
Binary file not shown.
BIN
Tools/Exporter/ConfigTable/System.Drawing.Common.dll
Normal file
BIN
Tools/Exporter/ConfigTable/System.Drawing.Common.dll
Normal file
Binary file not shown.
BIN
Tools/Exporter/ConfigTable/System.IO.Pipelines.dll
Normal file
BIN
Tools/Exporter/ConfigTable/System.IO.Pipelines.dll
Normal file
Binary file not shown.
BIN
Tools/Exporter/ConfigTable/System.Reflection.Metadata.dll
Normal file
BIN
Tools/Exporter/ConfigTable/System.Reflection.Metadata.dll
Normal file
Binary file not shown.
BIN
Tools/Exporter/ConfigTable/System.Security.Cryptography.Pkcs.dll
Normal file
BIN
Tools/Exporter/ConfigTable/System.Security.Cryptography.Pkcs.dll
Normal file
Binary file not shown.
BIN
Tools/Exporter/ConfigTable/System.Security.Cryptography.Xml.dll
Normal file
BIN
Tools/Exporter/ConfigTable/System.Security.Cryptography.Xml.dll
Normal file
Binary file not shown.
BIN
Tools/Exporter/ConfigTable/System.Text.Encoding.CodePages.dll
Normal file
BIN
Tools/Exporter/ConfigTable/System.Text.Encoding.CodePages.dll
Normal file
Binary file not shown.
BIN
Tools/Exporter/ConfigTable/System.Text.Encodings.Web.dll
Normal file
BIN
Tools/Exporter/ConfigTable/System.Text.Encodings.Web.dll
Normal file
Binary file not shown.
BIN
Tools/Exporter/ConfigTable/System.Text.Json.dll
Normal file
BIN
Tools/Exporter/ConfigTable/System.Text.Json.dll
Normal file
Binary file not shown.
BIN
Tools/Exporter/ConfigTable/protobuf-net.Core.dll
Normal file
BIN
Tools/Exporter/ConfigTable/protobuf-net.Core.dll
Normal file
Binary file not shown.
BIN
Tools/Exporter/ConfigTable/protobuf-net.dll
Normal file
BIN
Tools/Exporter/ConfigTable/protobuf-net.dll
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Tools/Exporter/NetworkProtocol/CommandLine.dll
Normal file
BIN
Tools/Exporter/NetworkProtocol/CommandLine.dll
Normal file
Binary file not shown.
29
Tools/Exporter/NetworkProtocol/ExporterSettings.json
Normal file
29
Tools/Exporter/NetworkProtocol/ExporterSettings.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"Export": {
|
||||
"NetworkProtocolDirectory": {
|
||||
"Value": "../../../Examples/Config/NetworkProtocol/",
|
||||
"Comment": "ProtoBuf文件所在的文件夹位置"
|
||||
},
|
||||
"NetworkProtocolServerDirectory": {
|
||||
"Value": "../../../Examples/Server/Entity/Generate/NetworkProtocol/",
|
||||
"Comment": "ProtoBuf生成到服务端的文件夹位置"
|
||||
},
|
||||
"NetworkProtocolClientDirectory": {
|
||||
"Value": "../../../Examples/Client/Unity/Assets/Scripts/Hotfix/Generate/NetworkProtocol/",
|
||||
"Comment": "ProtoBuf生成到客户端的文件夹位置"
|
||||
},
|
||||
"Serializes": {
|
||||
"Value": [
|
||||
// {
|
||||
// "KeyIndex": 0,
|
||||
// "NameSpace" : "MemoryPack",
|
||||
// "SerializeName": "MemoryPack",
|
||||
// "Attribute": "\t[MemoryPackable]",
|
||||
// "Ignore": "\t\t[MemoryPackIgnore]",
|
||||
// "Member": "MemoryPackOrder"
|
||||
// }
|
||||
],
|
||||
"Comment": "自定义序列化器"
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
Tools/Exporter/NetworkProtocol/Fantasy.Tools.NetworkProtocol
Normal file
BIN
Tools/Exporter/NetworkProtocol/Fantasy.Tools.NetworkProtocol
Normal file
Binary file not shown.
@@ -0,0 +1,264 @@
|
||||
{
|
||||
"runtimeTarget": {
|
||||
"name": ".NETCoreApp,Version=v8.0",
|
||||
"signature": ""
|
||||
},
|
||||
"compilationOptions": {},
|
||||
"targets": {
|
||||
".NETCoreApp,Version=v8.0": {
|
||||
"Fantasy.Tools.NetworkProtocol/1.0.0": {
|
||||
"dependencies": {
|
||||
"CommandLineParser": "2.9.1",
|
||||
"Microsoft.Extensions.Configuration.Json": "9.0.6",
|
||||
"Newtonsoft.Json": "13.0.3"
|
||||
},
|
||||
"runtime": {
|
||||
"Fantasy.Tools.NetworkProtocol.dll": {}
|
||||
}
|
||||
},
|
||||
"CommandLineParser/2.9.1": {
|
||||
"runtime": {
|
||||
"lib/netstandard2.0/CommandLine.dll": {
|
||||
"assemblyVersion": "2.9.1.0",
|
||||
"fileVersion": "2.9.1.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.Configuration/9.0.6": {
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.Configuration.Abstractions": "9.0.6",
|
||||
"Microsoft.Extensions.Primitives": "9.0.6"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net8.0/Microsoft.Extensions.Configuration.dll": {
|
||||
"assemblyVersion": "9.0.0.0",
|
||||
"fileVersion": "9.0.625.26613"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.Configuration.Abstractions/9.0.6": {
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.Primitives": "9.0.6"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net8.0/Microsoft.Extensions.Configuration.Abstractions.dll": {
|
||||
"assemblyVersion": "9.0.0.0",
|
||||
"fileVersion": "9.0.625.26613"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.Configuration.FileExtensions/9.0.6": {
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.Configuration": "9.0.6",
|
||||
"Microsoft.Extensions.Configuration.Abstractions": "9.0.6",
|
||||
"Microsoft.Extensions.FileProviders.Abstractions": "9.0.6",
|
||||
"Microsoft.Extensions.FileProviders.Physical": "9.0.6",
|
||||
"Microsoft.Extensions.Primitives": "9.0.6"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net8.0/Microsoft.Extensions.Configuration.FileExtensions.dll": {
|
||||
"assemblyVersion": "9.0.0.0",
|
||||
"fileVersion": "9.0.625.26613"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.Configuration.Json/9.0.6": {
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.Configuration": "9.0.6",
|
||||
"Microsoft.Extensions.Configuration.Abstractions": "9.0.6",
|
||||
"Microsoft.Extensions.Configuration.FileExtensions": "9.0.6",
|
||||
"Microsoft.Extensions.FileProviders.Abstractions": "9.0.6",
|
||||
"System.Text.Json": "9.0.6"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net8.0/Microsoft.Extensions.Configuration.Json.dll": {
|
||||
"assemblyVersion": "9.0.0.0",
|
||||
"fileVersion": "9.0.625.26613"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.FileProviders.Abstractions/9.0.6": {
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.Primitives": "9.0.6"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net8.0/Microsoft.Extensions.FileProviders.Abstractions.dll": {
|
||||
"assemblyVersion": "9.0.0.0",
|
||||
"fileVersion": "9.0.625.26613"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.FileProviders.Physical/9.0.6": {
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.FileProviders.Abstractions": "9.0.6",
|
||||
"Microsoft.Extensions.FileSystemGlobbing": "9.0.6",
|
||||
"Microsoft.Extensions.Primitives": "9.0.6"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net8.0/Microsoft.Extensions.FileProviders.Physical.dll": {
|
||||
"assemblyVersion": "9.0.0.0",
|
||||
"fileVersion": "9.0.625.26613"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.FileSystemGlobbing/9.0.6": {
|
||||
"runtime": {
|
||||
"lib/net8.0/Microsoft.Extensions.FileSystemGlobbing.dll": {
|
||||
"assemblyVersion": "9.0.0.0",
|
||||
"fileVersion": "9.0.625.26613"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.Primitives/9.0.6": {
|
||||
"runtime": {
|
||||
"lib/net8.0/Microsoft.Extensions.Primitives.dll": {
|
||||
"assemblyVersion": "9.0.0.0",
|
||||
"fileVersion": "9.0.625.26613"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Newtonsoft.Json/13.0.3": {
|
||||
"runtime": {
|
||||
"lib/net6.0/Newtonsoft.Json.dll": {
|
||||
"assemblyVersion": "13.0.0.0",
|
||||
"fileVersion": "13.0.3.27908"
|
||||
}
|
||||
}
|
||||
},
|
||||
"System.IO.Pipelines/9.0.6": {
|
||||
"runtime": {
|
||||
"lib/net8.0/System.IO.Pipelines.dll": {
|
||||
"assemblyVersion": "9.0.0.0",
|
||||
"fileVersion": "9.0.625.26613"
|
||||
}
|
||||
}
|
||||
},
|
||||
"System.Text.Encodings.Web/9.0.6": {
|
||||
"runtime": {
|
||||
"lib/net8.0/System.Text.Encodings.Web.dll": {
|
||||
"assemblyVersion": "9.0.0.0",
|
||||
"fileVersion": "9.0.625.26613"
|
||||
}
|
||||
},
|
||||
"runtimeTargets": {
|
||||
"runtimes/browser/lib/net8.0/System.Text.Encodings.Web.dll": {
|
||||
"rid": "browser",
|
||||
"assetType": "runtime",
|
||||
"assemblyVersion": "9.0.0.0",
|
||||
"fileVersion": "9.0.625.26613"
|
||||
}
|
||||
}
|
||||
},
|
||||
"System.Text.Json/9.0.6": {
|
||||
"dependencies": {
|
||||
"System.IO.Pipelines": "9.0.6",
|
||||
"System.Text.Encodings.Web": "9.0.6"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net8.0/System.Text.Json.dll": {
|
||||
"assemblyVersion": "9.0.0.0",
|
||||
"fileVersion": "9.0.625.26613"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"libraries": {
|
||||
"Fantasy.Tools.NetworkProtocol/1.0.0": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
"sha512": ""
|
||||
},
|
||||
"CommandLineParser/2.9.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-OE0sl1/sQ37bjVsPKKtwQlWDgqaxWgtme3xZz7JssWUzg5JpMIyHgCTY9MVMxOg48fJ1AgGT3tgdH5m/kQ5xhA==",
|
||||
"path": "commandlineparser/2.9.1",
|
||||
"hashPath": "commandlineparser.2.9.1.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.Extensions.Configuration/9.0.6": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-VWB5jdkxHsRiuoniTqwOL32R4OWyp5If/bAucLjRJczRVNcwb8iCXKLjn3Inv8fv+jHMVMnvQLg7xhSys+y5PA==",
|
||||
"path": "microsoft.extensions.configuration/9.0.6",
|
||||
"hashPath": "microsoft.extensions.configuration.9.0.6.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.Extensions.Configuration.Abstractions/9.0.6": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-3GgMIi2jP8g1fBW93Z9b9Unamc0SIsgyhiCmC91gq4loTixK9vQMuxxUsfJ1kRGwn+/FqLKwOHqmn0oYWn3Fvw==",
|
||||
"path": "microsoft.extensions.configuration.abstractions/9.0.6",
|
||||
"hashPath": "microsoft.extensions.configuration.abstractions.9.0.6.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.Extensions.Configuration.FileExtensions/9.0.6": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-pCEueasI5JhJ24KYzMFxtG40zyLnWpcQYawpARh9FNq9XbWozuWgexmdkPa8p8YoVNlpi3ecKfcjfoRMkKAufw==",
|
||||
"path": "microsoft.extensions.configuration.fileextensions/9.0.6",
|
||||
"hashPath": "microsoft.extensions.configuration.fileextensions.9.0.6.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.Extensions.Configuration.Json/9.0.6": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-N0dgOYQ9tDzJouL9Tyx2dgMCcHV2pBaY8yVtorbDqYYwiDRS2zd1TbhTA2FMHqXF3SMjBoO+gONZcDoA79gdSA==",
|
||||
"path": "microsoft.extensions.configuration.json/9.0.6",
|
||||
"hashPath": "microsoft.extensions.configuration.json.9.0.6.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.Extensions.FileProviders.Abstractions/9.0.6": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-q9FPkSGVA9ipI255p3PBAvWNXas5Tzjyp/DwYSwT+46mIFw9fWZahsF6vHpoxLt5/vtANotH2sAm7HunuFIx9g==",
|
||||
"path": "microsoft.extensions.fileproviders.abstractions/9.0.6",
|
||||
"hashPath": "microsoft.extensions.fileproviders.abstractions.9.0.6.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.Extensions.FileProviders.Physical/9.0.6": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-l+dFA0NRl90vSIiJNy5d7V0kpTEOWHTqbgoWYzlTwF5uiM5sWJ953haaELKE05jkyJdnemVTnqjrlgo4wo7oyg==",
|
||||
"path": "microsoft.extensions.fileproviders.physical/9.0.6",
|
||||
"hashPath": "microsoft.extensions.fileproviders.physical.9.0.6.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.Extensions.FileSystemGlobbing/9.0.6": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-1HJCAbwukNEoYbHgHbKHmenU0V/0huw8+i7Qtf5rLUG1E+3kEwRJQxpwD3wbTEagIgPSQisNgJTvmUX9yYVc6g==",
|
||||
"path": "microsoft.extensions.filesystemglobbing/9.0.6",
|
||||
"hashPath": "microsoft.extensions.filesystemglobbing.9.0.6.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.Extensions.Primitives/9.0.6": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-BHniU24QV67qp1pJknqYSofAPYGmijGI8D+ci9yfw33iuFdyOeB9lWTg78ThyYLyQwZw3s0vZ36VMb0MqbUuLw==",
|
||||
"path": "microsoft.extensions.primitives/9.0.6",
|
||||
"hashPath": "microsoft.extensions.primitives.9.0.6.nupkg.sha512"
|
||||
},
|
||||
"Newtonsoft.Json/13.0.3": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ==",
|
||||
"path": "newtonsoft.json/13.0.3",
|
||||
"hashPath": "newtonsoft.json.13.0.3.nupkg.sha512"
|
||||
},
|
||||
"System.IO.Pipelines/9.0.6": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-0nlr0reXrRmkZNKifKqh2DgGhQgfkT7Qa3gQxIn/JI7/y3WDiTz67M+Sq3vFhUqcG8O5zVrpqHvIHeGPGUBsEw==",
|
||||
"path": "system.io.pipelines/9.0.6",
|
||||
"hashPath": "system.io.pipelines.9.0.6.nupkg.sha512"
|
||||
},
|
||||
"System.Text.Encodings.Web/9.0.6": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-uWRgViw2yJAUyGxrzDLCc6fkzE2dZIoXxs8V6YjCujKsJuP0pnpYSlbm2/7tKd0SjBnMtwfDQhLenk3bXonVOA==",
|
||||
"path": "system.text.encodings.web/9.0.6",
|
||||
"hashPath": "system.text.encodings.web.9.0.6.nupkg.sha512"
|
||||
},
|
||||
"System.Text.Json/9.0.6": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-h+ZtYTyTnTh5Ju6mHCKb3FPGx4ylJZgm9W7Y2psUnkhQRPMOIxX+TCN0ZgaR/+Yea+93XHWAaMzYTar1/EHIPg==",
|
||||
"path": "system.text.json/9.0.6",
|
||||
"hashPath": "system.text.json.9.0.6.nupkg.sha512"
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
Tools/Exporter/NetworkProtocol/Fantasy.Tools.NetworkProtocol.dll
Normal file
BIN
Tools/Exporter/NetworkProtocol/Fantasy.Tools.NetworkProtocol.dll
Normal file
Binary file not shown.
BIN
Tools/Exporter/NetworkProtocol/Fantasy.Tools.NetworkProtocol.pdb
Normal file
BIN
Tools/Exporter/NetworkProtocol/Fantasy.Tools.NetworkProtocol.pdb
Normal file
Binary file not shown.
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"runtimeOptions": {
|
||||
"tfm": "net8.0",
|
||||
"framework": {
|
||||
"name": "Microsoft.NETCore.App",
|
||||
"version": "8.0.0"
|
||||
},
|
||||
"configProperties": {
|
||||
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Tools/Exporter/NetworkProtocol/Newtonsoft.Json.dll
Normal file
BIN
Tools/Exporter/NetworkProtocol/Newtonsoft.Json.dll
Normal file
Binary file not shown.
21
Tools/Exporter/NetworkProtocol/Run.bat
Normal file
21
Tools/Exporter/NetworkProtocol/Run.bat
Normal file
@@ -0,0 +1,21 @@
|
||||
@echo off
|
||||
|
||||
echo Please select an option:
|
||||
echo 1. Client
|
||||
echo 2. Server
|
||||
echo 3. All
|
||||
|
||||
set /p choice=Please select an option:
|
||||
|
||||
if "%choice%"=="1" (
|
||||
echo Client
|
||||
dotnet Fantasy.Tools.NetworkProtocol.dll --p 1
|
||||
) else if "%choice%"=="2" (
|
||||
echo Server
|
||||
dotnet Fantasy.Tools.NetworkProtocol.dll --p 2
|
||||
) else if "%choice%"=="3" (
|
||||
echo All
|
||||
dotnet Fantasy.Tools.NetworkProtocol.dll --p 3
|
||||
) else (
|
||||
echo Invalid option
|
||||
)
|
||||
24
Tools/Exporter/NetworkProtocol/Run.sh
Normal file
24
Tools/Exporter/NetworkProtocol/Run.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "1. Client"
|
||||
echo "2. Server"
|
||||
echo "3. All"
|
||||
|
||||
read -n 1 -p "Please select an option:" choice
|
||||
echo ""
|
||||
echo ""
|
||||
script_dir=$(cd $(dirname $0) && pwd)
|
||||
case $choice in
|
||||
1)
|
||||
dotnet $script_dir/Fantasy.Tools.NetworkProtocol.dll --p 1 --f $script_dir
|
||||
;;
|
||||
2)
|
||||
dotnet $script_dir/Fantasy.Tools.NetworkProtocol.dll --p 2 --f $script_dir
|
||||
;;
|
||||
3)
|
||||
dotnet $script_dir/Fantasy.Tools.NetworkProtocol.dll --p 3 --f $script_dir
|
||||
;;
|
||||
*)
|
||||
echo "Invalid option"
|
||||
;;
|
||||
esac
|
||||
BIN
Tools/Exporter/NetworkProtocol/System.IO.Pipelines.dll
Normal file
BIN
Tools/Exporter/NetworkProtocol/System.IO.Pipelines.dll
Normal file
Binary file not shown.
BIN
Tools/Exporter/NetworkProtocol/System.Text.Encodings.Web.dll
Normal file
BIN
Tools/Exporter/NetworkProtocol/System.Text.Encodings.Web.dll
Normal file
Binary file not shown.
BIN
Tools/Exporter/NetworkProtocol/System.Text.Json.dll
Normal file
BIN
Tools/Exporter/NetworkProtocol/System.Text.Json.dll
Normal file
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,9 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<!-- 物理复制 Exporter 文件到项目根目录 -->
|
||||
<Target Name="CopyExporterFilesToProject" BeforeTargets="PrepareForBuild">
|
||||
<ItemGroup>
|
||||
<ExporterFilesToCopy Include="$(MSBuildThisFileDirectory)..\tools\output\**\*" />
|
||||
</ItemGroup>
|
||||
<Copy SourceFiles="@(ExporterFilesToCopy)" DestinationFolder="$(MSBuildProjectDirectory)/Tools/Exporter/ConfigTable" SkipUnchangedFiles="true" />
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -0,0 +1,32 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<PackageId>Fantasy-Net.Tools.ExporterConfigTable</PackageId>
|
||||
<PackageVersion>2024.2.26</PackageVersion>
|
||||
<Title>Fantasy-Net.Tools.ExporterConfigTable</Title>
|
||||
<Authors>qq362946</Authors>
|
||||
<owners>qq362946</owners>
|
||||
<PackageOutputPath>../../../nupkg</PackageOutputPath>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<Description>
|
||||
Fantasy is a high-performance network development framework based on .NET, supporting mainstream protocols. It is designed for development teams or individuals needing a quick start, scalability, and a distributed, cross-platform solution at the commercial level. Fantasy aims to provide easy-to-use tools while ensuring high system performance and scalability.</Description>
|
||||
<Copyright>Copyright 2026 qq362946</Copyright>
|
||||
<PackageProjectUrl>https://www.code-fantasy.com/</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/qq362946/Fantasy</RepositoryUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<PackageTags>Net, c#, Server, Game, GameServer, Fantasy , Network</PackageTags>
|
||||
<PackageIcon>icon.png</PackageIcon>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
|
||||
<LangVersion>default</LangVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Include="../../Exporter/ConfigTable/**/*" Pack="true" PackagePath="tools\output\" />
|
||||
<None Include="icon.png" Pack="true" PackagePath="\"/>
|
||||
<None Include="Fantasy-Net.Tools.ExporterConfigTable.targets" Pack="true" PackagePath="buildTransitive" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="**\.DS_Store" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
BIN
Tools/NuGet/Fantasy.Tools.ExporterConfigTable/icon.png
Normal file
BIN
Tools/NuGet/Fantasy.Tools.ExporterConfigTable/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 246 B |
@@ -0,0 +1,9 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<!-- 物理复制 Exporter 文件到项目根目录 -->
|
||||
<Target Name="CopyExporterFilesToProject" BeforeTargets="PrepareForBuild">
|
||||
<ItemGroup>
|
||||
<ExporterFilesToCopy Include="$(MSBuildThisFileDirectory)..\tools\output\**\*" />
|
||||
</ItemGroup>
|
||||
<Copy SourceFiles="@(ExporterFilesToCopy)" DestinationFolder="$(MSBuildProjectDirectory)/Tools/Exporter/NetworkProtocol" SkipUnchangedFiles="true" />
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -0,0 +1,32 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<PackageId>Fantasy-Net.Tools.ExporterNetworkProtocol</PackageId>
|
||||
<PackageVersion>2024.2.26</PackageVersion>
|
||||
<Title>Fantasy-Net.Tools.ExporterNetworkProtocol</Title>
|
||||
<Authors>qq362946</Authors>
|
||||
<owners>qq362946</owners>
|
||||
<PackageOutputPath>../../../nupkg</PackageOutputPath>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<Description>
|
||||
Fantasy is a high-performance network development framework based on .NET, supporting mainstream protocols. It is designed for development teams or individuals needing a quick start, scalability, and a distributed, cross-platform solution at the commercial level. Fantasy aims to provide easy-to-use tools while ensuring high system performance and scalability.</Description>
|
||||
<Copyright>Copyright 2026 qq362946</Copyright>
|
||||
<PackageProjectUrl>https://www.code-fantasy.com/</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/qq362946/Fantasy</RepositoryUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<PackageTags>Net, c#, Server, Game, GameServer, Fantasy , Network</PackageTags>
|
||||
<PackageIcon>icon.png</PackageIcon>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
|
||||
<LangVersion>default</LangVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Include="../../Exporter/NetworkProtocol/**/*" Pack="true" PackagePath="tools\output\" />
|
||||
<None Include="icon.png" Pack="true" PackagePath="\"/>
|
||||
<None Include="Fantasy-Net.Tools.ExporterNetworkProtocol.targets" Pack="true" PackagePath="buildTransitive" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="**\.DS_Store" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
BIN
Tools/NuGet/Fantasy.Tools.ExporterNetworkProtocol/icon.png
Normal file
BIN
Tools/NuGet/Fantasy.Tools.ExporterNetworkProtocol/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 246 B |
@@ -0,0 +1,24 @@
|
||||
namespace Fantasy.Tools.ConfigTable;
|
||||
|
||||
/// <summary>
|
||||
/// 导出类型枚举,用于标识不同类型的导出操作。
|
||||
/// </summary>
|
||||
public enum ExportType
|
||||
{
|
||||
/// <summary>
|
||||
/// 无导出类型。
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// 所有数据的增量导出Excel类型。
|
||||
/// </summary>
|
||||
AllExcelIncrement = 1,
|
||||
/// <summary>
|
||||
/// 所有数据的全量导出Excel类型。
|
||||
/// </summary>
|
||||
AllExcel = 2,
|
||||
/// <summary>
|
||||
/// 导出类型枚举的最大值,一定要放在最后。
|
||||
/// </summary>
|
||||
Max,
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
// using System;
|
||||
// using System.Text;
|
||||
// using Exporter.Excel;
|
||||
// using Fantasy.Exporter;
|
||||
// using OfficeOpenXml;
|
||||
//
|
||||
// namespace Exporter;
|
||||
//
|
||||
// public class ConstValueToConst : ACustomExport
|
||||
// {
|
||||
// public override void Run()
|
||||
// {
|
||||
// if (!ExcelExporter.LoadIgnoreExcel("#ConstValue", out var excelPackage))
|
||||
// {
|
||||
// Log.Error("ConstValueToConst: Load Excel failed.");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// var worksheet = excelPackage.Workbook.Worksheets[0];
|
||||
//
|
||||
// var serverHotfixStrBuilder = new StringBuilder();
|
||||
// serverHotfixStrBuilder.AppendLine("namespace Fantasy\n{");
|
||||
// serverHotfixStrBuilder.AppendLine("\t// 生成器自动生成,请不要手动编辑,修改请在#ConstValue.xsl里。");
|
||||
// serverHotfixStrBuilder.AppendLine("\tpublic partial class ConstValueHotfix\n\t{");
|
||||
//
|
||||
// var serverModelStrBuilder = new StringBuilder();
|
||||
// serverModelStrBuilder.AppendLine("namespace Fantasy\n{");
|
||||
// serverModelStrBuilder.AppendLine("\t// 生成器自动生成,请不要手动编辑。");
|
||||
// serverModelStrBuilder.AppendLine("\tpublic partial class ConstValue\n\t{");
|
||||
//
|
||||
// var clientStrBuilder = new StringBuilder();
|
||||
// clientStrBuilder.AppendLine("namespace Fantasy\n{");
|
||||
// clientStrBuilder.AppendLine("\t// 生成器自动生成,请不要手动编辑。");
|
||||
// clientStrBuilder.AppendLine("\tpublic class ConstValue\n\t{");
|
||||
//
|
||||
// for (var row = 2; row <= worksheet.Dimension.Rows; row++)
|
||||
// {
|
||||
// var first = worksheet.GetCellValue(row, 1);
|
||||
// var second = worksheet.GetCellValue(row, 2);
|
||||
// var lower = first?.ToLower() ?? "";
|
||||
// var isClient = lower.Contains("c");
|
||||
// var isServerModel = lower.Contains("sh");
|
||||
// var isServerHotfix = lower.Contains("sm");
|
||||
//
|
||||
// if (string.IsNullOrEmpty(second))
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// string str;
|
||||
//
|
||||
// if (second.StartsWith("#"))
|
||||
// {
|
||||
// str = $"\t\t// {second}";
|
||||
// clientStrBuilder.AppendLine(str);
|
||||
// serverModelStrBuilder.AppendLine(str);
|
||||
// serverHotfixStrBuilder.AppendLine(str);
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// str = GetCodeStr(worksheet, row);
|
||||
//
|
||||
// if (isServerModel)
|
||||
// {
|
||||
// serverModelStrBuilder.AppendLine(str);
|
||||
// }
|
||||
//
|
||||
// if (isServerHotfix)
|
||||
// {
|
||||
// serverHotfixStrBuilder.AppendLine(str);
|
||||
// }
|
||||
//
|
||||
// if (isClient)
|
||||
// {
|
||||
// clientStrBuilder.AppendLine(str);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// clientStrBuilder.AppendLine("\t}\n}");
|
||||
// serverModelStrBuilder.AppendLine("\t}\n}");
|
||||
// serverHotfixStrBuilder.AppendLine("\t}\n}");
|
||||
//
|
||||
// Write("ConstValue.cs", clientStrBuilder.ToString(), CustomExportType.Client);
|
||||
// Write("ConstValue.cs", serverModelStrBuilder.ToString(), CustomExportType.Server);
|
||||
// Write("ConstValueHotfix.cs", serverHotfixStrBuilder.ToString(),"../../Server/Hotfix/Generate/CustomExport123" ,CustomExportType.Server);
|
||||
// }
|
||||
//
|
||||
// private static string GetCodeStr(ExcelWorksheet sheet, int row)
|
||||
// {
|
||||
// var typeStr = sheet.GetCellValue(row, 3);
|
||||
// var name = sheet.GetCellValue(row, 2);
|
||||
// var value = sheet.GetCellValue(row, 4);
|
||||
// var desc = sheet.GetCellValue(row, 5);
|
||||
//
|
||||
// try
|
||||
// {
|
||||
// if (typeStr.Contains("[]") || typeStr.Contains("[,]"))
|
||||
// {
|
||||
// return $"\t\tpublic static readonly {typeStr} {name} = {DefaultValue(typeStr, value)}; // {desc}";
|
||||
// }
|
||||
//
|
||||
// if (typeStr.Contains("Vector"))
|
||||
// {
|
||||
// return $"\t\tpublic static readonly {typeStr} {name} = {DefaultValue(typeStr, value)}; // {desc}";
|
||||
// }
|
||||
//
|
||||
// return $"\t\tpublic const {typeStr} {name} = {DefaultValue(typeStr, value)}; // {desc}";
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// Log.Error($"{name} 常量导出异常 : {e}");
|
||||
// return "";
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private static string DefaultValue(string type, string value)
|
||||
// {
|
||||
// switch (type)
|
||||
// {
|
||||
// case "byte[]":
|
||||
// case "int[]":
|
||||
// case "long[]":
|
||||
// case "string[]":
|
||||
// case "double[]":
|
||||
// case "float[]":
|
||||
// return $"new {type} {{{value}}}";
|
||||
// case "byte[,]":
|
||||
// case "int[,]":
|
||||
// case "long[,]":
|
||||
// case "string[,]":
|
||||
// case "float[,]":
|
||||
// case "double[,]":
|
||||
// return $"new {type} {{{value}}}";
|
||||
// case "int":
|
||||
// case "bool":
|
||||
// case "uint":
|
||||
// case "long":
|
||||
// case "double":
|
||||
// return $"{value}";
|
||||
// case "float":
|
||||
// return value[^1] == 'f' ? value : $"{value}f";
|
||||
// case "string":
|
||||
// return $"\"{value}\"";
|
||||
// case "Vector2":
|
||||
// {
|
||||
// var strings = value.Split(',', StringSplitOptions.TrimEntries);
|
||||
// return $"new Vector2({strings[0]},{strings[1]})";
|
||||
// }
|
||||
// case "Vector3":
|
||||
// {
|
||||
// var strings = value.Split(',', StringSplitOptions.TrimEntries);
|
||||
// return $"new Vector3({strings[0]},{strings[1]},{strings[2]})";
|
||||
// }
|
||||
// default:
|
||||
// throw new Exception($"不支持此类型: {type}");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,62 @@
|
||||
using System.Text;
|
||||
using Fantasy.Tools.ConfigTable;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Exporter;
|
||||
|
||||
/// <summary>
|
||||
/// 将场景类型配置表转换为枚举和字典的自定义导出类。
|
||||
/// </summary>
|
||||
public class SceneTypeConfigToEnum : ACustomExport
|
||||
{
|
||||
public override void Run()
|
||||
{
|
||||
var sceneType = new Dictionary<string, string>();
|
||||
// 获取场景配置表的完整路径
|
||||
if (!Worksheets.TryGetValue("SceneTypeConfig", out var sceneTypeConfig))
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (var row = 3; row <= sceneTypeConfig.Dimension.Rows; row++)
|
||||
{
|
||||
var sceneTypeId = sceneTypeConfig.GetCellValue(row, 1);
|
||||
var sceneTypeStr = sceneTypeConfig.GetCellValue(row, 2);
|
||||
|
||||
if (string.IsNullOrEmpty(sceneTypeId) || string.IsNullOrEmpty(sceneTypeStr))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
sceneType.Add(sceneTypeId, sceneTypeStr);
|
||||
}
|
||||
// 如果存在场景类型或场景子类型,执行导出操作
|
||||
if (sceneType.Count > 0)
|
||||
{
|
||||
Write(CustomExportType.Server, sceneType);
|
||||
}
|
||||
}
|
||||
|
||||
private void Write(CustomExportType customExportType, Dictionary<string, string> sceneTypes)
|
||||
{
|
||||
var strBuilder = new StringBuilder();
|
||||
var dicBuilder = new StringBuilder();
|
||||
// 添加命名空间和注释头部
|
||||
strBuilder.AppendLine("namespace Fantasy\n{");
|
||||
strBuilder.AppendLine("\t// 生成器自动生成,请不要手动编辑。");
|
||||
// 生成场景类型的静态类
|
||||
strBuilder.AppendLine("\tpublic static class SceneType\n\t{");
|
||||
dicBuilder.AppendLine("\n\t\tpublic static readonly Dictionary<string, int> SceneTypeDic = new Dictionary<string, int>()\n\t\t{");
|
||||
// 遍历场景类型字典,生成场景类型的常量和字典项
|
||||
foreach (var (sceneTypeId, sceneTypeStr) in sceneTypes)
|
||||
{
|
||||
dicBuilder.AppendLine($"\t\t\t{{ \"{sceneTypeStr}\", {sceneTypeId} }},");
|
||||
strBuilder.AppendLine($"\t\tpublic const int {sceneTypeStr} = {sceneTypeId};");
|
||||
}
|
||||
// 添加场景类型字典尾部,合并到主字符串构建器中
|
||||
dicBuilder.AppendLine("\t\t};");
|
||||
strBuilder.Append(dicBuilder);
|
||||
strBuilder.AppendLine("\t}\n}");
|
||||
// 调用外部方法将生成的代码写入文件
|
||||
Write("SceneType.cs", strBuilder.ToString(), customExportType);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using Fantasy.Serialize;
|
||||
|
||||
#pragma warning disable CS8603 // Possible null reference return.
|
||||
|
||||
namespace Fantasy;
|
||||
|
||||
public static class ConfigTableHelper
|
||||
{
|
||||
public static T Load<T>() where T : ASerialize
|
||||
{
|
||||
return default;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
using System.Reflection;
|
||||
using Fantasy.Exporter;
|
||||
using Fantasy.Serialize;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using ProtoBuf;
|
||||
#pragma warning disable CS8601 // Possible null reference assignment.
|
||||
|
||||
namespace Exporter.Excel;
|
||||
|
||||
/// <summary>
|
||||
/// 动态程序集类,用于加载动态生成的程序集并获取动态信息。
|
||||
/// </summary>
|
||||
public static class DynamicAssembly
|
||||
{
|
||||
private static void MetadataReference(out string assemblyName, out List<MetadataReference> metadataReferenceList)
|
||||
{
|
||||
AssemblyMetadata assemblyMetadata;
|
||||
MetadataReference metadataReference;
|
||||
var currentDomain = AppDomain.CurrentDomain;
|
||||
assemblyName = Path.GetRandomFileName();
|
||||
var assemblyArray = currentDomain.GetAssemblies();
|
||||
metadataReferenceList = new List<MetadataReference>();
|
||||
|
||||
// 注册引用
|
||||
|
||||
foreach (var domainAssembly in assemblyArray)
|
||||
{
|
||||
if (string.IsNullOrEmpty(domainAssembly.Location))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
assemblyMetadata = AssemblyMetadata.CreateFromFile(domainAssembly.Location);
|
||||
metadataReference = assemblyMetadata.GetReference();
|
||||
metadataReferenceList.Add(metadataReference);
|
||||
}
|
||||
|
||||
// 添加Proto支持
|
||||
|
||||
assemblyMetadata = AssemblyMetadata.CreateFromFile(typeof(ProtoMemberAttribute).Assembly.Location);
|
||||
metadataReference = assemblyMetadata.GetReference();
|
||||
metadataReferenceList.Add(metadataReference);
|
||||
|
||||
// 添加Fantasy支持
|
||||
|
||||
assemblyMetadata = AssemblyMetadata.CreateFromFile(typeof(ASerialize).Assembly.Location);
|
||||
metadataReference = assemblyMetadata.GetReference();
|
||||
metadataReferenceList.Add(metadataReference);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载指定路径下的动态程序集。
|
||||
/// </summary>
|
||||
/// <param name="path">程序集文件路径。</param>
|
||||
/// <returns>加载的动态程序集。</returns>
|
||||
public static Assembly Load(string path)
|
||||
{
|
||||
var fileList = new List<string>();
|
||||
|
||||
// 找到所有需要加载的CS文件
|
||||
|
||||
foreach (string file in Directory.GetFiles(path))
|
||||
{
|
||||
if (Path.GetExtension(file) != ".cs")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
fileList.Add(file);
|
||||
}
|
||||
|
||||
var syntaxTreeList = new List<SyntaxTree>();
|
||||
|
||||
foreach (var file in fileList)
|
||||
{
|
||||
using var fileStream = new StreamReader(file);
|
||||
var cSharp = CSharpSyntaxTree.ParseText(fileStream.ReadToEnd());
|
||||
syntaxTreeList.Add(cSharp);
|
||||
}
|
||||
|
||||
// 注册程序集
|
||||
MetadataReference(out var assemblyName, out var metadataReferenceList);
|
||||
var compilation = CSharpCompilation.Create(assemblyName, syntaxTreeList, metadataReferenceList, new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary));
|
||||
using var ms = new MemoryStream();
|
||||
var result = compilation.Emit(ms);
|
||||
if (!result.Success)
|
||||
{
|
||||
foreach (var resultDiagnostic in result.Diagnostics)
|
||||
{
|
||||
Log.Error(resultDiagnostic.GetMessage());
|
||||
}
|
||||
|
||||
throw new Exception("failures");
|
||||
}
|
||||
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
return Assembly.Load(ms.ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取动态程序集中指定表格的动态信息。
|
||||
/// </summary>
|
||||
/// <param name="dynamicAssembly">动态程序集。</param>
|
||||
/// <param name="tableName">表格名称。</param>
|
||||
/// <returns>动态信息对象。</returns>
|
||||
public static DynamicConfigDataType GetDynamicInfo(Assembly dynamicAssembly, string tableName)
|
||||
{
|
||||
var dynamicConfigDataType = new DynamicConfigDataType
|
||||
{
|
||||
ConfigDataType = GetConfigType(dynamicAssembly, $"{tableName}Data"),
|
||||
ConfigType = GetConfigType(dynamicAssembly, $"{tableName}")
|
||||
};
|
||||
|
||||
dynamicConfigDataType.ConfigData = CreateInstance(dynamicConfigDataType.ConfigDataType);
|
||||
|
||||
var listPropertyType = dynamicConfigDataType.ConfigDataType.GetProperty("List");
|
||||
|
||||
if (listPropertyType == null)
|
||||
{
|
||||
throw new Exception("No Property named Add was found");
|
||||
}
|
||||
|
||||
dynamicConfigDataType.Obj = listPropertyType.GetValue(dynamicConfigDataType.ConfigData);
|
||||
dynamicConfigDataType.Method = listPropertyType.PropertyType.GetMethod("Add");
|
||||
|
||||
if (dynamicConfigDataType.Method == null)
|
||||
{
|
||||
throw new Exception("No method named Add was found");
|
||||
}
|
||||
|
||||
return dynamicConfigDataType;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据类型名称获取动态类型。
|
||||
/// </summary>
|
||||
/// <param name="dynamicAssembly">动态程序集。</param>
|
||||
/// <param name="typeName">类型名称。</param>
|
||||
/// <returns>动态类型。</returns>
|
||||
private static Type GetConfigType(Assembly dynamicAssembly, string typeName)
|
||||
{
|
||||
var configType = dynamicAssembly.GetType($"Fantasy.{typeName}");
|
||||
|
||||
if (configType == null)
|
||||
{
|
||||
throw new FileNotFoundException($"Fantasy.{typeName} not found");
|
||||
}
|
||||
|
||||
return configType;
|
||||
// return dynamicAssembly.GetType($"Fantasy.{typeName}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建动态实例。
|
||||
/// </summary>
|
||||
/// <param name="configType">动态类型。</param>
|
||||
/// <returns>动态实例。</returns>
|
||||
public static object CreateInstance(Type configType)
|
||||
{
|
||||
var config = Activator.CreateInstance(configType);
|
||||
|
||||
if (config == null)
|
||||
{
|
||||
throw new Exception($"{configType.Name} is Activator.CreateInstance error");
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
||||
|
||||
namespace Exporter.Excel;
|
||||
|
||||
/// <summary>
|
||||
/// 动态配置数据类型类,用于存储动态配置数据的相关信息。
|
||||
/// </summary>
|
||||
public class DynamicConfigDataType
|
||||
{
|
||||
/// <summary>
|
||||
/// 配置数据对象,继承自 AProto 基类。
|
||||
/// </summary>
|
||||
public object ConfigData;
|
||||
/// <summary>
|
||||
/// 配置数据类型。
|
||||
/// </summary>
|
||||
public Type ConfigDataType;
|
||||
/// <summary>
|
||||
/// 配置类型。
|
||||
/// </summary>
|
||||
public Type ConfigType;
|
||||
/// <summary>
|
||||
/// 反射方法信息,用于调用特定方法。
|
||||
/// </summary>
|
||||
public MethodInfo Method;
|
||||
/// <summary>
|
||||
/// 配置数据对象实例。
|
||||
/// </summary>
|
||||
public object Obj;
|
||||
/// <summary>
|
||||
/// 用于生成 JSON 格式数据的字符串构建器。
|
||||
/// </summary>
|
||||
public StringBuilder Json = new StringBuilder();
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
using System.Reflection;
|
||||
using Fantasy.Exporter;
|
||||
using Fantasy.Serialize;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using ProtoBuf;
|
||||
|
||||
namespace Exporter.Excel;
|
||||
|
||||
public class OneDynamicAssembly
|
||||
{
|
||||
private readonly List<SyntaxTree> _syntaxTreeList = new List<SyntaxTree>();
|
||||
|
||||
public void Load(string file)
|
||||
{
|
||||
using var fileStream = new StreamReader(file);
|
||||
var cSharp = CSharpSyntaxTree.ParseText(fileStream.ReadToEnd());
|
||||
_syntaxTreeList.Add(cSharp);
|
||||
}
|
||||
|
||||
public Assembly Assembly
|
||||
{
|
||||
get
|
||||
{
|
||||
AssemblyMetadata assemblyMetadata;
|
||||
MetadataReference metadataReference;
|
||||
var currentDomain = AppDomain.CurrentDomain;
|
||||
var assemblyName = Path.GetRandomFileName();
|
||||
var assemblyArray = currentDomain.GetAssemblies();
|
||||
var metadataReferenceList = new List<MetadataReference>();
|
||||
// 注册引用
|
||||
foreach (var domainAssembly in assemblyArray)
|
||||
{
|
||||
if (string.IsNullOrEmpty(domainAssembly.Location))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
assemblyMetadata = AssemblyMetadata.CreateFromFile(domainAssembly.Location);
|
||||
metadataReference = assemblyMetadata.GetReference();
|
||||
metadataReferenceList.Add(metadataReference);
|
||||
}
|
||||
// 添加ProtoEntity支持
|
||||
assemblyMetadata = AssemblyMetadata.CreateFromFile(typeof(ASerialize).Assembly.Location);
|
||||
metadataReference = assemblyMetadata.GetReference();
|
||||
metadataReferenceList.Add(metadataReference);
|
||||
// 添加MessagePack支持
|
||||
assemblyMetadata = AssemblyMetadata.CreateFromFile(typeof(ProtoMemberAttribute).Assembly.Location);
|
||||
metadataReference = assemblyMetadata.GetReference();
|
||||
metadataReferenceList.Add(metadataReference);
|
||||
CSharpCompilation compilation = CSharpCompilation.Create(assemblyName, _syntaxTreeList, metadataReferenceList, new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary));
|
||||
|
||||
using var ms = new MemoryStream();
|
||||
var result = compilation.Emit(ms);
|
||||
|
||||
if (!result.Success)
|
||||
{
|
||||
foreach (var resultDiagnostic in result.Diagnostics)
|
||||
{
|
||||
Log.Error(resultDiagnostic.GetMessage());
|
||||
}
|
||||
|
||||
throw new Exception("failures");
|
||||
}
|
||||
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
return Assembly.Load(ms.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
1054
Tools/SourceCode/Fantasy.Tools.ConfigTable/Exporter/ExcelExporter.cs
Normal file
1054
Tools/SourceCode/Fantasy.Tools.ConfigTable/Exporter/ExcelExporter.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,47 @@
|
||||
using OfficeOpenXml;
|
||||
|
||||
namespace Fantasy.Tools.ConfigTable;
|
||||
|
||||
/// <summary>
|
||||
/// 提供操作 Excel 文件的辅助方法。
|
||||
/// </summary>
|
||||
public static class ExcelHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 加载 Excel 文件并返回 ExcelPackage 实例。
|
||||
/// </summary>
|
||||
/// <param name="name">Excel 文件的路径。</param>
|
||||
/// <returns>ExcelPackage 实例。</returns>
|
||||
public static ExcelPackage LoadExcel(string name)
|
||||
{
|
||||
return new ExcelPackage(name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定工作表中指定行列位置的单元格值。
|
||||
/// </summary>
|
||||
/// <param name="sheet">Excel 工作表。</param>
|
||||
/// <param name="row">行索引。</param>
|
||||
/// <param name="column">列索引。</param>
|
||||
/// <returns>单元格值。</returns>
|
||||
public static string GetCellValue(this ExcelWorksheet sheet, int row, int column)
|
||||
{
|
||||
ExcelRange cell = sheet.Cells[row, column];
|
||||
|
||||
try
|
||||
{
|
||||
if (cell.Value == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
string s = cell.GetValue<string>();
|
||||
|
||||
return s.Trim();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new Exception($"Rows {row} Columns {column} Content {cell.Text} {e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
namespace Fantasy.Tools.ConfigTable;
|
||||
|
||||
/// <summary>
|
||||
/// Excel表格类,用于存储表格的名称和列信息。
|
||||
/// </summary>
|
||||
public sealed class ExcelTable
|
||||
{
|
||||
/// <summary>
|
||||
/// 表格的名称。
|
||||
/// </summary>
|
||||
public readonly string Name;
|
||||
/// <summary>
|
||||
/// 客户端列信息,使用排序字典存储列名和列索引列表。
|
||||
/// </summary>
|
||||
public readonly SortedDictionary<string, List<int>> ClientColInfos = new();
|
||||
/// <summary>
|
||||
/// 服务器端列信息,使用排序字典存储列名和列索引列表。
|
||||
/// </summary>
|
||||
public readonly SortedDictionary<string, List<int>> ServerColInfos = new();
|
||||
/// <summary>
|
||||
/// 构造函数,初始化Excel表格对象并设置表格名称。
|
||||
/// </summary>
|
||||
/// <param name="name">表格名称。</param>
|
||||
public ExcelTable(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
namespace Fantasy.Tools.ConfigTable;
|
||||
|
||||
public static class ExcelTemplate
|
||||
{
|
||||
public static readonly string Template = """
|
||||
using System;
|
||||
using ProtoBuf;
|
||||
using Fantasy;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using Fantasy.ConfigTable;
|
||||
using Fantasy.Serialize;
|
||||
// ReSharper disable CollectionNeverUpdated.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
#pragma warning disable CS0169
|
||||
#pragma warning disable CS8618
|
||||
#pragma warning disable CS8625
|
||||
#pragma warning disable CS8603
|
||||
|
||||
namespace (namespace)
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class (ConfigName)Data : ASerialize, IConfigTable, IProto
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<(ConfigName)> List { get; set; } = new List<(ConfigName)>();
|
||||
#if FANTASY_NET
|
||||
[ProtoIgnore]
|
||||
private readonly ConcurrentDictionary<uint, (ConfigName)> _configs = new ConcurrentDictionary<uint, (ConfigName)>();
|
||||
#else
|
||||
[ProtoIgnore]
|
||||
private readonly Dictionary<uint, (ConfigName)> _configs = new Dictionary<uint, (ConfigName)>();
|
||||
#endif
|
||||
private static (ConfigName)Data _instance = null;
|
||||
|
||||
public static (ConfigName)Data Instance
|
||||
{
|
||||
get { return _instance ??= ConfigTableHelper.Load<(ConfigName)Data>(); }
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public (ConfigName) Get(uint id, bool check = true)
|
||||
{
|
||||
if (_configs.ContainsKey(id))
|
||||
{
|
||||
return _configs[id];
|
||||
}
|
||||
|
||||
if (check)
|
||||
{
|
||||
throw new Exception($"(ConfigName) not find {id} Id");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public bool TryGet(uint id, out (ConfigName) config)
|
||||
{
|
||||
config = null;
|
||||
|
||||
if (!_configs.ContainsKey(id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
config = _configs[id];
|
||||
return true;
|
||||
}
|
||||
public override void AfterDeserialization()
|
||||
{
|
||||
foreach (var config in List)
|
||||
{
|
||||
#if FANTASY_NET
|
||||
_configs.TryAdd(config.Id, config);
|
||||
#else
|
||||
_configs.Add(config.Id, config);
|
||||
#endif
|
||||
config.AfterDeserialization();
|
||||
}
|
||||
|
||||
EndInit();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
[ProtoContract]
|
||||
public sealed partial class (ConfigName) : ASerialize, IProto
|
||||
{(Fields)
|
||||
}
|
||||
}
|
||||
""";
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Fantasy.Exporter;
|
||||
using Fantasy.Helper;
|
||||
using OfficeOpenXml;
|
||||
#pragma warning disable CS8601 // Possible null reference assignment.
|
||||
|
||||
namespace Fantasy.Tools.ConfigTable;
|
||||
|
||||
public sealed class ExcelWorksheets(ExcelExporter excelExporter)
|
||||
{
|
||||
public bool TryGetValue(string worksheetName, out ExcelWorksheet excelWorksheet)
|
||||
{
|
||||
if (excelExporter.Worksheets.TryGetValue(worksheetName, out excelWorksheet))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var computeHash64 = HashCodeHelper.ComputeHash64(worksheetName);
|
||||
if (!excelExporter.VersionInfo.WorksheetNames.Contains(computeHash64))
|
||||
{
|
||||
Log.Info($"{worksheetName} is not exist!");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
||||
namespace Fantasy.Tools.ConfigTable;
|
||||
|
||||
/// <summary>
|
||||
/// 导出信息类,用于存储导出操作的名称和文件信息。
|
||||
/// </summary>
|
||||
public class ExportInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 导出操作的名称。
|
||||
/// </summary>
|
||||
public string Name;
|
||||
/// <summary>
|
||||
/// 导出操作生成的文件信息。
|
||||
/// </summary>
|
||||
public FileInfo FileInfo;
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
using Fantasy.Exporter;
|
||||
using Fantasy.Helper;
|
||||
// ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
|
||||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
||||
|
||||
namespace Fantasy.Tools.ConfigTable;
|
||||
|
||||
/// <summary>
|
||||
/// 自定义导出接口
|
||||
/// </summary>
|
||||
public interface ICustomExport
|
||||
{
|
||||
/// <summary>
|
||||
/// 执行导出操作
|
||||
/// </summary>
|
||||
void Run();
|
||||
/// <summary>
|
||||
/// 内部操作用于初始化、不明白原理不要修改这里和调用这个方法
|
||||
/// </summary>
|
||||
/// <param name="excelExporter"></param>
|
||||
/// <param name="worksheets"></param>
|
||||
void Init(ExcelExporter excelExporter, ExcelWorksheets worksheets);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 抽象自定义导出基类
|
||||
/// </summary>
|
||||
public abstract class ACustomExport : ICustomExport
|
||||
{
|
||||
protected ExcelExporter ExcelExporter;
|
||||
protected ExcelWorksheets Worksheets;
|
||||
|
||||
/// <summary>
|
||||
/// 自定义导出类型枚举:客户端、服务器
|
||||
/// </summary>
|
||||
protected enum CustomExportType
|
||||
{
|
||||
/// <summary>
|
||||
/// 客户端
|
||||
/// </summary>
|
||||
Client,
|
||||
/// <summary>
|
||||
/// 服务器
|
||||
/// </summary>
|
||||
Server
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 内部操作用于初始化、不明白原理不要修改这里
|
||||
/// </summary>
|
||||
/// <param name="excelExporter"></param>
|
||||
/// <param name="worksheets"></param>
|
||||
public void Init(ExcelExporter excelExporter, ExcelWorksheets worksheets)
|
||||
{
|
||||
ExcelExporter = excelExporter;
|
||||
Worksheets = worksheets;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行导出操作的抽象方法
|
||||
/// </summary>
|
||||
public abstract void Run();
|
||||
|
||||
/// <summary>
|
||||
/// 写入文件内容到指定位置
|
||||
/// </summary>
|
||||
/// <param name="fileName">文件名</param>
|
||||
/// <param name="fileContent">文件内容</param>
|
||||
/// <param name="filePath">相对的导出的目录</param>
|
||||
/// <param name="customExportType">自定义导出类型</param>
|
||||
protected void Write(string fileName, string fileContent, string filePath, CustomExportType customExportType)
|
||||
{
|
||||
if (filePath == null)
|
||||
{
|
||||
Log.Error($" {nameof(filePath)} is null");
|
||||
return;
|
||||
}
|
||||
|
||||
filePath = FileHelper.GetFullPath(filePath);
|
||||
|
||||
if (!Directory.Exists(filePath))
|
||||
{
|
||||
FileHelper.CreateDirectory(filePath);
|
||||
}
|
||||
|
||||
var combine = Path.Combine(filePath, fileName);
|
||||
File.WriteAllText(combine, fileContent);
|
||||
|
||||
switch (customExportType)
|
||||
{
|
||||
case CustomExportType.Client:
|
||||
{
|
||||
Log.Info($"导出客户端自定义文件:{filePath}/{fileName}");
|
||||
return;
|
||||
}
|
||||
case CustomExportType.Server:
|
||||
{
|
||||
Log.Info($"导出服务器自定义文件:{filePath}/{fileName}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 写入文件内容到指定位置
|
||||
/// </summary>
|
||||
/// <param name="fileName">文件名</param>
|
||||
/// <param name="fileContent">文件内容</param>
|
||||
/// <param name="customExportType">自定义导出类型</param>
|
||||
protected void Write(string fileName, string fileContent, CustomExportType customExportType)
|
||||
{
|
||||
switch (customExportType)
|
||||
{
|
||||
case CustomExportType.Client:
|
||||
{
|
||||
if (string.IsNullOrEmpty(ExcelExporter.ClientCustomExportDirectory))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Directory.Exists(ExcelExporter.ClientCustomExportDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(ExcelExporter.ClientCustomExportDirectory);
|
||||
}
|
||||
|
||||
File.WriteAllText($"{ExcelExporter.ClientCustomExportDirectory}/{fileName}", fileContent);
|
||||
Log.Info($"导出客户端自定义文件:{ExcelExporter.ClientCustomExportDirectory}/{fileName}");
|
||||
return;
|
||||
}
|
||||
case CustomExportType.Server:
|
||||
{
|
||||
if (string.IsNullOrEmpty(ExcelExporter.ServerCustomExportDirectory))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Directory.Exists(ExcelExporter.ServerCustomExportDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(ExcelExporter.ServerCustomExportDirectory);
|
||||
}
|
||||
|
||||
File.WriteAllText($"{ExcelExporter.ServerCustomExportDirectory}/{fileName}", fileContent);
|
||||
Log.Info($"导出服务器自定义文件:{ExcelExporter.ServerCustomExportDirectory}/{fileName}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Fantasy.Tools.ConfigTable;
|
||||
|
||||
public class VersionInfo
|
||||
{
|
||||
public SortedSet<long> WorksheetNames = [];
|
||||
public SortedDictionary<long, long> Tables = new();
|
||||
}
|
||||
21
Tools/SourceCode/Fantasy.Tools.ConfigTable/ExporterAges.cs
Normal file
21
Tools/SourceCode/Fantasy.Tools.ConfigTable/ExporterAges.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using CommandLine;
|
||||
using Fantasy.Tools.ConfigTable;
|
||||
|
||||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
||||
|
||||
namespace Fantasy.Tools;
|
||||
|
||||
public class ExporterAges
|
||||
{
|
||||
public static ExporterAges Instance;
|
||||
/// <summary>
|
||||
/// 导出目标平台枚举,用于标识导出到哪个平台
|
||||
/// </summary>
|
||||
[Option('p',"ExportPlatform", Required = false, Default = ExportPlatform.None, HelpText = "Export target platform:\n/// Client target platform \nClient = 1\n/// Server target platform\nServer = 2\n/// Client and Server target platform\nAll = 3")]
|
||||
public ExportPlatform ExportPlatform { get; set; }
|
||||
/// <summary>
|
||||
/// 导出类型
|
||||
/// </summary>
|
||||
[Option('e',"ExportType", Required = false, Default = ExportType.None, HelpText = "Export Type:\n/// Incremental export of all data in Excel format.\nAllExcelIncrement = 1\n/// Export all data to Excel format.\nAllExcel = 2")]
|
||||
public ExportType ExportType { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"Export": {
|
||||
"ExcelProgramPath": {
|
||||
"Value": "../../../Examples/Config/Excel/",
|
||||
"Comment": "Excel文件夹的根目录"
|
||||
},
|
||||
"ExcelVersionFile": {
|
||||
"Value": "../../../Examples/Config/Excel/Version.txt",
|
||||
"Comment": "Excel的Version文件位置、这个文件用于记录每次导出对比是否需要再次导出的文件"
|
||||
},
|
||||
"ExcelServerFileDirectory": {
|
||||
"Value": "../../../Examples/Server/Entity/Generate/ConfigTable/Entity/",
|
||||
"Comment": "Excel生成的代码文件、在服务端文件夹位置"
|
||||
},
|
||||
"ExcelClientFileDirectory": {
|
||||
"Value": "../../../Examples/Client/Unity/Assets/Scripts/Hotfix/Generate/ConfigTable/Entity/",
|
||||
"Comment": "Excel生成的代码文件、在客户端文件夹位置"
|
||||
},
|
||||
"ExcelServerBinaryDirectory": {
|
||||
"Value": "../../../Examples/Config/Binary/",
|
||||
"Comment": "Excel生成服务器二进制数据文件夹位置"
|
||||
},
|
||||
"ExcelClientBinaryDirectory": {
|
||||
"Value": "../../../Examples/Client/Unity/Assets/Bundles/Config/",
|
||||
"Comment": "Excel生成在客户端的二进制数据文件夹位置"
|
||||
},
|
||||
"ExcelServerJsonDirectory": {
|
||||
"Value": "../../../Examples/Config/Json/Server/",
|
||||
"Comment": "Excel生成在服务端的Json数据文件夹位置"
|
||||
},
|
||||
"ExcelClientJsonDirectory": {
|
||||
"Value": "../../../Examples/Config/Json/Client/",
|
||||
"Comment": "Excel生成在客户端的Json数据文件夹位置"
|
||||
},
|
||||
"ServerCustomExportDirectory": {
|
||||
"Value": "../../../Examples/Server/Entity/Generate/CustomExport/",
|
||||
"Comment": "Excel在服务端生成自定义代码的文件夹位置"
|
||||
},
|
||||
"ClientCustomExportDirectory": {
|
||||
"Value": "../../../Examples/Client/Unity/Assets/Scripts/Hotfix/Generate/CustomExport",
|
||||
"Comment": "Excel在客户端端生成自定义代码的文件夹位置"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using Fantasy.Helper;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
#pragma warning disable CS8604 // Possible null reference argument.
|
||||
|
||||
namespace Fantasy.Tools.ConfigTable;
|
||||
|
||||
public class ExporterSettingsHelper
|
||||
{
|
||||
public static string? ExcelProgramPath { get; private set; }
|
||||
public static string? ExcelVersionFile { get; private set; }
|
||||
public static string? ExcelServerFileDirectory { get; private set; }
|
||||
public static string? ExcelClientFileDirectory { get; private set; }
|
||||
public static string? ExcelServerBinaryDirectory { get; private set; }
|
||||
public static string? ExcelClientBinaryDirectory { get; private set; }
|
||||
public static string? ExcelServerJsonDirectory { get; private set; }
|
||||
public static string? ExcelClientJsonDirectory { get; private set; }
|
||||
public static string? ServerCustomExportDirectory { get; private set; }
|
||||
public static string? ClientCustomExportDirectory { get; private set; }
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
const string settingsName = "ExporterSettings.json";
|
||||
var currentDirectory = Directory.GetCurrentDirectory();
|
||||
|
||||
if (!File.Exists(Path.Combine(currentDirectory, settingsName)))
|
||||
{
|
||||
throw new FileNotFoundException($"not found {settingsName} in OutputDirectory");
|
||||
}
|
||||
|
||||
var root = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile(settingsName).Build();
|
||||
|
||||
ExcelProgramPath = FileHelper.GetFullPath(root["Export:ExcelProgramPath:Value"]);
|
||||
ExcelVersionFile = FileHelper.GetFullPath(root["Export:ExcelVersionFile:Value"]);
|
||||
ExcelServerFileDirectory = FileHelper.GetFullPath(root["Export:ExcelServerFileDirectory:Value"]);
|
||||
ExcelClientFileDirectory = FileHelper.GetFullPath(root["Export:ExcelClientFileDirectory:Value"]);
|
||||
ExcelServerBinaryDirectory = FileHelper.GetFullPath(root["Export:ExcelServerBinaryDirectory:Value"]);
|
||||
ExcelClientBinaryDirectory = FileHelper.GetFullPath(root["Export:ExcelClientBinaryDirectory:Value"]);
|
||||
ExcelServerJsonDirectory = FileHelper.GetFullPath(root["Export:ExcelServerJsonDirectory:Value"]);
|
||||
ExcelClientJsonDirectory = FileHelper.GetFullPath(root["Export:ExcelClientJsonDirectory:Value"]);
|
||||
ServerCustomExportDirectory = FileHelper.GetFullPath(root["Export:ServerCustomExportDirectory:Value"]);
|
||||
ClientCustomExportDirectory = FileHelper.GetFullPath(root["Export:ClientCustomExportDirectory:Value"]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<LangVersion>default</LangVersion>
|
||||
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DefineConstants>TRACE;FANTASY_EXPORTER</DefineConstants>
|
||||
<OutputPath>../../Exporter/ConfigTable/</OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DefineConstants>TRACE;FANTASY_EXPORTER</DefineConstants>
|
||||
<OutputPath>../../Exporter/ConfigTable/</OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommandLineParser" Version="2.9.1" />
|
||||
<PackageReference Include="EPPlus" Version="8.0.5" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.6" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="protobuf-net" Version="3.2.52" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\..\Fantasy.Net\Fantasy.Net\Runtime\Core\Pool\Normal\Pool.cs">
|
||||
<Link>Core\Base\Pool.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\..\Fantasy.Packages\Fantasy.ConfigTable\Net\Dictionary\IntDictionaryConfig.cs">
|
||||
<Link>Core\Dictionary\IntDictionaryConfig.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\..\Fantasy.Packages\Fantasy.ConfigTable\Net\Dictionary\StringDictionaryConfig.cs">
|
||||
<Link>Core\Dictionary\StringDictionaryConfig.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\..\Fantasy.Packages\Fantasy.ConfigTable\Net\Interface\IConfigTable.cs">
|
||||
<Link>Core\Interface\IConfigTable.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\..\Fantasy.Net\Fantasy.Net\Runtime\Core\Serialize\ProtoBufPackHelper\IProto.cs">
|
||||
<Link>Core\Serialize\ProtoBufPackHelper\IProto.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\..\Fantasy.Net\Fantasy.Net\Runtime\Core\Helper\TimeHelper.cs">
|
||||
<Link>Excel\Base\TimeHelper.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\..\Fantasy.Net\Fantasy.Net\Runtime\Core\Pool\Interface\IPool.cs">
|
||||
<Link>Excel\Base\IPool.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\..\Fantasy.Net\Fantasy.Net\Runtime\Core\Assembly\AssemblyInfo.cs">
|
||||
<Link>Excel\Base\AssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\..\Fantasy.Net\Fantasy.Net\Runtime\Core\DataStructure\Collection\OneToManyListPool.cs">
|
||||
<Link>Excel\Base\OneToManyList.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Fantasy.Tools.NetworkProtocol\Core\Base\ConsoleLog.cs">
|
||||
<Link>Core\ConsoleLog.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Fantasy.Tools.NetworkProtocol\Core\Base\ExportPlatform.cs">
|
||||
<Link>Core\ExportPlatform.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\..\Fantasy.Net\Fantasy.Net\Runtime\Core\Helper\FileHelper.cs">
|
||||
<Link>Core\FileHelper.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\..\Fantasy.Net\Fantasy.Net\Runtime\Core\Helper\HashCodeHelper.cs">
|
||||
<Link>Core\HashCodeHelper.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\..\Fantasy.Net\Fantasy.Net\Runtime\Core\Helper\JsonHelper.cs">
|
||||
<Link>Core\JsonHelper.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\..\Fantasy.Net\Fantasy.Net\Runtime\Core\Serialize\BsonPack\BsonPackHelperNet.cs">
|
||||
<Link>Core\Serialize\BsonPack\BsonPackHelperNet.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\..\Fantasy.Net\Fantasy.Net\Runtime\Core\Serialize\BsonPack\StructBsonSerialize.cs">
|
||||
<Link>Core\Serialize\BsonPack\StructBsonSerialize.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\..\Fantasy.Net\Fantasy.Net\Runtime\Core\Serialize\BsonPack\SupportInitializeChecker.cs">
|
||||
<Link>Core\Serialize\BsonPack\SupportInitializeChecker.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\..\Fantasy.Net\Fantasy.Net\Runtime\Core\Serialize\Interface\ASerialize.cs">
|
||||
<Link>Core\Serialize\Interface\ASerialize.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\..\Fantasy.Net\Fantasy.Net\Runtime\Core\Serialize\Interface\ISerialize.cs">
|
||||
<Link>Core\Serialize\Interface\ISerialize.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\..\Fantasy.Net\Fantasy.Net\Runtime\Core\Serialize\SerializerManager.cs">
|
||||
<Link>Core\Serialize\SerializerManager.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\..\Fantasy.Net\Fantasy.Net\Runtime\Core\Serialize\ProtoBufPackHelper\ProtoBufPackHelperNet.cs">
|
||||
<Link>Core\Serialize\ProtoBufPackHelper\ProtoBufPackHelperNet.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\..\Fantasy.Net\Fantasy.Net\Runtime\Core\Serialize\MemoryStreamBuffer.cs">
|
||||
<Link>Excel\Base\MemoryStreamBuffer.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="ExporterSettings.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Run.bat">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Run.sh">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
67
Tools/SourceCode/Fantasy.Tools.ConfigTable/Program.cs
Normal file
67
Tools/SourceCode/Fantasy.Tools.ConfigTable/Program.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System.Text;
|
||||
using CommandLine;
|
||||
using Fantasy.Exporter;
|
||||
using Fantasy.Tools;
|
||||
using Fantasy.Tools.ConfigTable;
|
||||
|
||||
try
|
||||
{
|
||||
Parser.Default.ParseArguments<ExporterAges>(Environment.GetCommandLineArgs())
|
||||
.WithNotParsed(error => throw new Exception("Command line format error!"))
|
||||
.WithParsed(ages => ExporterAges.Instance = ages);
|
||||
// 初始化配置
|
||||
ExporterSettingsHelper.Initialize();
|
||||
// 加载配置
|
||||
Console.OutputEncoding = Encoding.UTF8;
|
||||
// 判断启动参数,如果没有选择目标平台就让用户选择
|
||||
if (ExporterAges.Instance.ExportPlatform == ExportPlatform.None)
|
||||
{
|
||||
Log.Info("请输入你想要导出的目标平台:");
|
||||
Log.Info("1:Client(客户端)");
|
||||
Log.Info("2:Server(服务器)");
|
||||
Log.Info("3:All(客户端和服务器)");
|
||||
var inputKeyChar = Console.ReadKey().KeyChar;
|
||||
if (!int.TryParse(inputKeyChar.ToString(), out var exportPlatformKey) || exportPlatformKey is < 1 or >= (int)ExportPlatform.All)
|
||||
{
|
||||
Console.WriteLine("");
|
||||
Log.Error("无法识别的导出类型请,输入正确导出的目标平台。");
|
||||
return;
|
||||
}
|
||||
ExporterAges.Instance.ExportPlatform = (ExportPlatform)exportPlatformKey;
|
||||
}
|
||||
|
||||
var selectExportType = ExporterAges.Instance.ExportType;
|
||||
|
||||
if (selectExportType == ExportType.None)
|
||||
{
|
||||
// 检查启动参数
|
||||
Log.Info("请输入你想要做的操作:");
|
||||
Log.Info("1:所有增量导出Excel(包含常量枚举)");
|
||||
Log.Info("2:所有全量导出Excel(包含常量枚举)");
|
||||
// 获取用户输入
|
||||
var keyChar = Console.ReadKey().KeyChar;
|
||||
// 判断用户输入
|
||||
if (!int.TryParse(keyChar.ToString(), out var key) || key is < 1 or >= (int)ExportType.Max)
|
||||
{
|
||||
Console.WriteLine("");
|
||||
Log.Error("无法识别的导出类型请,输入正确的操作类型。");
|
||||
return;
|
||||
}
|
||||
|
||||
selectExportType = (ExportType)key;
|
||||
}
|
||||
Log.Info($"selectExportType:{selectExportType} ExportPlatform:{ExporterAges.Instance.ExportPlatform}");
|
||||
// 转换用户输入
|
||||
Log.Info("");
|
||||
new ExcelExporter(selectExportType).Run();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Log.Info("按任意键退出程序");
|
||||
Console.ReadKey();
|
||||
Environment.Exit(0);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"Fantasy.Tools.ConfigTable": {
|
||||
"commandName": "Project",
|
||||
"environmentVariables": {},
|
||||
"commandLineArgs": "--ExportPlatform 3"
|
||||
}
|
||||
}
|
||||
}
|
||||
33
Tools/SourceCode/Fantasy.Tools.ConfigTable/Run.bat
Normal file
33
Tools/SourceCode/Fantasy.Tools.ConfigTable/Run.bat
Normal file
@@ -0,0 +1,33 @@
|
||||
@echo off
|
||||
|
||||
echo Please select an option:
|
||||
echo 1. Client Increment
|
||||
echo 2. Client all
|
||||
echo 3. Server Increment
|
||||
echo 4. Server all
|
||||
echo 5. Client and Server Increment
|
||||
echo 6. Client and Server all
|
||||
|
||||
set /p choice=Please select an option:
|
||||
|
||||
if "%choice%"=="1" (
|
||||
echo Client Increment
|
||||
dotnet Fantasy.Tools.ConfigTable.dll --p 1 --e 1
|
||||
) else if "%choice%"=="2" (
|
||||
echo Client all
|
||||
dotnet Fantasy.Tools.ConfigTable.dll --p 1 --e 2
|
||||
) else if "%choice%"=="3" (
|
||||
echo Server Increment
|
||||
dotnet Fantasy.Tools.ConfigTable.dll --p 2 --e 1
|
||||
) else if "%choice%"=="4" (
|
||||
echo Server all
|
||||
dotnet Fantasy.Tools.ConfigTable.dll --p 2 --e 2
|
||||
) else if "%choice%"=="5" (
|
||||
echo Client and Server Increment
|
||||
dotnet Fantasy.Tools.ConfigTable.dll --p 3 --e 1
|
||||
) else if "%choice%"=="6" (
|
||||
echo Client and Server all
|
||||
dotnet Fantasy.Tools.ConfigTable.dll --p 3 --e 2
|
||||
) else (
|
||||
echo Invalid option
|
||||
)
|
||||
34
Tools/SourceCode/Fantasy.Tools.ConfigTable/Run.sh
Normal file
34
Tools/SourceCode/Fantasy.Tools.ConfigTable/Run.sh
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "1. Client Increment"
|
||||
echo "2. Client all"
|
||||
echo "3. Server Increment"
|
||||
echo "4. Server all"
|
||||
echo "5. Client and Server Increment"
|
||||
echo "6. Client and Server all"
|
||||
|
||||
read -n 1 -p "Please select an option:" choice
|
||||
echo ""
|
||||
case $choice in
|
||||
1)
|
||||
dotnet Fantasy.Tools.ConfigTable.dll --p 1 --e 1
|
||||
;;
|
||||
2)
|
||||
dotnet Fantasy.Tools.ConfigTable.dll --p 1 --e 2
|
||||
;;
|
||||
3)
|
||||
dotnet Fantasy.Tools.ConfigTable.dll --p 2 --e 1
|
||||
;;
|
||||
4)
|
||||
dotnet Fantasy.Tools.ConfigTable.dll --p 2 --e 2
|
||||
;;
|
||||
5)
|
||||
dotnet Fantasy.Tools.ConfigTable.dll --p 3 --e 1
|
||||
;;
|
||||
6)
|
||||
dotnet Fantasy.Tools.ConfigTable.dll --p 3 --e 2
|
||||
;;
|
||||
*)
|
||||
echo "Invalid option"
|
||||
;;
|
||||
esac
|
||||
@@ -0,0 +1,176 @@
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Fantasy.Exporter;
|
||||
|
||||
/// <summary>
|
||||
/// 定义日志记录功能的接口。
|
||||
/// </summary>
|
||||
public interface ILog
|
||||
{
|
||||
/// <summary>
|
||||
/// 记录跟踪级别的日志消息。
|
||||
/// </summary>
|
||||
/// <param name="message">日志消息。</param>
|
||||
void Trace(string message);
|
||||
/// <summary>
|
||||
/// 记录警告级别的日志消息。
|
||||
/// </summary>
|
||||
/// <param name="message">日志消息。</param>
|
||||
void Warning(string message);
|
||||
/// <summary>
|
||||
/// 记录信息级别的日志消息。
|
||||
/// </summary>
|
||||
/// <param name="message">日志消息。</param>
|
||||
void Info(string message);
|
||||
/// <summary>
|
||||
/// 记录调试级别的日志消息。
|
||||
/// </summary>
|
||||
/// <param name="message">日志消息。</param>
|
||||
void Debug(string message);
|
||||
/// <summary>
|
||||
/// 记录错误级别的日志消息。
|
||||
/// </summary>
|
||||
/// <param name="message">日志消息。</param>
|
||||
void Error(string message);
|
||||
/// <summary>
|
||||
/// 记录跟踪级别的格式化日志消息。
|
||||
/// </summary>
|
||||
/// <param name="message">日志消息模板。</param>
|
||||
/// <param name="args">格式化参数。</param>
|
||||
void Trace(string message, params object[] args);
|
||||
/// <summary>
|
||||
/// 记录警告级别的格式化日志消息。
|
||||
/// </summary>
|
||||
/// <param name="message">日志消息模板。</param>
|
||||
/// <param name="args">格式化参数。</param>
|
||||
void Warning(string message, params object[] args);
|
||||
/// <summary>
|
||||
/// 记录信息级别的格式化日志消息。
|
||||
/// </summary>
|
||||
/// <param name="message">日志消息模板。</param>
|
||||
/// <param name="args">格式化参数。</param>
|
||||
void Info(string message, params object[] args);
|
||||
/// <summary>
|
||||
/// 记录调试级别的格式化日志消息。
|
||||
/// </summary>
|
||||
/// <param name="message">日志消息模板。</param>
|
||||
/// <param name="args">格式化参数。</param>
|
||||
void Debug(string message, params object[] args);
|
||||
/// <summary>
|
||||
/// 记录错误级别的格式化日志消息。
|
||||
/// </summary>
|
||||
/// <param name="message">日志消息模板。</param>
|
||||
/// <param name="args">格式化参数。</param>
|
||||
void Error(string message, params object[] args);
|
||||
}
|
||||
|
||||
public static class Log
|
||||
{
|
||||
private static readonly ILog LogCore;
|
||||
|
||||
static Log()
|
||||
{
|
||||
LogCore = new ConsoleLog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 记录信息级别的日志消息。
|
||||
/// </summary>
|
||||
/// <param name="msg">日志消息。</param>
|
||||
public static void Info(string msg)
|
||||
{
|
||||
LogCore.Info(msg);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 记录错误级别的日志消息,并附带调用栈信息。
|
||||
/// </summary>
|
||||
/// <param name="msg">日志消息。</param>
|
||||
public static void Error(string msg)
|
||||
{
|
||||
var st = new StackTrace(1, true);
|
||||
LogCore.Error($"{msg}\n{st}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 记录异常的错误级别的日志消息,并附带调用栈信息。
|
||||
/// </summary>
|
||||
/// <param name="e">异常对象。</param>
|
||||
public static void Error(Exception e)
|
||||
{
|
||||
if (e.Data.Contains("StackTrace"))
|
||||
{
|
||||
LogCore.Error($"{e.Data["StackTrace"]}\n{e}");
|
||||
return;
|
||||
}
|
||||
|
||||
var str = e.ToString();
|
||||
LogCore.Error(str);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 记录信息级别的格式化日志消息。
|
||||
/// </summary>
|
||||
/// <param name="message">日志消息模板。</param>
|
||||
/// <param name="args">格式化参数。</param>
|
||||
public static void Info(string message, params object[] args)
|
||||
{
|
||||
LogCore.Info(string.Format(message, args));
|
||||
}
|
||||
}
|
||||
|
||||
public class ConsoleLog : ILog
|
||||
{
|
||||
public void Info(string message)
|
||||
{
|
||||
Console.WriteLine(message);
|
||||
}
|
||||
|
||||
public void Error(string message)
|
||||
{
|
||||
ConsoleColor color = Console.ForegroundColor;
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine($"{message}\n{new StackTrace(1, true)}");
|
||||
Console.ForegroundColor = color;
|
||||
}
|
||||
|
||||
public void Trace(string message)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Warning(string message)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Debug(string message)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Trace(string message, params object[] args)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Warning(string message, params object[] args)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Info(string message, params object[] args)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Debug(string message, params object[] args)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Error(string message, params object[] args)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
||||
namespace Fantasy.Tools.ProtocalExporter;
|
||||
|
||||
public sealed class CustomSerialize
|
||||
{
|
||||
public string NameSpace { get; set; }
|
||||
public int KeyIndex { get; set; }
|
||||
public string SerializeName { get; set; }
|
||||
public string Attribute { get; set; }
|
||||
public string Ignore { get; set; }
|
||||
public string Member { get; set; }
|
||||
public uint OpCodeType { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace Fantasy.Tools;
|
||||
|
||||
/// <summary>
|
||||
/// 导出目标平台枚举,用于标识导出到哪个平台。
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum ExportPlatform : byte
|
||||
{
|
||||
None = 0,
|
||||
Client = 1,
|
||||
Server = 1 << 1,
|
||||
All = Client | Server,
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
namespace Fantasy.Tools.ProtocalExporter;
|
||||
|
||||
public static class NetworkProtocolTemplate
|
||||
{
|
||||
public static readonly string Template ="""
|
||||
#if SERVER
|
||||
using ProtoBuf;
|
||||
(UsingNamespace)
|
||||
using System.Collections.Generic;
|
||||
using MongoDB.Bson.Serialization.Attributes;
|
||||
using Fantasy;
|
||||
using Fantasy.Network.Interface;
|
||||
using Fantasy.Serialize;
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable RedundantUsingDirective
|
||||
// ReSharper disable RedundantOverriddenMember
|
||||
// ReSharper disable PartialTypeWithSinglePart
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable CheckNamespace
|
||||
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
|
||||
#pragma warning disable CS8618
|
||||
|
||||
namespace Fantasy
|
||||
{
|
||||
#else
|
||||
using ProtoBuf;
|
||||
(UsingNamespace)
|
||||
using System.Collections.Generic;
|
||||
using Fantasy;
|
||||
using Fantasy.Network.Interface;
|
||||
using Fantasy.Serialize;
|
||||
#pragma warning disable CS8618
|
||||
|
||||
namespace Fantasy
|
||||
{
|
||||
#endif
|
||||
(Content)}
|
||||
""";
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using Fantasy.Helper;
|
||||
|
||||
namespace Fantasy.Tools.ProtocalExporter;
|
||||
|
||||
internal class OpCodeCache
|
||||
{
|
||||
private readonly List<uint> _opCodes = new List<uint>();
|
||||
private readonly Dictionary<string, uint> _opcodeCache;
|
||||
private readonly Dictionary<string, uint> _saveOpCodeCache = new();
|
||||
private readonly string _opcodeCachePath = $"{ExporterSettingsHelper.NetworkProtocolDirectory}OpCode.Cache";
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数,用于初始化网络协议操作码缓存
|
||||
/// </summary>
|
||||
public OpCodeCache(bool regenerate)
|
||||
{
|
||||
if (File.Exists(_opcodeCachePath) && !regenerate)
|
||||
{
|
||||
var readAllText = File.ReadAllText(_opcodeCachePath);
|
||||
_opcodeCache = readAllText.Deserialize<Dictionary<string, uint>>();
|
||||
_opCodes.AddRange(_opcodeCache.Values);
|
||||
}
|
||||
else
|
||||
{
|
||||
_opcodeCache = new Dictionary<string, uint>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存网络协议操作码
|
||||
/// </summary>
|
||||
public void Save()
|
||||
{
|
||||
File.WriteAllText(_opcodeCachePath, _saveOpCodeCache.ToJson());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据className获得OpCode、如果是新增的会产生一个新的OpCode
|
||||
/// </summary>
|
||||
/// <param name="className">协议名</param>
|
||||
/// <param name="opcode">操作码</param>
|
||||
/// <returns></returns>
|
||||
public uint GetOpcodeCache(string className, ref uint opcode)
|
||||
{
|
||||
if (!_opcodeCache.TryGetValue(className, out var opCode))
|
||||
{
|
||||
while (_opCodes.Contains(++opcode))
|
||||
{
|
||||
|
||||
}
|
||||
opCode = opcode;
|
||||
_opCodes.Add(opCode);
|
||||
}
|
||||
|
||||
_saveOpCodeCache.Add(className, opCode);
|
||||
return opCode;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,891 @@
|
||||
using System.Text;
|
||||
using Fantasy.Exporter;
|
||||
using Fantasy.Helper;
|
||||
using Fantasy.Network;
|
||||
using OpCode = Fantasy.Network.OpCode;
|
||||
using OpCodeType = Fantasy.Network.OpCodeType;
|
||||
#pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type.
|
||||
#pragma warning disable CS8602 // Dereference of a possibly null reference.
|
||||
// ReSharper disable PossibleNullReferenceException
|
||||
// ReSharper disable ConditionIsAlwaysTrueOrFalse
|
||||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
||||
#pragma warning disable CS8604 // Possible null reference argument.
|
||||
|
||||
namespace Fantasy.Tools.ProtocalExporter;
|
||||
public enum NetworkProtocolOpCodeType
|
||||
{
|
||||
None = 0,
|
||||
Outer = 1,
|
||||
Inner = 2,
|
||||
}
|
||||
public sealed class OpcodeInfo
|
||||
{
|
||||
public uint Code;
|
||||
public string Name;
|
||||
}
|
||||
|
||||
public sealed class ProtocolExporter
|
||||
{
|
||||
private string _serverTemplate;
|
||||
private string _clientTemplate;
|
||||
private readonly List<OpcodeInfo> _opcodes = new();
|
||||
private static readonly char[] SplitChars = [' ', '\t'];
|
||||
private readonly string _networkProtocolDirectory;
|
||||
private readonly string _networkProtocolClientDirectory;
|
||||
private readonly string _networkProtocolServerDirectory;
|
||||
private readonly string _networkProtocolDirectoryOuter;
|
||||
private readonly string _networkProtocolDirectoryInner;
|
||||
|
||||
public ProtocolExporter()
|
||||
{
|
||||
Console.OutputEncoding = Encoding.UTF8;
|
||||
|
||||
if (ExporterSettingsHelper.NetworkProtocolDirectory == null || ExporterSettingsHelper.NetworkProtocolDirectory.Trim() == "")
|
||||
{
|
||||
Log.Info($"NetworkProtocolDirectory Can not be empty!");
|
||||
return;
|
||||
}
|
||||
|
||||
_networkProtocolDirectory = ExporterSettingsHelper.NetworkProtocolDirectory;
|
||||
if (ExporterAges.Instance.ExportPlatform.HasFlag(ExportPlatform.Client))
|
||||
{
|
||||
if (ExporterSettingsHelper.NetworkProtocolClientDirectory?.Trim() == "")
|
||||
{
|
||||
Log.Info($"NetworkProtocolClientDirectory Can not be empty!");
|
||||
return;
|
||||
}
|
||||
|
||||
_networkProtocolClientDirectory = ExporterSettingsHelper.NetworkProtocolClientDirectory ?? string.Empty;
|
||||
if (!Directory.Exists(_networkProtocolClientDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(_networkProtocolClientDirectory);
|
||||
}
|
||||
}
|
||||
|
||||
if (ExporterAges.Instance.ExportPlatform.HasFlag(ExportPlatform.Server))
|
||||
{
|
||||
if (ExporterSettingsHelper.NetworkProtocolServerDirectory?.Trim() == "")
|
||||
{
|
||||
Log.Info($"NetworkProtocolServerDirectory Can not be empty!");
|
||||
return;
|
||||
}
|
||||
|
||||
_networkProtocolServerDirectory = ExporterSettingsHelper.NetworkProtocolServerDirectory ?? string.Empty;
|
||||
if (!Directory.Exists(_networkProtocolServerDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(_networkProtocolServerDirectory);
|
||||
}
|
||||
|
||||
_networkProtocolDirectoryInner = $"{_networkProtocolDirectory}Inner";
|
||||
|
||||
if (!Directory.Exists(_networkProtocolDirectoryInner))
|
||||
{
|
||||
Directory.CreateDirectory(_networkProtocolDirectoryInner);
|
||||
}
|
||||
}
|
||||
|
||||
_networkProtocolDirectoryOuter = $"{_networkProtocolDirectory}Outer";
|
||||
|
||||
if (!Directory.Exists(_networkProtocolDirectoryOuter))
|
||||
{
|
||||
Directory.CreateDirectory(_networkProtocolDirectoryOuter);
|
||||
}
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
var tasks = new Task[3];
|
||||
tasks[0] = Task.Run(RouteType);
|
||||
tasks[1] = Task.Run(RoamingType);
|
||||
tasks[2] = Task.Run(async () =>
|
||||
{
|
||||
LoadTemplate();
|
||||
await Start(NetworkProtocolOpCodeType.Outer);
|
||||
if (ExporterAges.Instance.ExportPlatform.HasFlag(ExportPlatform.Server))
|
||||
{
|
||||
await Start(NetworkProtocolOpCodeType.Inner);
|
||||
}
|
||||
});
|
||||
Task.WaitAll(tasks);
|
||||
}
|
||||
|
||||
private async Task Start(NetworkProtocolOpCodeType opCodeType)
|
||||
{
|
||||
var className = "";
|
||||
var opCodeName = "";
|
||||
var file = new StringBuilder();
|
||||
var messageStr = new StringBuilder();
|
||||
var disposeStr = new StringBuilder();
|
||||
var errorCodeStr = new StringBuilder();
|
||||
var usingNamespace = new HashSet<string>();
|
||||
var saveDirectory = new Dictionary<string, string>();
|
||||
|
||||
OpcodeInfo opcodeInfo = null;
|
||||
ProtocolOpCode protocolOpCode = null;
|
||||
string[] protocolFiles = null;
|
||||
_opcodes.Clear();
|
||||
|
||||
switch (opCodeType)
|
||||
{
|
||||
case NetworkProtocolOpCodeType.Outer:
|
||||
{
|
||||
if (ExporterAges.Instance.ExportPlatform.HasFlag(ExportPlatform.Server))
|
||||
{
|
||||
saveDirectory.Add(_networkProtocolServerDirectory, _serverTemplate);
|
||||
}
|
||||
|
||||
if (ExporterAges.Instance.ExportPlatform.HasFlag(ExportPlatform.Client))
|
||||
{
|
||||
saveDirectory.Add(_networkProtocolClientDirectory, _clientTemplate);
|
||||
}
|
||||
|
||||
protocolOpCode = new ProtocolOpCode()
|
||||
{
|
||||
Message = OpCodeType.OuterMessage,
|
||||
Request = OpCodeType.OuterRequest,
|
||||
Response = OpCodeType.OuterResponse,
|
||||
RouteMessage = 0,
|
||||
RouteRequest = 0,
|
||||
RouteResponse = 0,
|
||||
AddressableMessage = OpCodeType.OuterAddressableMessage,
|
||||
AddressableRequest = OpCodeType.OuterAddressableRequest,
|
||||
AddressableResponse = OpCodeType.OuterAddressableResponse,
|
||||
CustomRouteMessage = OpCodeType.OuterCustomRouteMessage,
|
||||
CustomRouteRequest = OpCodeType.OuterCustomRouteRequest,
|
||||
CustomRouteResponse = OpCodeType.OuterCustomRouteResponse,
|
||||
RoamingMessage = OpCodeType.OuterRoamingMessage,
|
||||
RoamingRequest = OpCodeType.OuterRoamingRequest,
|
||||
RoamingResponse = OpCodeType.OuterRoamingResponse,
|
||||
};
|
||||
opCodeName = "OuterOpcode";
|
||||
protocolFiles = FileHelper.GetDirectoryFile(_networkProtocolDirectoryOuter, "*.proto", SearchOption.AllDirectories);
|
||||
break;
|
||||
}
|
||||
case NetworkProtocolOpCodeType.Inner:
|
||||
{
|
||||
protocolOpCode = new ProtocolOpCode()
|
||||
{
|
||||
Message = OpCodeType.InnerMessage,
|
||||
Request = OpCodeType.InnerRequest,
|
||||
Response = OpCodeType.InnerResponse,
|
||||
RouteMessage = OpCodeType.InnerRouteMessage,
|
||||
RouteRequest = OpCodeType.InnerRouteRequest,
|
||||
RouteResponse = OpCodeType.InnerRouteResponse,
|
||||
AddressableMessage = OpCodeType.InnerAddressableMessage,
|
||||
AddressableRequest = OpCodeType.InnerAddressableRequest,
|
||||
AddressableResponse = OpCodeType.InnerAddressableResponse,
|
||||
CustomRouteMessage = 0,
|
||||
CustomRouteRequest = 0,
|
||||
CustomRouteResponse = 0,
|
||||
RoamingMessage = OpCodeType.InnerRoamingMessage,
|
||||
RoamingRequest = OpCodeType.InnerRoamingRequest,
|
||||
RoamingResponse = OpCodeType.InnerRoamingResponse,
|
||||
};
|
||||
opCodeName = "InnerOpcode";
|
||||
saveDirectory.Add(_networkProtocolServerDirectory, _serverTemplate);
|
||||
protocolFiles = FileHelper.GetDirectoryFile(_networkProtocolDirectoryInner, "*.proto", SearchOption.AllDirectories);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (protocolFiles == null || protocolFiles.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#region GenerateFiles
|
||||
|
||||
foreach (var filePath in protocolFiles)
|
||||
{
|
||||
var keyIndex = 1;
|
||||
var parameter = "";
|
||||
var hasOpCode = false;
|
||||
var isMsgHead = false;
|
||||
var isSetProtocol = false;
|
||||
string responseTypeStr = null;
|
||||
string customRouteType = null;
|
||||
string protocolMember = "ProtoMember";
|
||||
string protocolType = "\t[ProtoContract]";
|
||||
string protocolIgnore = "\t\t[ProtoIgnore]";
|
||||
var protocolOpCodeType = OpCodeProtocolType.ProtoBuf;
|
||||
var fileText = await File.ReadAllTextAsync(filePath);
|
||||
|
||||
foreach (var line in fileText.Split('\n'))
|
||||
{
|
||||
var currentLine = line.Trim();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(currentLine))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (currentLine.StartsWith("///"))
|
||||
{
|
||||
messageStr.AppendFormat(" /// <summary>\r\n" + " /// {0}\r\n" + " /// </summary>\r\n", currentLine.Substring("///".Length));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (currentLine.StartsWith("// Protocol"))
|
||||
{
|
||||
isSetProtocol = true;
|
||||
var protocol = currentLine.Substring("// Protocol".Length).Trim();
|
||||
|
||||
switch (protocol)
|
||||
{
|
||||
case "ProtoBuf":
|
||||
{
|
||||
protocolType = "\t[ProtoContract]";
|
||||
protocolIgnore = "\t\t[ProtoIgnore]";
|
||||
protocolMember = "ProtoMember";
|
||||
protocolOpCodeType = OpCodeProtocolType.ProtoBuf;
|
||||
break;
|
||||
}
|
||||
// case "MemoryPack":
|
||||
// {
|
||||
// keyIndex = 0;
|
||||
// protocolType = "\t[MemoryPackable]";
|
||||
// protocolIgnore = "\t\t[MemoryPackIgnore]";
|
||||
// protocolMember = "MemoryPackOrder";
|
||||
// // protocolOpCodeType = OpCodeProtocolType.MemoryPack;
|
||||
// break;
|
||||
// }
|
||||
case "Bson":
|
||||
{
|
||||
if (opCodeType == NetworkProtocolOpCodeType.Outer)
|
||||
{
|
||||
Log.Error("Under Outer, /// does not support the Bson protocol!");
|
||||
return;
|
||||
}
|
||||
protocolType = null;
|
||||
protocolIgnore = "\t\t[BsonIgnore]";
|
||||
protocolMember = null;
|
||||
protocolOpCodeType = OpCodeProtocolType.Bson;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
if (!ExporterSettingsHelper.CustomSerializes.TryGetValue(protocol, out var customSerialize))
|
||||
{
|
||||
Log.Error($"// Protocol {protocol} is not supported!");
|
||||
return;
|
||||
}
|
||||
|
||||
usingNamespace.Add(customSerialize.NameSpace);
|
||||
keyIndex = customSerialize.KeyIndex;
|
||||
protocolType = customSerialize.Attribute;
|
||||
protocolIgnore = customSerialize.Ignore;
|
||||
protocolMember = customSerialize.Member;
|
||||
protocolOpCodeType = customSerialize.OpCodeType;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (currentLine.StartsWith("message"))
|
||||
{
|
||||
isMsgHead = true;
|
||||
className = currentLine.Split(SplitChars, StringSplitOptions.RemoveEmptyEntries)[1];
|
||||
var splits = currentLine.Split(new[] { "//" }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if (isSetProtocol)
|
||||
{
|
||||
if (protocolType != null)
|
||||
{
|
||||
messageStr.AppendLine(protocolType);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
messageStr.AppendLine("\t[ProtoContract]");
|
||||
}
|
||||
|
||||
if (splits.Length > 1)
|
||||
{
|
||||
hasOpCode = true;
|
||||
var parameterArray = currentLine.Split(new[] { "//" }, StringSplitOptions.RemoveEmptyEntries)[1].Trim().Split(',');
|
||||
parameter = parameterArray[0].Trim();
|
||||
opcodeInfo = new OpcodeInfo()
|
||||
{
|
||||
Name = className
|
||||
};
|
||||
switch (parameterArray.Length)
|
||||
{
|
||||
case 2:
|
||||
{
|
||||
switch (parameter)
|
||||
{
|
||||
case "ICustomRouteMessage":
|
||||
{
|
||||
customRouteType = $"Fantasy.RouteType.{parameterArray[1].Trim()}";
|
||||
break;
|
||||
}
|
||||
case "IRoamingMessage":
|
||||
{
|
||||
customRouteType = $"Fantasy.RoamingType.{parameterArray[1].Trim()}";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
responseTypeStr = parameterArray[1].Trim();
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
responseTypeStr = parameterArray[1].Trim();
|
||||
customRouteType = parameter.Contains("IRoaming") ? $"Fantasy.RoamingType.{parameterArray[2].Trim()}" : $"Fantasy.RouteType.{parameterArray[2].Trim()}";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
parameter = "";
|
||||
hasOpCode = false;
|
||||
}
|
||||
|
||||
messageStr.Append(string.IsNullOrWhiteSpace(parameter)
|
||||
? $"\tpublic partial class {className} : AMessage"
|
||||
: $"\tpublic partial class {className} : AMessage, {parameter}");
|
||||
if (protocolMember == "ProtoMember")
|
||||
{
|
||||
messageStr.Append(", IProto");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isMsgHead)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (currentLine)
|
||||
{
|
||||
case "{":
|
||||
{
|
||||
messageStr.AppendLine("\n\t{");
|
||||
messageStr.AppendLine($"\t\tpublic static {className} Create(Scene scene)");
|
||||
messageStr.AppendLine($"\t\t{{\n\t\t\treturn scene.MessagePoolComponent.Rent<{className}>();\n\t\t}}");
|
||||
messageStr.AppendLine($"\t\tpublic override void Dispose()");
|
||||
messageStr.AppendLine($"\t\t{{");
|
||||
messageStr.AppendLine($"<<<<Dispose>>>#if FANTASY_NET || FANTASY_UNITY\n\t\t\tGetScene().MessagePoolComponent.Return<{className}>(this);\n#endif");
|
||||
messageStr.AppendLine($"\t\t}}");
|
||||
|
||||
if (parameter == "IMessage")
|
||||
{
|
||||
opcodeInfo.Code = OpCode.Create(protocolOpCodeType, protocolOpCode.Message, protocolOpCode.AMessage++);
|
||||
messageStr.AppendLine($"\t\tpublic uint OpCode() {{ return {opCodeName}.{className}; }}");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (responseTypeStr != null)
|
||||
{
|
||||
messageStr.AppendLine(protocolIgnore);
|
||||
messageStr.AppendLine($"\t\tpublic {responseTypeStr} ResponseType {{ get; set; }}");
|
||||
responseTypeStr = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (parameter.Contains("RouteRequest"))
|
||||
{
|
||||
Log.Error($"{opcodeInfo.Name} 没指定ResponseType");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasOpCode)
|
||||
{
|
||||
messageStr.AppendLine($"\t\tpublic uint OpCode() {{ return {opCodeName}.{className}; }}");
|
||||
}
|
||||
|
||||
if (customRouteType != null)
|
||||
{
|
||||
messageStr.AppendLine(protocolIgnore);
|
||||
messageStr.AppendLine($"\t\tpublic int RouteType => {customRouteType};");
|
||||
customRouteType = null;
|
||||
}
|
||||
|
||||
switch (parameter)
|
||||
{
|
||||
case "IRequest":
|
||||
{
|
||||
opcodeInfo.Code = OpCode.Create(protocolOpCodeType, protocolOpCode.Request, protocolOpCode.ARequest++);
|
||||
break;
|
||||
}
|
||||
case "IResponse":
|
||||
{
|
||||
opcodeInfo.Code = OpCode.Create(protocolOpCodeType, protocolOpCode.Response, protocolOpCode.AResponse++);
|
||||
if (!string.IsNullOrEmpty(protocolMember))
|
||||
{
|
||||
errorCodeStr.AppendLine($"\t\t[{protocolMember}(ErrorCodeKeyIndex)]");
|
||||
}
|
||||
errorCodeStr.AppendLine("\t\tpublic uint ErrorCode { get; set; }");
|
||||
disposeStr.AppendLine($"\t\t\tErrorCode = default;");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
switch (parameter)
|
||||
{
|
||||
case "IAddressableRouteMessage":
|
||||
{
|
||||
opcodeInfo.Code = OpCode.Create(protocolOpCodeType, protocolOpCode.AddressableMessage, protocolOpCode.AAddressableMessage++);
|
||||
break;
|
||||
}
|
||||
case "IAddressableRouteRequest":
|
||||
{
|
||||
opcodeInfo.Code = OpCode.Create(protocolOpCodeType, protocolOpCode.AddressableRequest, protocolOpCode.AAddressableRequest++);
|
||||
break;
|
||||
}
|
||||
case "IAddressableRouteResponse":
|
||||
{
|
||||
opcodeInfo.Code = OpCode.Create(protocolOpCodeType, protocolOpCode.AddressableResponse, protocolOpCode.AAddressableResponse++);
|
||||
if (!string.IsNullOrEmpty(protocolMember))
|
||||
{
|
||||
errorCodeStr.AppendLine($"\t\t[{protocolMember}(ErrorCodeKeyIndex)]");
|
||||
}
|
||||
errorCodeStr.AppendLine("\t\tpublic uint ErrorCode { get; set; }");
|
||||
disposeStr.AppendLine($"\t\t\tErrorCode = default;");
|
||||
break;
|
||||
}
|
||||
case "ICustomRouteMessage":
|
||||
{
|
||||
if (opCodeType == NetworkProtocolOpCodeType.Inner)
|
||||
{
|
||||
throw new NotSupportedException("Under Inner, /// does not support the ICustomRouteMessage!");
|
||||
}
|
||||
opcodeInfo.Code = OpCode.Create(protocolOpCodeType, protocolOpCode.CustomRouteMessage, protocolOpCode.ACustomRouteMessage++);
|
||||
break;
|
||||
}
|
||||
case "ICustomRouteRequest":
|
||||
{
|
||||
if (opCodeType == NetworkProtocolOpCodeType.Inner)
|
||||
{
|
||||
throw new NotSupportedException("Under Inner, /// does not support the ICustomRouteMessage!");
|
||||
}
|
||||
opcodeInfo.Code = OpCode.Create(protocolOpCodeType, protocolOpCode.CustomRouteRequest, protocolOpCode.ACustomRouteRequest++);
|
||||
break;
|
||||
}
|
||||
case "ICustomRouteResponse":
|
||||
{
|
||||
if (opCodeType == NetworkProtocolOpCodeType.Inner)
|
||||
{
|
||||
throw new NotSupportedException("Under Inner, /// does not support the ICustomRouteMessage!");
|
||||
}
|
||||
opcodeInfo.Code = OpCode.Create(protocolOpCodeType, protocolOpCode.CustomRouteResponse, protocolOpCode.ACustomRouteResponse++);
|
||||
if (!string.IsNullOrEmpty(protocolMember))
|
||||
{
|
||||
errorCodeStr.AppendLine($"\t\t[{protocolMember}(ErrorCodeKeyIndex)]");
|
||||
}
|
||||
errorCodeStr.AppendLine("\t\tpublic uint ErrorCode { get; set; }");
|
||||
disposeStr.AppendLine($"\t\t\tErrorCode = default;");
|
||||
break;
|
||||
}
|
||||
case "IRoamingMessage":
|
||||
{
|
||||
// if (opCodeType == NetworkProtocolOpCodeType.Inner)
|
||||
// {
|
||||
// throw new NotSupportedException("Under Inner, /// does not support the IRoamingMessage!");
|
||||
// }
|
||||
opcodeInfo.Code = OpCode.Create(protocolOpCodeType, protocolOpCode.RoamingMessage, protocolOpCode.ARoamingMessage++);
|
||||
break;
|
||||
}
|
||||
case "IRoamingRequest":
|
||||
{
|
||||
// if (opCodeType == NetworkProtocolOpCodeType.Inner)
|
||||
// {
|
||||
// throw new NotSupportedException("Under Inner, /// does not support the IRoamingRequest!");
|
||||
// }
|
||||
opcodeInfo.Code = OpCode.Create(protocolOpCodeType, protocolOpCode.RoamingRequest, protocolOpCode.ARoamingRequest++);
|
||||
break;
|
||||
}
|
||||
case "IRoamingResponse":
|
||||
{
|
||||
// if (opCodeType == NetworkProtocolOpCodeType.Inner)
|
||||
// {
|
||||
// throw new NotSupportedException("Under Inner, /// does not support the IRoamingResponse!");
|
||||
// }
|
||||
opcodeInfo.Code = OpCode.Create(protocolOpCodeType, protocolOpCode.RoamingResponse, protocolOpCode.ARoamingResponse++);
|
||||
if (!string.IsNullOrEmpty(protocolMember))
|
||||
{
|
||||
errorCodeStr.AppendLine($"\t\t[{protocolMember}(ErrorCodeKeyIndex)]");
|
||||
}
|
||||
errorCodeStr.AppendLine("\t\tpublic uint ErrorCode { get; set; }");
|
||||
disposeStr.AppendLine($"\t\t\tErrorCode = default;");
|
||||
break;
|
||||
}
|
||||
case "IRouteMessage":
|
||||
{
|
||||
if (opCodeType == NetworkProtocolOpCodeType.Outer)
|
||||
{
|
||||
throw new NotSupportedException("Under Inner, /// does not support the ICustomRouteMessage!");
|
||||
}
|
||||
opcodeInfo.Code = OpCode.Create(protocolOpCodeType, protocolOpCode.RouteMessage, protocolOpCode.ARouteMessage++);
|
||||
break;
|
||||
}
|
||||
case "IRouteRequest":
|
||||
{
|
||||
if (opCodeType == NetworkProtocolOpCodeType.Outer)
|
||||
{
|
||||
throw new NotSupportedException("Under Inner, /// does not support the ICustomRouteMessage!");
|
||||
}
|
||||
opcodeInfo.Code = OpCode.Create(protocolOpCodeType, protocolOpCode.RouteRequest, protocolOpCode.ARouteRequest++);
|
||||
break;
|
||||
}
|
||||
case "IRouteResponse":
|
||||
{
|
||||
if (opCodeType == NetworkProtocolOpCodeType.Outer)
|
||||
{
|
||||
throw new NotSupportedException("Under Inner, /// does not support the ICustomRouteMessage!");
|
||||
}
|
||||
opcodeInfo.Code = OpCode.Create(protocolOpCodeType, protocolOpCode.RouteResponse, protocolOpCode.ARouteResponse++);
|
||||
if (!string.IsNullOrEmpty(protocolMember))
|
||||
{
|
||||
errorCodeStr.AppendLine($"\t\t[{protocolMember}(ErrorCodeKeyIndex)]");
|
||||
}
|
||||
errorCodeStr.AppendLine("\t\tpublic uint ErrorCode { get; set; }");
|
||||
disposeStr.AppendLine($"\t\t\tErrorCode = default;");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasOpCode)
|
||||
{
|
||||
_opcodes.Add(opcodeInfo);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
case "}":
|
||||
{
|
||||
isMsgHead = false;
|
||||
errorCodeStr = errorCodeStr.Replace("ErrorCodeKeyIndex", keyIndex.ToString());
|
||||
messageStr = messageStr.Replace("<<<<Dispose>>>", disposeStr.ToString());
|
||||
messageStr.Append(errorCodeStr);
|
||||
messageStr.AppendLine("\t}");
|
||||
file.Append(messageStr);
|
||||
messageStr.Clear();
|
||||
disposeStr.Clear();
|
||||
errorCodeStr.Clear();
|
||||
keyIndex = 1;
|
||||
protocolType = "\t[ProtoContract]";
|
||||
protocolIgnore = "\t\t[ProtoIgnore]";
|
||||
protocolMember = "ProtoMember";
|
||||
protocolOpCodeType = OpCodeProtocolType.ProtoBuf;
|
||||
continue;
|
||||
}
|
||||
case "":
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentLine.StartsWith("//"))
|
||||
{
|
||||
messageStr.AppendFormat("\t\t///<summary>\r\n" + "\t\t/// {0}\r\n" + "\t\t///</summary>\r\n", currentLine.TrimStart('/', '/'));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (currentLine.StartsWith("repeated"))
|
||||
{
|
||||
Repeated(messageStr, disposeStr, currentLine, protocolMember, ref keyIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
Members(messageStr, disposeStr, currentLine, protocolMember, ref keyIndex);
|
||||
}
|
||||
}
|
||||
|
||||
var namespaceBuilder = new StringBuilder();
|
||||
|
||||
foreach (var @namespace in usingNamespace)
|
||||
{
|
||||
namespaceBuilder.Append($"using {@namespace};\n");
|
||||
}
|
||||
|
||||
var csName = $"{Path.GetFileNameWithoutExtension(filePath)}.cs";
|
||||
foreach (var (directory, template) in saveDirectory)
|
||||
{
|
||||
var csFile = Path.Combine(directory, csName);
|
||||
var content = template.Replace("(Content)", file.ToString());
|
||||
content = content.Replace("(UsingNamespace)", namespaceBuilder.ToString());
|
||||
await File.WriteAllTextAsync(csFile, content);
|
||||
}
|
||||
file.Clear();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GenerateOpCode
|
||||
|
||||
file.Clear();
|
||||
file.AppendLine("namespace Fantasy");
|
||||
file.AppendLine("{");
|
||||
file.AppendLine($"\tpublic static partial class {opCodeName}");
|
||||
file.AppendLine("\t{");
|
||||
|
||||
foreach (var opcode in _opcodes)
|
||||
{
|
||||
file.AppendLine($"\t\t public const uint {opcode.Name} = {opcode.Code};");
|
||||
}
|
||||
|
||||
_opcodes.Clear();
|
||||
file.AppendLine("\t}");
|
||||
file.AppendLine("}");
|
||||
|
||||
foreach (var (directory, _) in saveDirectory)
|
||||
{
|
||||
var csFile = Path.Combine(directory, $"{opCodeName}.cs");
|
||||
await File.WriteAllTextAsync(csFile, file.ToString());
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
private void Repeated(StringBuilder file, StringBuilder disposeStr, string newline, string protocolMember, ref int keyIndex)
|
||||
{
|
||||
try
|
||||
{
|
||||
var index = newline.IndexOf(";", StringComparison.Ordinal);
|
||||
newline = newline.Remove(index);
|
||||
var property = newline.Split(SplitChars, StringSplitOptions.RemoveEmptyEntries);
|
||||
var type = property[1];
|
||||
var name = property[2];
|
||||
// var memberIndex = int.Parse(property[4]);
|
||||
type = ConvertType(type);
|
||||
|
||||
file.AppendLine($"\t\t[{protocolMember}({keyIndex++})]");
|
||||
file.AppendLine($"\t\tpublic List<{type}> {name} = new List<{type}>();");
|
||||
disposeStr.AppendLine($"\t\t\t{name}.Clear();");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error($"{newline}\n {e}");
|
||||
}
|
||||
}
|
||||
|
||||
private void Members(StringBuilder file, StringBuilder disposeStr, string currentLine, string protocolMember, ref int keyIndex)
|
||||
{
|
||||
try
|
||||
{
|
||||
var index = currentLine.IndexOf(";", StringComparison.Ordinal);
|
||||
currentLine = currentLine.Remove(index);
|
||||
var property = currentLine.Split(SplitChars, StringSplitOptions.RemoveEmptyEntries);
|
||||
var type = property[0];
|
||||
var name = property[1];
|
||||
// var memberIndex = int.Parse(property[3]);
|
||||
var typeCs = ConvertType(type);
|
||||
if (protocolMember != null)
|
||||
{
|
||||
file.AppendLine($"\t\t[{protocolMember}({keyIndex++})]");
|
||||
}
|
||||
file.AppendLine($"\t\tpublic {typeCs} {name} {{ get; set; }}");
|
||||
disposeStr.AppendLine($"\t\t\t{name} = default;");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error($"{currentLine}\n {e}");
|
||||
}
|
||||
}
|
||||
|
||||
private string ConvertType(string type)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
"int[]" => "int[] { }",
|
||||
"int32[]" => "int[] { }",
|
||||
"int64[]" => "long[] { }",
|
||||
"int32" => "int",
|
||||
"uint32" => "uint",
|
||||
"int64" => "long",
|
||||
"uint64" => "ulong",
|
||||
_ => type
|
||||
};
|
||||
}
|
||||
|
||||
private async Task RoamingType()
|
||||
{
|
||||
var routeTypeFile = $"{_networkProtocolDirectory}RoamingType.Config";
|
||||
var protoFileText = "";
|
||||
if (!File.Exists(routeTypeFile))
|
||||
{
|
||||
protoFileText = "// Roaming协议定义(需要定义10000以上、因为10000以内的框架预留)\n";
|
||||
await File.WriteAllTextAsync(routeTypeFile, protoFileText);
|
||||
}
|
||||
else
|
||||
{
|
||||
protoFileText = await File.ReadAllTextAsync(routeTypeFile);
|
||||
}
|
||||
|
||||
var roamingTypes = new HashSet<int>();
|
||||
var roamingTypeFileSb = new StringBuilder();
|
||||
roamingTypeFileSb.AppendLine("using System.Collections.Generic;");
|
||||
roamingTypeFileSb.AppendLine("namespace Fantasy\n{");
|
||||
roamingTypeFileSb.AppendLine("\t// Roaming协议定义(需要定义10000以上、因为10000以内的框架预留)\t");
|
||||
roamingTypeFileSb.AppendLine("\tpublic static class RoamingType\n\t{");
|
||||
|
||||
foreach (var line in protoFileText.Split('\n'))
|
||||
{
|
||||
var currentLine = line.Trim();
|
||||
|
||||
if (currentLine == "" || currentLine.StartsWith("//"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var splits = currentLine.Split(["//"], StringSplitOptions.RemoveEmptyEntries);
|
||||
var routeTypeStr = splits[0].Split("=", StringSplitOptions.RemoveEmptyEntries);
|
||||
var roamingType = routeTypeStr[1].Trim();
|
||||
roamingTypes.Add(int.Parse(roamingType));
|
||||
roamingTypeFileSb.Append($"\t\tpublic const int {routeTypeStr[0].Trim()} = {roamingType};");
|
||||
|
||||
if (splits.Length > 1)
|
||||
{
|
||||
roamingTypeFileSb.Append($" // {splits[1].Trim()}\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
roamingTypeFileSb.Append('\n');
|
||||
}
|
||||
}
|
||||
|
||||
if (roamingTypes.Count > 0)
|
||||
{
|
||||
roamingTypeFileSb.AppendLine("\t\tpublic static IEnumerable<int> RoamingTypes");
|
||||
roamingTypeFileSb.AppendLine("\t\t{\n\t\t\tget\n\t\t\t{");
|
||||
foreach (var roamingType in roamingTypes)
|
||||
{
|
||||
roamingTypeFileSb.AppendLine($"\t\t\t\tyield return {roamingType};");
|
||||
}
|
||||
roamingTypeFileSb.AppendLine("\t\t\t}\n\t\t}");
|
||||
}
|
||||
|
||||
|
||||
roamingTypeFileSb.AppendLine("\t}\n}");
|
||||
var file = roamingTypeFileSb.ToString();
|
||||
|
||||
if (ExporterAges.Instance.ExportPlatform.HasFlag(ExportPlatform.Server))
|
||||
{
|
||||
await File.WriteAllTextAsync($"{_networkProtocolServerDirectory}RoamingType.cs", file);
|
||||
}
|
||||
|
||||
if (ExporterAges.Instance.ExportPlatform.HasFlag(ExportPlatform.Client))
|
||||
{
|
||||
await File.WriteAllTextAsync($"{_networkProtocolClientDirectory}RoamingType.cs", file);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task RouteType()
|
||||
{
|
||||
var routeTypeFile = $"{_networkProtocolDirectory}RouteType.Config";
|
||||
var protoFileText = "";
|
||||
if (!File.Exists(routeTypeFile))
|
||||
{
|
||||
protoFileText = "// Route协议定义(需要定义1000以上、因为1000以内的框架预留)\n";
|
||||
await File.WriteAllTextAsync(routeTypeFile, protoFileText);
|
||||
}
|
||||
else
|
||||
{
|
||||
protoFileText = await File.ReadAllTextAsync(routeTypeFile);
|
||||
}
|
||||
var routeTypeFileSb = new StringBuilder();
|
||||
routeTypeFileSb.AppendLine("namespace Fantasy\n{");
|
||||
routeTypeFileSb.AppendLine("\t// Route协议定义(需要定义1000以上、因为1000以内的框架预留)\t");
|
||||
routeTypeFileSb.AppendLine("\tpublic static class RouteType\n\t{");
|
||||
|
||||
foreach (var line in protoFileText.Split('\n'))
|
||||
{
|
||||
var currentLine = line.Trim();
|
||||
|
||||
if (currentLine.StartsWith("//"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var splits = currentLine.Split(new[] { "//" }, StringSplitOptions.RemoveEmptyEntries);
|
||||
var routeTypeStr = splits[0].Split("=", StringSplitOptions.RemoveEmptyEntries);
|
||||
routeTypeFileSb.Append($"\t\tpublic const int {routeTypeStr[0].Trim()} = {routeTypeStr[1].Trim()};");
|
||||
|
||||
if (splits.Length > 1)
|
||||
{
|
||||
routeTypeFileSb.Append($" // {splits[1].Trim()}\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
routeTypeFileSb.Append('\n');
|
||||
}
|
||||
}
|
||||
|
||||
routeTypeFileSb.AppendLine("\t}\n}");
|
||||
var file = routeTypeFileSb.ToString();
|
||||
|
||||
if (ExporterAges.Instance.ExportPlatform.HasFlag(ExportPlatform.Server))
|
||||
{
|
||||
await File.WriteAllTextAsync($"{_networkProtocolServerDirectory}RouteType.cs", file);
|
||||
}
|
||||
|
||||
if (ExporterAges.Instance.ExportPlatform.HasFlag(ExportPlatform.Client))
|
||||
{
|
||||
await File.WriteAllTextAsync($"{_networkProtocolClientDirectory}RouteType.cs", file);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadTemplate()
|
||||
{
|
||||
string[] lines = NetworkProtocolTemplate.Template.Split(["\r\n", "\n"], StringSplitOptions.None);
|
||||
|
||||
StringBuilder serverSb = new StringBuilder();
|
||||
StringBuilder clientSb = new StringBuilder();
|
||||
|
||||
int flag = 0;
|
||||
foreach (string line in lines)
|
||||
{
|
||||
string trim = line.Trim();
|
||||
|
||||
if (trim.StartsWith("#if") && trim.Contains("SERVER"))
|
||||
{
|
||||
flag = 1;
|
||||
continue;
|
||||
}
|
||||
else if (trim.StartsWith("#else"))
|
||||
{
|
||||
flag = 2;
|
||||
continue;
|
||||
}
|
||||
else if (trim.StartsWith($"#endif"))
|
||||
{
|
||||
flag = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (flag)
|
||||
{
|
||||
case 1: // 服务端
|
||||
{
|
||||
serverSb.AppendLine(line);
|
||||
break;
|
||||
}
|
||||
case 2: // 客户端
|
||||
{
|
||||
clientSb.AppendLine(line);
|
||||
break;
|
||||
}
|
||||
default: // 双端
|
||||
{
|
||||
serverSb.AppendLine(line);
|
||||
clientSb.AppendLine(line);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_serverTemplate = serverSb.Replace("(NetworkProtocol)", "ProtoBuf").ToString();
|
||||
_clientTemplate = clientSb.Replace("(NetworkProtocol)", "ProtoBuf").ToString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
namespace Fantasy.Tools.ProtocalExporter;
|
||||
|
||||
public class ProtocolOpCode
|
||||
{
|
||||
private const int Start = 10001;
|
||||
|
||||
public uint Message;
|
||||
public uint Request;
|
||||
public uint Response;
|
||||
public uint RouteMessage;
|
||||
public uint RouteRequest;
|
||||
public uint RouteResponse;
|
||||
public uint AddressableMessage;
|
||||
public uint AddressableRequest;
|
||||
public uint AddressableResponse;
|
||||
public uint CustomRouteMessage;
|
||||
public uint CustomRouteRequest;
|
||||
public uint CustomRouteResponse;
|
||||
public uint RoamingMessage;
|
||||
public uint RoamingRequest;
|
||||
public uint RoamingResponse;
|
||||
|
||||
public uint AMessage = Start;
|
||||
public uint ARequest = Start;
|
||||
public uint AResponse = Start;
|
||||
public uint ARouteMessage = Start;
|
||||
public uint ARouteRequest = Start;
|
||||
public uint ARouteResponse = Start;
|
||||
public uint AAddressableMessage = Start;
|
||||
public uint AAddressableRequest = Start;
|
||||
public uint AAddressableResponse = Start;
|
||||
public uint ACustomRouteMessage = Start;
|
||||
public uint ACustomRouteRequest = Start;
|
||||
public uint ACustomRouteResponse = Start;
|
||||
public uint ARoamingMessage = Start;
|
||||
public uint ARoamingRequest = Start;
|
||||
public uint ARoamingResponse = Start;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user