【特性】新增 --output_compact_json 选项,生成紧凑的json格式

main
walon 2021-10-22 16:59:29 +08:00
parent 5665e76299
commit 8ad27e8275
6 changed files with 44 additions and 10 deletions

View File

@ -73,6 +73,7 @@ namespace Luban.Job.Cfg.Cache
} }
private readonly ConcurrentDictionary<(string TableFullName, string DataType), (DefTable Table, List<Record> Records, string Md5)> _tableCaches = new(); private readonly ConcurrentDictionary<(string TableFullName, string DataType), (DefTable Table, List<Record> Records, string Md5)> _tableCaches = new();
public bool TryGetRecordOutputData(DefTable table, List<Record> records, string dataType, out string md5) public bool TryGetRecordOutputData(DefTable table, List<Record> records, string dataType, out string md5)
{ {
if (_tableCaches.TryGetValue((table.FullName, dataType), out var cacheInfo)) if (_tableCaches.TryGetValue((table.FullName, dataType), out var cacheInfo))
@ -82,6 +83,7 @@ namespace Luban.Job.Cfg.Cache
if (cacheAss.TimeZone == curAss.TimeZone if (cacheAss.TimeZone == curAss.TimeZone
&& cacheAss.TargetPatch == null && curAss.TargetPatch == null && cacheAss.TargetPatch == null && curAss.TargetPatch == null
&& !cacheAss.NeedL10nTextTranslate && !curAss.NeedL10nTextTranslate && !cacheAss.NeedL10nTextTranslate && !curAss.NeedL10nTextTranslate
&& cacheAss.OutputCompactJson == curAss.OutputCompactJson
&& records.Count == cacheInfo.Records.Count && records.SequenceEqual(cacheInfo.Records)) && records.Count == cacheInfo.Records.Count && records.SequenceEqual(cacheInfo.Records))
{ {
md5 = cacheInfo.Md5; md5 = cacheInfo.Md5;

View File

@ -49,6 +49,8 @@ namespace Luban.Job.Cfg.Defs
public TimeZoneInfo TimeZone { get; } public TimeZoneInfo TimeZone { get; }
public bool OutputCompactJson { get; init; }
public DefAssembly(string patchName, TimeZoneInfo timezone, List<string> excludeTags, IAgent agent) public DefAssembly(string patchName, TimeZoneInfo timezone, List<string> excludeTags, IAgent agent)
{ {
this._patchName = patchName; this._patchName = patchName;

View File

@ -29,6 +29,9 @@ namespace Luban.Job.Cfg
[Option("data_file_extension", Required = false, HelpText = "data file name extension. default choose by gen_type")] [Option("data_file_extension", Required = false, HelpText = "data file name extension. default choose by gen_type")]
public string DataFileExtension { get; set; } public string DataFileExtension { get; set; }
[Option("output_compact_json", Required = false, HelpText = "output compact json data. drop blank characters. ")]
public bool OutputCompactJson { get; set; }
[Option('s', "service", Required = true, HelpText = "service")] [Option('s', "service", Required = true, HelpText = "service")]
public string Service { get; set; } public string Service { get; set; }

View File

@ -143,7 +143,8 @@ namespace Luban.Job.Cfg
var excludeTags = args.ExportExcludeTags.Split(',').Select(t => t.Trim().ToLowerInvariant()).Where(t => !string.IsNullOrEmpty(t)).ToList(); var excludeTags = args.ExportExcludeTags.Split(',').Select(t => t.Trim().ToLowerInvariant()).Where(t => !string.IsNullOrEmpty(t)).ToList();
var ass = new DefAssembly(args.PatchName, timeZoneInfo, excludeTags, agent) var ass = new DefAssembly(args.PatchName, timeZoneInfo, excludeTags, agent)
{ {
UseUnityVectors = args.UseUnityVectors UseUnityVectors = args.UseUnityVectors,
OutputCompactJson = args.OutputCompactJson,
}; };
ass.Load(args.Service, rawDefines); ass.Load(args.Service, rawDefines);

View File

@ -45,7 +45,7 @@ namespace Luban.Job.Cfg.Utils
var ss = new MemoryStream(); var ss = new MemoryStream();
var jsonWriter = new Utf8JsonWriter(ss, new JsonWriterOptions() var jsonWriter = new Utf8JsonWriter(ss, new JsonWriterOptions()
{ {
Indented = true, Indented = !table.Assembly.OutputCompactJson,
SkipValidation = false, SkipValidation = false,
Encoder = System.Text.Encodings.Web.JavaScriptEncoder.Create(System.Text.Unicode.UnicodeRanges.All), Encoder = System.Text.Encodings.Web.JavaScriptEncoder.Create(System.Text.Unicode.UnicodeRanges.All),
}); });

View File

@ -26,18 +26,41 @@
<NoStandardLibraries>false</NoStandardLibraries> <NoStandardLibraries>false</NoStandardLibraries>
<RootNamespace>LubanAssistant</RootNamespace> <RootNamespace>LubanAssistant</RootNamespace>
<AssemblyName>LubanAssistant</AssemblyName> <AssemblyName>LubanAssistant</AssemblyName>
<LoadBehavior>3</LoadBehavior>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<DefineConstants>VSTO40</DefineConstants> <DefineConstants>VSTO40</DefineConstants>
<BootstrapperEnabled>true</BootstrapperEnabled>
<BootstrapperComponentsLocation>HomeSite</BootstrapperComponentsLocation>
<NuGetPackageImportStamp> <NuGetPackageImportStamp>
</NuGetPackageImportStamp> </NuGetPackageImportStamp>
<IsWebBootstrapper>False</IsWebBootstrapper>
<BootstrapperEnabled>true</BootstrapperEnabled>
<PublishUrl>publish\</PublishUrl>
<InstallUrl />
<TargetCulture>zh-chs</TargetCulture>
<ApplicationVersion>1.0.0.3</ApplicationVersion>
<AutoIncrementApplicationRevision>true</AutoIncrementApplicationRevision>
<UpdateEnabled>false</UpdateEnabled>
<UpdateInterval>0</UpdateInterval>
<UpdateIntervalUnits>days</UpdateIntervalUnits>
<ProductName>LubanAssistant</ProductName>
<PublisherName>focus creative games</PublisherName>
<SupportUrl>https://github.com/focus-creative-games/luban</SupportUrl>
<FriendlyName>LubanAssistant</FriendlyName>
<OfficeApplicationDescription />
<LoadBehavior>3</LoadBehavior>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.7.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.7.2 %28x86 和 x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.VSTORuntime.4.0"> <BootstrapperPackage Include="Microsoft.VSTORuntime.4.0">
<Visible>False</Visible> <Visible>False</Visible>
<ProductName>Microsoft Visual Studio 2010 Tools for Office Runtime %28x86 and x64%29</ProductName> <ProductName>Microsoft Visual Studio 2010 Tools for Office Runtime %28x86 x64%29</ProductName>
<Install>true</Install> <Install>true</Install>
</BootstrapperPackage> </BootstrapperPackage>
</ItemGroup> </ItemGroup>
@ -612,6 +635,9 @@
<DependentUpon>Resources.resx</DependentUpon> <DependentUpon>Resources.resx</DependentUpon>
</Compile> </Compile>
<None Include="app.config" /> <None Include="app.config" />
<None Include="focus_creative_games.pfx" />
<None Include="LubanAssistant_1_TemporaryKey.pfx" />
<None Include="LubanAssistant_2_TemporaryKey.pfx" />
<None Include="LubanAssistant_TemporaryKey.pfx" /> <None Include="LubanAssistant_TemporaryKey.pfx" />
<None Include="packages.config" /> <None Include="packages.config" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
@ -667,10 +693,10 @@
<SignManifests>true</SignManifests> <SignManifests>true</SignManifests>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<ManifestKeyFile>LubanAssistant_TemporaryKey.pfx</ManifestKeyFile> <ManifestKeyFile>focus_creative_games.pfx</ManifestKeyFile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<ManifestCertificateThumbprint>DB8575295993B72B55091F842E5704CA3A263CD5</ManifestCertificateThumbprint> <ManifestCertificateThumbprint>90F0DE4632F75E2AABB577005E67BDCB425BF442</ManifestCertificateThumbprint>
</PropertyGroup> </PropertyGroup>
<!-- Include the build rules for a C# project. --> <!-- Include the build rules for a C# project. -->
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
@ -681,8 +707,8 @@
<VisualStudio> <VisualStudio>
<FlavorProperties GUID="{BAA0C2D2-18E2-41B9-852F-F413020CAA33}"> <FlavorProperties GUID="{BAA0C2D2-18E2-41B9-852F-F413020CAA33}">
<ProjectProperties HostName="Excel" HostPackage="{29A7B9D7-A7F1-4328-8EF0-6B2D1A56B2C1}" OfficeVersion="15.0" VstxVersion="4.0" ApplicationType="Excel" Language="cs" TemplatesPath="" DebugInfoExeName="#Software\Microsoft\Office\16.0\Excel\InstallRoot\Path#excel.exe" DebugInfoCommandLine="/x" AddItemTemplatesGuid="{51063C3A-E220-4D12-8922-BDA915ACD783}" /> <ProjectProperties HostName="Excel" HostPackage="{29A7B9D7-A7F1-4328-8EF0-6B2D1A56B2C1}" OfficeVersion="15.0" VstxVersion="4.0" ApplicationType="Excel" Language="cs" TemplatesPath="" DebugInfoExeName="#Software\Microsoft\Office\16.0\Excel\InstallRoot\Path#excel.exe" DebugInfoCommandLine="/x" AddItemTemplatesGuid="{51063C3A-E220-4D12-8922-BDA915ACD783}" />
<Host Name="Excel" GeneratedCodeNamespace="LubanAssistant" IconIndex="0"> <Host Name="Excel" GeneratedCodeNamespace="LubanAssistant" PublishedHash="69C324AB27932AA2FBF2B7EA72250886FF164DE6" IconIndex="0">
<HostItem Name="ThisAddIn" Code="LubanAssistant.cs" CanonicalName="AddIn" CanActivate="false" IconIndex="1" Blueprint="LubanAssistant.Designer.xml" GeneratedCode="LubanAssistant.Designer.cs" /> <HostItem Name="ThisAddIn" Code="LubanAssistant.cs" CanonicalName="AddIn" PublishedHash="9F7A7EDC25C939CCC9BF7AE67132678B9E3EB422" CanActivate="false" IconIndex="1" Blueprint="LubanAssistant.Designer.xml" GeneratedCode="LubanAssistant.Designer.cs" />
</Host> </Host>
</FlavorProperties> </FlavorProperties>
</VisualStudio> </VisualStudio>