Skip to content
This repository has been archived by the owner on Dec 13, 2021. It is now read-only.

Commit

Permalink
Removed the legacy Convert___FromInt methods
Browse files Browse the repository at this point in the history
  • Loading branch information
leekelleher committed Feb 13, 2017
1 parent 2aec222 commit 9678d43
Showing 1 changed file with 0 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,78 +169,5 @@ protected DatabaseContext DatabaseContext
var ctx = new DittoCacheContext(this, context.Content, context.TargetType, context.PropertyDescriptor, context.Culture);
return this.GetCacheItem(ctx, this.ProcessValue);
}

/// <summary>
/// Takes a content node ID, gets the corresponding <see cref="T:Umbraco.Core.Models.IPublishedContent"/> object,
/// then converts the object to the desired type.
/// </summary>
/// <param name="id">The content node ID.</param>
/// <param name="targetType">The property <see cref="Type"/> to convert to.</param>
/// <param name="culture">The <see cref="CultureInfo"/> to use as the current culture.</param>
/// <returns>
/// An <see cref="T:System.Object"/> that represents the converted value.
/// </returns>
[Obsolete("This method will be removed from the next version of Ditto. Please use one of the built-in UmbracoContext.ContentCache.", false)]
protected virtual object ConvertContentFromInt(int id, Type targetType, CultureInfo culture)
{
if (id <= 0)
{
return null;
}

return UmbracoContext.ContentCache.GetById(id).As(targetType, culture);
}

/// <summary>
/// Takes a media node ID, gets the corresponding <see cref="T:Umbraco.Core.Models.IPublishedContent"/> object,
/// then converts the object to the desired type.
/// </summary>
/// <param name="id">The media node ID.</param>
/// <param name="targetType">The property <see cref="Type"/> to convert to. </param>
/// <param name="culture"> The <see cref="CultureInfo"/> to use as the current culture.</param>
/// <returns>
/// An <see cref="T:System.Object"/> that represents the converted value.
/// </returns>
[Obsolete("This method will be removed from the next version of Ditto. Please use one of the built-in UmbracoContext.MediaCache.", false)]
protected virtual object ConvertMediaFromInt(int id, Type targetType, CultureInfo culture)
{
if (id <= 0)
{
return null;
}

var media = UmbracoContext.MediaCache.GetById(id);

// Ensure we are actually returning a media file.
if (media.HasProperty(Constants.Conventions.Media.File))
{
return media.As(targetType, culture);
}

// It's most likely a folder, try its children.
// This returns an IEnumerable<T>
return media.Children().As(targetType, culture);
}

/// <summary>
/// Takes a member node ID, gets the corresponding <see cref="T:Umbraco.Core.Models.IPublishedContent"/> object,
/// then converts the object to the desired type.
/// </summary>
/// <param name="id">The media node ID.</param>
/// <param name="targetType">The property <see cref="Type"/> to convert to. </param>
/// <param name="culture"> The <see cref="CultureInfo"/> to use as the current culture.</param>
/// <returns>
/// An <see cref="T:System.Object"/> that represents the converted value.
/// </returns>
[Obsolete("This method will be removed from the next version of Ditto. Please use one of the built-in MembershipHelper.", false)]
protected virtual object ConvertMemberFromInt(int id, Type targetType, CultureInfo culture)
{
if (id <= 0)
{
return null;
}

return Members.GetById(id).As(targetType, culture);
}
}
}

0 comments on commit 9678d43

Please sign in to comment.