From 1a1c8e71fcd14858f595029f089b2d4a00202b32 Mon Sep 17 00:00:00 2001
From: ogi <Administrator@S-OGI-PC>
Date: Fri, 05 Dec 2025 09:24:16 +0900
Subject: [PATCH] プロジェクトファイルを追加。
---
HotelPms.Client.Blazor/Util/CacheStorage.cs | 99 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 99 insertions(+), 0 deletions(-)
diff --git a/HotelPms.Client.Blazor/Util/CacheStorage.cs b/HotelPms.Client.Blazor/Util/CacheStorage.cs
new file mode 100644
index 0000000..b8d9a23
--- /dev/null
+++ b/HotelPms.Client.Blazor/Util/CacheStorage.cs
@@ -0,0 +1,99 @@
+using System.Collections.Concurrent;
+
+namespace HotelPms.Client.Blazor.Util
+{
+ /// <summary>
+ /// バッファー保存用メモリDB
+ /// </summary>
+ public class CacheStorage : IDisposable
+ {
+ public enum Key : int
+ {
+ /// <summary>
+ /// マスタ設定画面などViewModel伝送用
+ /// </summary>
+ ViewModel = 0,
+ RoomTypeName,
+ RoomName,
+ }
+
+
+ private static CacheStorage m_Instance;
+ public static CacheStorage Instance
+ {
+ get
+ {
+ if (m_Instance == null) { m_Instance = new CacheStorage(); }
+ return m_Instance;
+ }
+ }
+
+ /// <summary>
+ /// バッファー保存用メモリDB
+ /// </summary>
+ public ConcurrentDictionary<string, object> Data { get; set; } = new ConcurrentDictionary<string, object>();
+
+ public void Dispose()
+ {
+ Data.Clear();
+ }
+
+ public object Get(Key key)
+ {
+ return Get(key.ToString());
+ }
+
+ public object Get(string key)
+ {
+ try
+ {
+ Data.TryGetValue(key, out object value);
+ return value;
+ }
+ catch
+ {
+ return null;
+ }
+ }
+
+ public void Set(Key key, object value)
+ {
+ Set(key.ToString(), value);
+ }
+
+ public void Set(string key, object value)
+ {
+ Data[key] = value;
+ }
+
+ /// <summary>
+ /// マスタデータ
+ /// </summary>
+ /// <param name="id"></param>
+ /// <param name="value"></param>
+ public void SetMasterName(Key key, int id, string value)
+ {
+ ConcurrentDictionary<int, string> dict = Get(key) as ConcurrentDictionary<int, string>;
+ if (dict == null)
+ {
+ dict = new ConcurrentDictionary<int, string>();
+ Set(key, dict);
+ }
+ dict[id] = value;
+ }
+
+ /// <summary>
+ /// 存在しなかったら、nullで返す
+ /// </summary>
+ /// <param name="key"></param>
+ /// <param name="id"></param>
+ /// <returns></returns>
+ public string GetMasterName(Key key, int id)
+ {
+ ConcurrentDictionary<int, string> dict = Get(key) as ConcurrentDictionary<int, string>;
+ if (dict == null) { return string.Empty; }
+ if (!dict.ContainsKey(id)) { return string.Empty; }
+ return dict[id];
+ }
+ }
+}
--
Gitblit v1.10.0