[CP/M filesystem] Move definitions to json.

This commit is contained in:
2022-12-16 19:18:15 +00:00
parent 7a66a8c83a
commit 75981404d8
4 changed files with 21881 additions and 21881 deletions

View File

@@ -35,8 +35,8 @@
<NoWarn>CS1591;CS1574</NoWarn>
</PropertyGroup>
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<InternalsVisibleTo Include="Aaru.Tests"/>
<InternalsVisibleTo Include="Aaru.Tests.Devices"/>
<InternalsVisibleTo Include="Aaru.Tests" />
<InternalsVisibleTo Include="Aaru.Tests.Devices" />
</ItemGroup>
<PropertyGroup>
<NrtRevisionFormat>$(Version)+{chash:8}</NrtRevisionFormat>
@@ -44,40 +44,40 @@
<NrtShowRevision>true</NrtShowRevision>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Claunia.Encoding" Version="1.9.2"/>
<PackageReference Include="System.ValueTuple" Version="4.5.0"/>
<PackageReference Include="Unclassified.NetRevisionTask" Version="0.4.3" PrivateAssets="all"/>
<PackageReference Include="Claunia.Encoding" Version="1.9.2" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="Unclassified.NetRevisionTask" Version="0.4.3" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Aaru.Checksums\Aaru.Checksums.csproj"/>
<ProjectReference Include="..\Aaru.CommonTypes\Aaru.CommonTypes.csproj"/>
<ProjectReference Include="..\Aaru.Helpers\Aaru.Helpers.csproj"/>
<ProjectReference Include="..\Aaru.Partitions\Aaru.Partitions.csproj"/>
<ProjectReference Include="..\Aaru.Images\Aaru.Images.csproj"/>
<ProjectReference Include="..\Aaru.Console\Aaru.Console.csproj"/>
<ProjectReference Include="..\Aaru.Decoders\Aaru.Decoders.csproj"/>
<ProjectReference Include="..\Aaru.Checksums\Aaru.Checksums.csproj" />
<ProjectReference Include="..\Aaru.CommonTypes\Aaru.CommonTypes.csproj" />
<ProjectReference Include="..\Aaru.Helpers\Aaru.Helpers.csproj" />
<ProjectReference Include="..\Aaru.Partitions\Aaru.Partitions.csproj" />
<ProjectReference Include="..\Aaru.Images\Aaru.Images.csproj" />
<ProjectReference Include="..\Aaru.Console\Aaru.Console.csproj" />
<ProjectReference Include="..\Aaru.Decoders\Aaru.Decoders.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="LisaFS\"/>
<Folder Include="UCSDPascal\"/>
<Folder Include="AppleMFS\"/>
<Folder Include="CPM\"/>
<Folder Include="AppleDOS\"/>
<Folder Include="ISO9660\"/>
<Folder Include="ISO9660\Structs\"/>
<Folder Include="ISO9660\Consts\"/>
<Folder Include="LisaFS\" />
<Folder Include="UCSDPascal\" />
<Folder Include="AppleMFS\" />
<Folder Include="CPM\" />
<Folder Include="AppleDOS\" />
<Folder Include="ISO9660\" />
<Folder Include="ISO9660\Structs\" />
<Folder Include="ISO9660\Consts\" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="..\LICENSE.LGPL">
<Link>LICENSE.LGPL</Link>
</EmbeddedResource>
<EmbeddedResource Include="CPM\cpmdefs.xml"/>
<EmbeddedResource Include="CPM\cpmdefs.json" />
<EmbeddedResource Update="Localization\Localization.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Localization.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Aaru.Generators\Aaru.Generators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false"/>
<ProjectReference Include="..\Aaru.Generators\Aaru.Generators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>
</Project>

View File

@@ -35,26 +35,23 @@ using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Reflection;
using System.Xml;
using System.Xml.Serialization;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Aaru.Filesystems;
public sealed partial class CPM
{
/// <summary>Loads all the known CP/M disk definitions from an XML stored as an embedded resource.</summary>
/// <summary>Loads all the known CP/M disk definitions from an JSON stored as an embedded resource.</summary>
/// <returns>The definitions.</returns>
bool LoadDefinitions()
{
try
{
var defsReader =
XmlReader.Create(Assembly.GetExecutingAssembly().
GetManifestResourceStream("Aaru.Filesystems.CPM.cpmdefs.xml") ??
new MemoryStream());
var defsSerializer = new XmlSerializer(typeof(CpmDefinitions));
_definitions = (CpmDefinitions)defsSerializer.Deserialize(defsReader);
_definitions =
JsonSerializer.
Deserialize(Assembly.GetExecutingAssembly().GetManifestResourceStream("Aaru.Filesystems.CPM.cpmdefs.json") ?? new MemoryStream(),
typeof(CpmDefinitions), CpmDefinitionsContext.Default) as CpmDefinitions;
if(_definitions is null)
return false;
@@ -99,6 +96,11 @@ public sealed partial class CPM
}
}
[JsonSourceGenerationOptions(WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
IncludeFields = true)]
[JsonSerializable(typeof(CpmDefinitions))]
public class CpmDefinitionsContext : JsonSerializerContext {}
/// <summary>CP/M disk definitions</summary>
[SuppressMessage("ReSharper", "InconsistentNaming")]
public sealed class CpmDefinitions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff