@ -513,6 +513,11 @@ namespace Emby.Server.Implementations.Library
}
}
public Guid GetNewItemId ( string key , Type type )
public Guid GetNewItemId ( string key , Type type )
{
return GetNewItemIdInternal ( key , type , false ) ;
}
private Guid GetNewItemIdInternal ( string key , Type type , bool forceCaseInsensitive )
{
{
if ( string . IsNullOrWhiteSpace ( key ) )
if ( string . IsNullOrWhiteSpace ( key ) )
{
{
@ -531,7 +536,7 @@ namespace Emby.Server.Implementations.Library
. Replace ( "/" , "\\" ) ;
. Replace ( "/" , "\\" ) ;
}
}
if ( ! ConfigurationManager . Configuration . EnableCaseSensitiveItemIds )
if ( forceCaseInsensitive | | ! ConfigurationManager . Configuration . EnableCaseSensitiveItemIds )
{
{
key = key . ToLower ( ) ;
key = key . ToLower ( ) ;
}
}
@ -865,7 +870,7 @@ namespace Emby.Server.Implementations.Library
/// <returns>Task{Person}.</returns>
/// <returns>Task{Person}.</returns>
public Person GetPerson ( string name )
public Person GetPerson ( string name )
{
{
return CreateItemByName < Person > ( Person . GetPath (name ) , name ) ;
return CreateItemByName < Person > ( Person . GetPath , name ) ;
}
}
/// <summary>
/// <summary>
@ -875,7 +880,7 @@ namespace Emby.Server.Implementations.Library
/// <returns>Task{Studio}.</returns>
/// <returns>Task{Studio}.</returns>
public Studio GetStudio ( string name )
public Studio GetStudio ( string name )
{
{
return CreateItemByName < Studio > ( Studio . GetPath (name ) , name ) ;
return CreateItemByName < Studio > ( Studio . GetPath , name ) ;
}
}
/// <summary>
/// <summary>
@ -885,7 +890,7 @@ namespace Emby.Server.Implementations.Library
/// <returns>Task{Genre}.</returns>
/// <returns>Task{Genre}.</returns>
public Genre GetGenre ( string name )
public Genre GetGenre ( string name )
{
{
return CreateItemByName < Genre > ( Genre . GetPath (name ) , name ) ;
return CreateItemByName < Genre > ( Genre . GetPath , name ) ;
}
}
/// <summary>
/// <summary>
@ -895,7 +900,7 @@ namespace Emby.Server.Implementations.Library
/// <returns>Task{MusicGenre}.</returns>
/// <returns>Task{MusicGenre}.</returns>
public MusicGenre GetMusicGenre ( string name )
public MusicGenre GetMusicGenre ( string name )
{
{
return CreateItemByName < MusicGenre > ( MusicGenre . GetPath (name ) , name ) ;
return CreateItemByName < MusicGenre > ( MusicGenre . GetPath , name ) ;
}
}
/// <summary>
/// <summary>
@ -905,7 +910,7 @@ namespace Emby.Server.Implementations.Library
/// <returns>Task{GameGenre}.</returns>
/// <returns>Task{GameGenre}.</returns>
public GameGenre GetGameGenre ( string name )
public GameGenre GetGameGenre ( string name )
{
{
return CreateItemByName < GameGenre > ( GameGenre . GetPath (name ) , name ) ;
return CreateItemByName < GameGenre > ( GameGenre . GetPath , name ) ;
}
}
/// <summary>
/// <summary>
@ -923,7 +928,7 @@ namespace Emby.Server.Implementations.Library
var name = value . ToString ( CultureInfo . InvariantCulture ) ;
var name = value . ToString ( CultureInfo . InvariantCulture ) ;
return CreateItemByName < Year > ( Year . GetPath (name ) , name ) ;
return CreateItemByName < Year > ( Year . GetPath , name ) ;
}
}
/// <summary>
/// <summary>
@ -933,10 +938,10 @@ namespace Emby.Server.Implementations.Library
/// <returns>Task{Genre}.</returns>
/// <returns>Task{Genre}.</returns>
public MusicArtist GetArtist ( string name )
public MusicArtist GetArtist ( string name )
{
{
return CreateItemByName < MusicArtist > ( MusicArtist . GetPath (name ) , name ) ;
return CreateItemByName < MusicArtist > ( MusicArtist . GetPath , name ) ;
}
}
private T CreateItemByName < T > ( string path , string name )
private T CreateItemByName < T > ( Func < string , string > getPathFn , string name )
where T : BaseItem , new ( )
where T : BaseItem , new ( )
{
{
if ( typeof ( T ) = = typeof ( MusicArtist ) )
if ( typeof ( T ) = = typeof ( MusicArtist ) )
@ -957,7 +962,9 @@ namespace Emby.Server.Implementations.Library
}
}
}
}
var id = GetNewItemId ( path , typeof ( T ) ) ;
var path = getPathFn ( name ) ;
var forceCaseInsensitiveId = ConfigurationManager . Configuration . EnableNormalizedItemByNameIds ;
var id = GetNewItemIdInternal ( path , typeof ( T ) , forceCaseInsensitiveId ) ;
var item = GetItemById ( id ) as T ;
var item = GetItemById ( id ) as T ;