示例#1
0
        /// <summary>
        /// Update the properties for obj with the values in the dictionary
        /// </summary>
        /// <param name="obj">Target object</param>
        /// <param name="cmd_dict">dictionary holds the new values</param>
        /// <param name="indProxy">caller indicator/strategy</param>
        public static void UpdateProperties(object stg, Dictionary <string, object> cmd_dict, GIndicatorBase indProxy)
        {
            Dictionary <string, ArrayList> dict_new = GConfig.ParseCmdJson(cmd_dict, indProxy);

            try{
                indProxy.Print("==UpdateProperties== " + stg.GetType().FullName);
                foreach (PropertyInfo p in stg.GetType().GetProperties())
                {
                    if (dict_new.Keys.Contains(p.Name))
                    {
                        indProxy.Print(string.Format("SetValue=={0},{1}",
                                                     p.Name, p.PropertyType));    //p.ReflectedType, p.DeclaringType, p.ToString(), GetValue(this, null)
                        p.SetValue(stg, ParseProperties(dict_new, p.Name, p.PropertyType, indProxy));
                    }
                }
            } catch (Exception ex) {
                indProxy.Print("Exception=" + ex.StackTrace);
            }
        }
示例#2
0
        public static void LoadAlerConfig(GIndicatorBase indProxy)
        {
            List <string> names = new List <string>()
            {
                "AlertBarsBack", "SoundFileName", "SoundPlayLoop"
            };
            Dictionary <string, object> dic = GConfig.GetConfigItems(GConfig.MainConfigFile, names);
            object altBarsBack, name = null, loop = null;

            if (dic.TryGetValue("AlertBarsBack", out altBarsBack) &&
                dic.TryGetValue("SoundFileName", out name) &&
                dic.TryGetValue("SoundPlayLoop", out loop))
            {
                SoundLoopFilePath = GConfig.GetSoundFileDir() + name.ToString();
                int.TryParse(altBarsBack.ToString(), out AlertBarsBack);
                int.TryParse(loop.ToString(), out SoundLoopCount);
                indProxy.Print(String.Format("LoadAlerConfig AlertBarsBackStr={0}, GetSoundFilePath={1}, SoundPlayLoopStr={2}",
                                             AlertBarsBack, SoundLoopFilePath, SoundLoopCount));
            }
        }