{"action":"opened","issue":{"url":"https://api.github.com/repos/dcastro/MementoContainer/issues/3","repository_url":"https://api.github.com/repos/dcastro/MementoContainer","labels_url":"https://api.github.com/repos/dcastro/MementoContainer/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/dcastro/MementoContainer/issues/3/comments","events_url":"https://api.github.com/repos/dcastro/MementoContainer/issues/3/events","html_url":"https://github.com/dcastro/MementoContainer/issues/3","id":302100332,"number":3,"title":"State of child collection in class not being preserved when rolled back","user":{"login":"Guerillah","id":16261957,"avatar_url":"https://avatars1.githubusercontent.com/u/16261957?v=4","gravatar_id":"","url":"https://api.github.com/users/Guerillah","html_url":"https://github.com/Guerillah","followers_url":"https://api.github.com/users/Guerillah/followers","following_url":"https://api.github.com/users/Guerillah/following{/other_user}","gists_url":"https://api.github.com/users/Guerillah/gists{/gist_id}","starred_url":"https://api.github.com/users/Guerillah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Guerillah/subscriptions","organizations_url":"https://api.github.com/users/Guerillah/orgs","repos_url":"https://api.github.com/users/Guerillah/repos","events_url":"https://api.github.com/users/Guerillah/events{/privacy}","received_events_url":"https://api.github.com/users/Guerillah/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-04T16:40:37Z","updated_at":"2018-03-04T16:40:37Z","closed_at":null,"author_association":"NONE","body":"Thanks for this library... I like this implementation so far the best of all of the others available for C#.\r\n\r\nIn experimenting with this library I am unsure of how to get the framework to keep the state of a collection inside a class as it is currently not working. I have the following fake Person class.\r\n\r\n` [MementoClass]\r\n    public class Person\r\n    {\r\n        public string Name { get; set; }\r\n        public List<string> Addresses { get; set; }\r\n        public DateTime DateOfBirth { get; set; }\r\n    }`\r\n\r\nWhen I run the following code, it will not restore the addresses that existed before I cleared them. What must I do to make that happen?\r\n\r\n`   var person = new Person { Addresses = new List<string> { \"12180 N Lazy River\", \"4311 W Summit Ranch\" }, DateOfBirth = DateTime.Now, Name = \"David D\" };\r\n            var personList = new List<Person> { person };\r\n            var memento = Memento.Create().RegisterProperty(person, p=>p.Name).RegisterProperty(person, p=>p.Addresses).RegisterCollection(personList);\r\n\r\n            try\r\n            {\r\n                person.Name = \"Changed\";\r\n                person.Addresses.Clear();\r\n                throw new Exception();\r\n            }\r\n            catch (Exception x)\r\n            {\r\n                memento.Rollback();\r\n            }`\r\n\r\n            var addressCount = person.Addresses.Count; //Equals 0 when should equal 2 if restored correctly."}}
{"actor":{"display_login":"Guerillah"}}