Move types to Dashboard.Common.
This commit is contained in:
parent
509bad221f
commit
1b6bf09f95
9
Dashboard.Common/Dashboard.Common.csproj
Normal file
9
Dashboard.Common/Dashboard.Common.csproj
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
38
Dashboard.Common/HashList.cs
Normal file
38
Dashboard.Common/HashList.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Dashboard.Drawing
|
||||||
|
{
|
||||||
|
public class HashList<T> : IReadOnlyList<T>
|
||||||
|
where T : notnull
|
||||||
|
{
|
||||||
|
private readonly List<T> _list = new List<T>();
|
||||||
|
private readonly Dictionary<T, int> _map = new Dictionary<T, int>();
|
||||||
|
|
||||||
|
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<T> GetEnumerator() => _list.GetEnumerator();
|
||||||
|
IEnumerator IEnumerable.GetEnumerator() => _list.GetEnumerator();
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Dashboard\Dashboard.csproj" />
|
<ProjectReference Include="..\Dashboard.Common\Dashboard.Common.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@ -196,39 +195,6 @@ namespace Dashboard.Drawing
|
|||||||
Write(command, bytes);
|
Write(command, bytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class HashList<T> : IReadOnlyList<T>
|
|
||||||
where T : notnull
|
|
||||||
{
|
|
||||||
private readonly List<T> _list = new List<T>();
|
|
||||||
private readonly Dictionary<T, int> _map = new Dictionary<T, int>();
|
|
||||||
|
|
||||||
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<T> GetEnumerator() => _list.GetEnumerator();
|
|
||||||
IEnumerator IEnumerable.GetEnumerator() => _list.GetEnumerator();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IDrawController
|
public interface IDrawController
|
||||||
|
@ -15,6 +15,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dashboard.TestApplication",
|
|||||||
{49A62F46-AC1C-4240-8615-020D4FBBF964} = {49A62F46-AC1C-4240-8615-020D4FBBF964}
|
{49A62F46-AC1C-4240-8615-020D4FBBF964} = {49A62F46-AC1C-4240-8615-020D4FBBF964}
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dashboard.Common", "Dashboard.Common\Dashboard.Common.csproj", "{C77CDD2B-2482-45F9-B330-47A52F5F13C0}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
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}.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.ActiveCfg = Release|Any CPU
|
||||||
{7C90B90B-DF31-439B-9080-CD805383B014}.Release|Any CPU.Build.0 = 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
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
Loading…
Reference in New Issue
Block a user