Skip to content

Instantly share code, notes, and snippets.

@jonfuller
Forked from hammerdr/CollectionMagic.cs
Created August 6, 2010 14:59
Show Gist options
  • Save jonfuller/511437 to your computer and use it in GitHub Desktop.
Save jonfuller/511437 to your computer and use it in GitHub Desktop.
class LineBuilder
{
List<LineItem> _lines;
public LineBuilder WithLine(params string[] names)
{
_lines.AddRange(names.Select(name => new LineItem(name)));
return this;
}
public LineBuilder WithDepLine(object dependency, object target, params string[] names)
{
_lines.AddRange(names.Select(name => new DLineItem(dependency, target, name)));
return this;
}
public IEnumerable<LineItem> Lines { get { return _lines; } }
}
var result = obj.createResult(resultType, new LineBuilder()
.WithLine("A")
.WithLine("B")
.WithDepLine(dependency, target, "C", "D", "E")
.WithLine("F")
.Lines);
return result;
// or this:
var result = obj.createResult(resultType, new LineBuilder()
.WithLine("A", "B")
.WithDepLine(dependency, target, "C", "D", "E")
.WithLine("F")
.Lines);
return result;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment