From 27f92e6c33cc6b20b74ae19fab8748806a867e44 Mon Sep 17 00:00:00 2001 From: Jan Date: Thu, 21 Nov 2019 21:46:03 +0100 Subject: [PATCH] ZoneCodeGenerator: Add Computations class for StructureInformation including IsUsed to check whether a structure has at least 1 usage --- .../Information/StructureInformation.cs | 2 ++ .../Computations/StructureComputations.cs | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 src/ZoneCodeGenerator/Generating/Computations/StructureComputations.cs diff --git a/src/ZoneCodeGenerator/Domain/Information/StructureInformation.cs b/src/ZoneCodeGenerator/Domain/Information/StructureInformation.cs index 9a65927f..25abce53 100644 --- a/src/ZoneCodeGenerator/Domain/Information/StructureInformation.cs +++ b/src/ZoneCodeGenerator/Domain/Information/StructureInformation.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using ZoneCodeGenerator.Domain.FastFileStructure; +using ZoneCodeGenerator.Generating.Computations; using ZoneCodeGenerator.Persistence; namespace ZoneCodeGenerator.Domain.Information @@ -33,6 +34,7 @@ namespace ZoneCodeGenerator.Domain.Information public bool IsLeaf { get; set; } public List NameChain { get; set; } + public StructureComputations Computations => new StructureComputations(this); public StructureInformation(DataTypeWithMembers type) { diff --git a/src/ZoneCodeGenerator/Generating/Computations/StructureComputations.cs b/src/ZoneCodeGenerator/Generating/Computations/StructureComputations.cs new file mode 100644 index 00000000..687a716a --- /dev/null +++ b/src/ZoneCodeGenerator/Generating/Computations/StructureComputations.cs @@ -0,0 +1,20 @@ +using System.Collections.Generic; +using System.Linq; +using ZoneCodeGenerator.Domain; +using ZoneCodeGenerator.Domain.Evaluation; +using ZoneCodeGenerator.Domain.Information; + +namespace ZoneCodeGenerator.Generating.Computations +{ + class StructureComputations + { + private readonly StructureInformation information; + + public bool IsUsed => information.Usages.Any(); + + public StructureComputations(StructureInformation information) + { + this.information = information; + } + } +} \ No newline at end of file