Added Fluent.cs to allow string default extention method eg. "Series.Title.WithDefault(series.SeriesId)"

This commit is contained in:
kay.one 2011-06-18 10:19:24 -07:00
commit b00e437e56
5 changed files with 71 additions and 3 deletions

22
NzbDrone.Core/Fluent.cs Normal file
View file

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core
{
public static class Fluent
{
public static string WithDefault(this string actual, object defaultValue)
{
if (defaultValue == null)
throw new ArgumentNullException("defaultValue");
if (String.IsNullOrWhiteSpace(actual))
{
return defaultValue.ToString();
}
return actual;
}
}
}