Exemple #1
0
 public static VarTypeCfg Instance()
 {
     if (gInstance == null)
     {
         gInstance = new VarTypeCfg();
     }
     return(gInstance);
 }
Exemple #2
0
        public FieldGetterSetter GenVarGetterSetter(string propName)
        {
            FieldGetterSetter objField = null;
            var cfg = VarTypeCfg.Instance().GetCfgByKey(propName);

            if (cfg == null)
            {
                return(objField);
            }
            int nId = cfg.nID;

            if (cfg.nType == (int)EVarType.VarInt)
            {
                objField = new FieldGetterSetter()
                {
                    funcGetter = (string name) =>
                    {
                        if (m_varData.IntData.ContainsKey(nId))
                        {
                            return(m_varData.IntData[nId]);
                        }
                        return(null);
                    },
                    funcSetter = (string name, object newv) =>
                    {
                        m_varData.IntData[nId] = Convert.ToInt64(newv);
                    }
                };
            }
            else if (cfg.nType == (int)EVarType.VarInt)
            {
                objField = new FieldGetterSetter()
                {
                    funcGetter = (string name) =>
                    {
                        if (m_varData.StrData.ContainsKey(nId))
                        {
                            return(m_varData.StrData[nId]);
                        }
                        return(null);
                    },
                    funcSetter = (string name, object newv) =>
                    {
                        m_varData.StrData[nId] = (string)newv;
                    }
                };
            }
            else if (cfg.nType == (int)EVarType.VarMap)
            {
                objField = new FieldGetterSetter()
                {
                    funcGetter = (string name) =>
                    {
                        if (m_varData.MapData.ContainsKey(nId))
                        {
                            return(m_varData.MapData[nId]);
                        }
                        return(null);
                    },
                    funcSetter = (string name, object newv) =>
                    {
                        m_varData.MapData[nId] = (Dictionary <int, long>)newv;
                    }
                };
            }
            return(objField);
        }