From 1b6bf09f958b277f1e8d5ba18f1ead309a69bbec Mon Sep 17 00:00:00 2001 From: "H. Utku Maden" Date: Sat, 14 Dec 2024 19:57:23 +0300 Subject: [PATCH] Move types to Dashboard.Common. --- {Dashboard => Dashboard.Common}/Box3d.cs | 0 Dashboard.Common/Dashboard.Common.csproj | 9 +++++ Dashboard.Common/HashList.cs | 38 ++++++++++++++++++++++ Dashboard.Drawing/Dashboard.Drawing.csproj | 2 +- Dashboard.Drawing/DrawQueue.cs | 34 ------------------- Dashboard.sln | 6 ++++ 6 files changed, 54 insertions(+), 35 deletions(-) rename {Dashboard => Dashboard.Common}/Box3d.cs (100%) create mode 100644 Dashboard.Common/Dashboard.Common.csproj create mode 100644 Dashboard.Common/HashList.cs diff --git a/Dashboard/Box3d.cs b/Dashboard.Common/Box3d.cs similarity index 100% rename from Dashboard/Box3d.cs rename to Dashboard.Common/Box3d.cs diff --git a/Dashboard.Common/Dashboard.Common.csproj b/Dashboard.Common/Dashboard.Common.csproj new file mode 100644 index 0000000..3a63532 --- /dev/null +++ b/Dashboard.Common/Dashboard.Common.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + + diff --git a/Dashboard.Common/HashList.cs b/Dashboard.Common/HashList.cs new file mode 100644 index 0000000..aae45e6 --- /dev/null +++ b/Dashboard.Common/HashList.cs @@ -0,0 +1,38 @@ +using System.Collections; +using System.Collections.Generic; + +namespace Dashboard.Drawing +{ + public class HashList : IReadOnlyList + where T : notnull + { + private readonly List _list = new List(); + private readonly Dictionary _map = new Dictionary(); + + public T this[int index] => _list[index]; + + public int Count => _list.Count; + + public int Intern(T value) + { + if (_map.TryGetValue(value, out int index)) + return index; + + index = Count; + + _list.Add(value); + _map.Add(value, index); + + return index; + } + + public void Clear() + { + _list.Clear(); + _map.Clear(); + } + + public IEnumerator GetEnumerator() => _list.GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() => _list.GetEnumerator(); + } +} \ No newline at end of file diff --git a/Dashboard.Drawing/Dashboard.Drawing.csproj b/Dashboard.Drawing/Dashboard.Drawing.csproj index 8a0d073..6a4d54a 100644 --- a/Dashboard.Drawing/Dashboard.Drawing.csproj +++ b/Dashboard.Drawing/Dashboard.Drawing.csproj @@ -7,7 +7,7 @@ - + diff --git a/Dashboard.Drawing/DrawQueue.cs b/Dashboard.Drawing/DrawQueue.cs index 6ceb823..120bda5 100644 --- a/Dashboard.Drawing/DrawQueue.cs +++ b/Dashboard.Drawing/DrawQueue.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.Drawing; using System.IO; @@ -196,39 +195,6 @@ namespace Dashboard.Drawing Write(command, bytes); } } - - private class HashList : IReadOnlyList - where T : notnull - { - private readonly List _list = new List(); - private readonly Dictionary _map = new Dictionary(); - - public T this[int index] => _list[index]; - - public int Count => _list.Count; - - public int Intern(T value) - { - if (_map.TryGetValue(value, out int index)) - return index; - - index = Count; - - _list.Add(value); - _map.Add(value, index); - - return index; - } - - public void Clear() - { - _list.Clear(); - _map.Clear(); - } - - public IEnumerator GetEnumerator() => _list.GetEnumerator(); - IEnumerator IEnumerable.GetEnumerator() => _list.GetEnumerator(); - } } public interface IDrawController diff --git a/Dashboard.sln b/Dashboard.sln index 5b6b711..cbcbcb5 100644 --- a/Dashboard.sln +++ b/Dashboard.sln @@ -15,6 +15,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dashboard.TestApplication", {49A62F46-AC1C-4240-8615-020D4FBBF964} = {49A62F46-AC1C-4240-8615-020D4FBBF964} EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dashboard.Common", "Dashboard.Common\Dashboard.Common.csproj", "{C77CDD2B-2482-45F9-B330-47A52F5F13C0}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -33,6 +35,10 @@ Global {7C90B90B-DF31-439B-9080-CD805383B014}.Debug|Any CPU.Build.0 = Debug|Any CPU {7C90B90B-DF31-439B-9080-CD805383B014}.Release|Any CPU.ActiveCfg = Release|Any CPU {7C90B90B-DF31-439B-9080-CD805383B014}.Release|Any CPU.Build.0 = Release|Any CPU + {C77CDD2B-2482-45F9-B330-47A52F5F13C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C77CDD2B-2482-45F9-B330-47A52F5F13C0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C77CDD2B-2482-45F9-B330-47A52F5F13C0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C77CDD2B-2482-45F9-B330-47A52F5F13C0}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE