From 4db7d08bb295be33e80f1353f58fcea4a8da6127 Mon Sep 17 00:00:00 2001
From: cloudflight <cloudflight@126.com>
Date: 星期一, 10 六月 2024 19:11:39 +0800
Subject: [PATCH] 2024年6月10日

---
 Hydraulic/Hydro.CommonBase/component/dict.cs |   32 ++++++++++++++++++++++++++++----
 1 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/Hydraulic/Hydro.CommonBase/component/dict.cs b/Hydraulic/Hydro.CommonBase/component/dict.cs
index c857da9..55d7db7 100644
--- a/Hydraulic/Hydro.CommonBase/component/dict.cs
+++ b/Hydraulic/Hydro.CommonBase/component/dict.cs
@@ -56,7 +56,7 @@
             }
         }
 
-        public bool emptyCreate = false;
+        public bool emptyCreate = true;
         //List<dict> _list = null;
         public dict() : base()
         {
@@ -155,14 +155,38 @@
         {
             get
             {
-                if (!this.ContainsKey(key)) this.Add(key, default(TValue));
+                if (!this.ContainsKey(key))
+                {
+                    lock (this)
+                    {
+                        if (!this.ContainsKey(key))
+                        {
+                            if (emptyCreate)
+                                this.Add(key, default(TValue));
+                            else
+                                return default(TValue);
+                        }
+                    }
+                }                   
                 return base[key];
 
             }
             set
             {
-                if (this.ContainsKey(key)) base[key] = value;
-                else this.Add(key, value);
+                if (!this.ContainsKey(key))
+                {
+                    lock (this)
+                    {
+                        if (!this.ContainsKey(key))
+                        {
+                            if (emptyCreate)
+                                this.Add(key, value);
+                            else
+                                return;
+                        }
+                    }
+                }
+                base[key] = value;
             }
 
         }

--
Gitblit v1.9.3