Пример #1
0
        public void LoadDefaultValues()
        {
            Type cfg = typeof(PtfConfig);

            foreach (var p in cfg.GetProperties())
            {
                PtfConfigAttribute configAttribute = p.GetCustomAttributes(typeof(PtfConfigAttribute), false).FirstOrDefault() as PtfConfigAttribute;
                if (configAttribute == null)
                {
                    continue;
                }
                var val = DetectorUtil.GetPropertyValue(configAttribute.Name);
                if (val != null)
                {
                    p.SetValue(this, val, null);
                }
            }
        }
Пример #2
0
        public Dictionary <string, List <string> > ToDictionary()
        {
            Dictionary <string, List <string> > dict = new Dictionary <string, List <string> >();
            Type cfg = typeof(PtfConfig);

            foreach (var p in cfg.GetProperties())
            {
                PtfConfigAttribute configAttribute = p.GetCustomAttributes(typeof(PtfConfigAttribute), false).FirstOrDefault() as PtfConfigAttribute;
                if (configAttribute == null)
                {
                    continue;
                }
                string value = p.GetValue(this, null).ToString();
                dict.Add(configAttribute.Name, new List <string>()
                {
                    value
                });
            }
            return(dict);
        }