How to write extension method that work with base class

Idea is to have extension method that extend my functionality.

So instead of having something like this:

 return Add(Add(storage.GetFirst(), 3), 7);

I want have something like this:

return storage.GetFirst().Add(3).Add(7);

Problem with extension methods is that they have to be static in static class. This is simplify example of what I want to do.

 public class Storage
    {
        public int GetFirst()
        {
            return 100;
        }
        public int GetAll(int x, int y)
        {

            // ... 
            return x + y;
        }
    }
    public abstract class MyBase
    {
        protected Storage storage;
        protected MyBase()
        {
            storage = new Storage();
        }

        public int Add(int what, int howMuch)
        {
            return storage.GetAll(what, howMuch);
        }

    }

    public class MyClass : MyBase
    {
        public int method1()
        {
            return Add(Add(storage.GetFirst(), 3), 7);

            //I want have something like this:
            // return storage.GetFirst().Add(3).Add(7);
        }
    }

Off course classes Storage, MyBase and MyClass must not be static. Logic is simplify to have clean and simple example so relation between classes must stay same. What I want to do is to make Add method to be extension method, but leave everything else "more less same".

Is this possible to do and how?


Click here view more answers http://ift.tt/1VpgoWj