Created
December 6, 2012 20:59
-
-
Save bsommardahl/4228301 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IObjectPropertyChangerActor<out T> | |
{ | |
IObjectPropertyChangerActor<T> With(Action<T> action); | |
IObjectPropertyChangerActor<T> And(Action<T> action); | |
} | |
public class ObjectPropertyChangerActor<T> : IObjectPropertyChangerActor<T> | |
{ | |
readonly T _objectToChange; | |
public ObjectPropertyChangerActor(T objectToChange) | |
{ | |
_objectToChange = objectToChange; | |
} | |
#region IObjectPropertyChangerActor<T> Members | |
public IObjectPropertyChangerActor<T> With(Action<T> action) | |
{ | |
return MakeTheChange(action); | |
} | |
public IObjectPropertyChangerActor<T> And(Action<T> action) | |
{ | |
return MakeTheChange(action); | |
} | |
#endregion | |
IObjectPropertyChangerActor<T> MakeTheChange(Action<T> action) | |
{ | |
action.Invoke(_objectToChange); | |
return this; | |
} | |
} | |
public static class ObjectChangingExtensions | |
{ | |
public static IObjectPropertyChangerActor<T> Change<T>(this T objectToChange) | |
{ | |
return new ObjectPropertyChangerActor<T>(objectToChange); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment