示例#1
0
        public void Restore(IChainChompCorruptor corruptor)
        {
            Type t = corruptor.GetType();

            foreach (PropertyInfo prop in t.GetProperties(BindingFlags.Instance | BindingFlags.Public))
            {
                if (Attribute.IsDefined(prop, typeof(SaveableSetting)))
                {
                    object value = data[prop.Name];

                    prop.SetValue(corruptor, Convert.ChangeType(value, prop.PropertyType));
                }
            }
        }
示例#2
0
        public void Store(IChainChompCorruptor corruptor)
        {
            Type t = corruptor.GetType();

            data = new Dictionary <string, dynamic>();

            foreach (PropertyInfo prop in t.GetProperties(BindingFlags.Instance | BindingFlags.Public))
            {
                if (Attribute.IsDefined(prop, typeof(SaveableSetting)))
                {
                    dynamic value = prop.GetValue(corruptor);
                    string  name  = prop.Name;

                    data.Add(name, value);
                }
            }
        }