Coder Social home page Coder Social logo

undogeneric's Introduction

A Library to provide Undo functionality, with depth and size limits. All core features implemented, see example in test project. Basic Usage:

List<string> ourList = new List<string>(new string[] { "plastics", "hardware", "housewares", "toys" });
Undo<List<string>> history = new Undo<List<string>>();
history.AddItem(new List<string>(ourList.ToArray()));
ourList.Add("books");
history.AddItem(new List<string>(ourList));
ourList.Add("furniture");
history.AddItem(new List<string>(ourList));
ourList.Add("auto parts");
history.AddItem(new List<string>(ourList));
string currentSize = history.GetSize().ToString();
Console.WriteLine("Current Size: {0}", currentSize);
for (int i = 0; i < 15; i++)
        {
            history.Up();
            current = history.Current.Value;
            Console.WriteLine("Printing Item {0}: Time: {1} Date: {2};", history.Cursor.ToString(), history.Current.Time, history.Current.Date);
            foreach (var item in current)
            {
                Console.Write(item + ",");
            }
            Console.WriteLine();

            Console.WriteLine("Moving Up:");
            Console.WriteLine();



        }
Console.ReadKey(false);

See Example Project for more in depth usage. Bugs/Features please post in issues.

undogeneric's People

Contributors

doveraudio avatar

Watchers

 avatar  avatar

undogeneric's Issues

Implement Property Changed Events

Provide interface for two-way event subscription for automated functionality. Needs a subscription method for acquiring updated history item, and to notify subscribers of updates to the undo list.

Incorrect Date format

Incorrect Date format in Add Item

        public bool AddItem(T item)
            {
                string time = DateTime.UtcNow.TimeOfDay.ToString();
                string date = DateTime.UtcNow.Date.ToString();
                long maxBytes = maxMB * MEGABYTE;
                UndoItem<T> undo = new UndoItem<T>(date, time, item);
                long targetSize = undo.Size + currentSize; ;
                if (checkSize)
                {
                    if (maxBytes < targetSize)
                    {
                        while (maxBytes < targetSize)
                        {
                            RemoveLastItem();
                            targetSize = undo.Size + currentSize;
                        }
                    }
                }

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.