mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 21:43:33 -07:00
Added Fluent.cs to allow string default extention method eg. "Series.Title.WithDefault(series.SeriesId)"
This commit is contained in:
parent
ed4976de90
commit
b00e437e56
5 changed files with 71 additions and 3 deletions
22
NzbDrone.Core/Fluent.cs
Normal file
22
NzbDrone.Core/Fluent.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue