cloudflight
2024-08-03 5dde4212e3a73bf1ab0fd9e4d34dfebad0f8ffa2
Hydraulic/Hydro.CommonBase/component/dict.cs
@@ -1,4 +1,5 @@
using System;
#define emptyCreate1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
@@ -56,7 +57,7 @@
            }
        }
        public bool emptyCreate = true;
        public bool emptyCreate = false;
        //List<dict> _list = null;
        public dict() : base()
        {
@@ -155,38 +156,53 @@
        {
            get
            {
                if (!this.ContainsKey(key))
                {
                    lock (this)
                    {
                        if (!this.ContainsKey(key))
                        {
                            if (emptyCreate)
                                this.Add(key, default(TValue));
                            else
                                return default(TValue);
                        }
                    }
                }
#if emptyCreate
                if (!this.ContainsKey(key)) this.Add(key, default(TValue));
                return base[key];
#else
                return base[key];
#endif
                //if (!this.ContainsKey(key))
                //{
                //    if (emptyCreate)
                //    {
                //        this.Add(key, default(TValue));
                //        return base[key];
                //    }
                //    else
                //        return default(TValue);
                //}
                //else
                //    return base[key];
            }
            set
            {
#if emptyCreate
                if (!this.ContainsKey(key)) this.Add(key, default(TValue));
                base[key] = value;
#else
                base[key] = value;
#endif
                return;
                if (!this.ContainsKey(key))
                {
                    lock (this)
                    if (!this.ContainsKey(key))
                    {
                        if (!this.ContainsKey(key))
                        if (emptyCreate)
                        {
                            if (emptyCreate)
                                this.Add(key, value);
                            else
                                return;
                            this.Add(key, value);
                            return;
                        }
                        else
                            return;
                    }
                }
                base[key] = value;
                else
                    base[key] = value;
            }
        }