public T GetTarget <T>() where T : IItemWrapper { if (IsInternal || IsMediaLink) { var wrapper = SpawnProvider.FromItem <T>(LinkField.TargetItem); return((T)((wrapper is T) ? wrapper : null));; } return(default(T)); }
public virtual T GetTarget <T>() where T : IItemWrapper { if (!string.IsNullOrWhiteSpace(_value)) { var item = Sitecore.Context.Database.GetItem(_value); if (item != null) { var wrapper = SpawnProvider.FromItem <T>(item); return((T)((wrapper is T) ? wrapper : null)); } } return(default(T)); }
public T GetTarget <T>() where T : IItemWrapper { if (Field == null || Field.Value.Length == 0) { return(default(T)); } if (MediaItem != null) { var target = SpawnProvider.FromItem <T>(new Item(MediaItem.ID, MediaItem.InnerData, MediaItem.Database)); return((T)((target is T) ? target : null)); } return(default(T)); }
public T GetTarget <T>(ID id) where T : IItemWrapper { if (ID.IsNullOrEmpty(id)) { return(default(T)); } var item = Database.GetItem(id); if (item == null) { return(default(T)); } var wrapper = SpawnProvider.FromItem <T>(item); return((T)((wrapper is T) ? wrapper : null)); }
public IEnumerable <T> GetItems <T>() where T : IItemWrapper { foreach (var id in Value) { var item = Database.GetItem(id.ToString()); if (item != null) { var wrapper = SpawnProvider.FromItem <T>(item); if (wrapper is T) { yield return((T)wrapper); } } } }
public IEnumerable <T> GetItems <T>() where T : IItemWrapper { if (string.IsNullOrWhiteSpace(_value)) { yield break; } var list = (string.IsNullOrWhiteSpace(_value) ? string.Empty : _value).Split('|'); foreach (var id in list) { var item = Database.GetItem(id); if (item != null) { var wrapper = SpawnProvider.FromItem <T>(item); if (wrapper is T) { yield return((T)wrapper); } } } }