Skip to content

Commit 63a6932

Browse files
committed
Added to overloads to stop obsolete message being shown on GetItem(path) and GetItem(id). These will eventually be removed when the legacy interface is removed and replaced by the extension methods.
1 parent c9e311d commit 63a6932

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

Source/Glass.Mapper.Sc/ISitecoreServiceLegacy.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ T Create<T, TK>(TK parent, string newName, Language language = null, bool update
502502
/// <returns>
503503
/// The Sitecore item as the specified type
504504
/// </returns>
505-
T GetItem<T>(Guid id);
505+
T GetItem<T>(Guid id) where T : class;
506506

507507
/// <summary>
508508
/// Retrieve a Sitecore item as the specified type.

Source/Glass.Mapper.Sc/SitecoreService.cs

+38
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,26 @@ public void Delete<T>(T item) where T : class
911911

912912
#region GetItem - Path
913913

914+
915+
/// <summary>
916+
/// Gets the item.
917+
/// </summary>
918+
/// <typeparam name="T"></typeparam>
919+
/// <param name="path">The path.</param>
920+
/// <param name="isLazy">if set to <c>true</c> [is lazy].</param>
921+
/// <returns>
922+
/// ``0.
923+
/// </returns>
924+
public T GetItem<T>(string path) where T : class
925+
{
926+
var options = new GetItemByPathOptions
927+
{
928+
Path = path,
929+
ConstructorParameters = (new object[] { }).Select(x => new ConstructorParameter(x.GetType(), x)).ToArray(),
930+
};
931+
return this.GetItem<T>(options);
932+
}
933+
914934
/// <summary>
915935
/// Gets the item.
916936
/// </summary>
@@ -1376,6 +1396,24 @@ public T GetItem<T, TK, TL, TM, TN>(string path, Language language, Sitecore.Dat
13761396

13771397
#region GetItem - Guid
13781398

1399+
/// <summary>
1400+
/// Retrieve a Sitecore item as the specified type.
1401+
/// </summary>
1402+
/// <typeparam name="T">The type to return the Sitecore item as</typeparam>
1403+
/// <param name="id">The ID of the Sitecore item</param>
1404+
/// <returns>
1405+
/// The Sitecore item as the specified type
1406+
/// </returns>
1407+
public T GetItem<T>(Guid id) where T : class
1408+
{
1409+
var options = new GetItemByIdOptions
1410+
{
1411+
Id = id,
1412+
ConstructorParameters = (new object[] { }).Select(x => new ConstructorParameter(x.GetType(), x)).ToArray(),
1413+
};
1414+
return this.GetItem<T>(options);
1415+
}
1416+
13791417
/// <summary>
13801418
/// Retrieve a Sitecore item as the specified type.
13811419
/// </summary>

0 commit comments

Comments
 (0)