I was just working on some little data provider classes in a sandbox solution.  Just playing around with design patterns and I need a bit of data, nothing major.  A handful of classes that can act as little databases / data sources for my sandbox.  Just to make list a bit easier making lists of things in code I made this generic wrapper so make my code look nicer …

using System.Collections.Generic;

namespace JamSoft.Mvvm.ToyBox.Core

{

    public class FluentList<T> : List<T>

    {

        public new FluentList<T> Add(T obj)

        {

            base.Add(obj);

            return this;

        }

        public new FluentList<T> AddRange(IEnumerable<T> objs)

        {

            base.AddRange(objs);

            return this;

        }

    }

}

So, once you have this in your solution you can start to do things like this in code:

            var stringList = new FluentList<string>()

                .Add(“Moon”)

                .Add(“Alpha Centauri”)

                .Add(“Sirius”);

Pretty neat things these fluent ideas …

Silverlight, IIS & Attach to Process
Window 7 64 Bit / MOTU Traveler

Leave a Comment

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.