Git Product home page Git Product logo

mementocontainer's People

Contributors

dcastro avatar guerillah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

rualmar guerillah

mementocontainer's Issues

State of child collection in class not being preserved when rolled back

Thanks for this library... I like this implementation so far the best of all of the others available for C#.

In 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.

[MementoClass] public class Person { public string Name { get; set; } public List<string> Addresses { get; set; } public DateTime DateOfBirth { get; set; } }

When 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?

`var person = new Person { Addresses = new List { "12180 N Lazy River", "4311 W Summit Ranch" }, DateOfBirth = DateTime.Now, Name = "David D" };
var personList = new List { person };
var memento = Memento.Create().RegisterProperty(person, p=>p.Name).RegisterProperty(person, p=>p.Addresses).RegisterCollection(personList);

        try
        {
            person.Name = "Changed";
            person.Addresses.Clear();
            throw new Exception();
        }
        catch (Exception x)
        {
            memento.Rollback();
        }

        var addressCount = person.Addresses.Count; //Equals 0 when should equal 2 if restored correctly.`

"Mementing" 3rd party classes

Hi, I've recently discovered this memento pattern implementation via a container and it features exactly what I wanted to achieve in my app. The only problem I have is as far as I've seen it needs the class to be adorned with, at least, a MementoClassAttribute, but I'm actually working with 3rd party classes from a closed library, so I can't modify them.

Mocking with the source code I saw I only have to implement my own IPropertyAnalyzer (wich, in this case is almost equals as the standard one, only getting all the properties even without the class adorner). I saw the code is actually structured in a way to allow dependency injection but all the required interfaces are internal to the assembly, so I couldn't come with a way to extend it without modifying the source.

Is there any way to achieve my goal without adorning the class or modifying the source code? If there isn't one, would you accept contributions or forks in that direction?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.