November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Hi Fredrik,
What are you using the PermanentLinkMapStore for?
If you're not already, you should be using constructor injection, then it's a case of switching to using IUrlResolver and IPermanentLinkMapper. I don't know exactly what PermanentLinkMapStore method you're using, but I'd expect it to look something like this:
using EPiServer.Web;
using EPiServer.Web.Routing;
public class ExampleClass
{
private IUrlResolver _urlResolver;
private IPermanentLinkMapper _permanentLinkMapper;
public ExampleClass(IUrlResolver urlResolver, IPermanentLinkMapper permanentLinkMapper)
{
_urlResolver = urlResolver;
_permanentLinkMapper = permanentLinkMapper;
}
public void ExampleMethod(IContent content)
{
var url = _urlResolver.GetUrl(content.ContentLink);
var permanentLinkMap = _permanentLinkMapper.Find(content.ContentLink);
}
}
Let me know if you have questions.
So this is the code I'm trying to get my head around regardaring PermanentLinkMapStore,
and the warning I'm getting is: Warning CS0618: 'PermanentLinkMapStore' is obsolete: 'Use IPermanentLinkMapper instead'
public static class LinkItemExtensions
{
public static IEnumerable<IContent> ContentData(this LinkItemCollection linkItemCollection)
{
var pages = new List<IContent>();
if (linkItemCollection == null) return pages;
var urlResolver = ServiceLocator.Current.GetInstance<UrlResolver>();
foreach (var linkItem in linkItemCollection.Where(linkItem => !string.IsNullOrEmpty(linkItem.Href)))
{
string linkUrl;
if (!PermanentLinkMapStore.TryToPermanent(linkItem.Href, out linkUrl)) continue;
var urlBuilder = new UrlBuilder(linkUrl);
var page = urlResolver.Route(urlBuilder) as PageData;
if (page != null) pages.Add(page);
}
return pages;
}
}
Hi again,
Fairly sure you can just dispense with using the PermanentLinkMapStore
or IPermanentLinkMapper
at all in this scenario.
I think the following should work:
public static IEnumerable<IContent> ContentData(this LinkItemCollection linkItemCollection)
{
var pages = new List<IContent>();
if (linkItemCollection == null)
{
return pages;
}
var urlResolver = ServiceLocator.Current.GetInstance<IUrlResolver>();
foreach (var linkItem in linkItemCollection.Where(linkItem => !string.IsNullOrEmpty(linkItem.Href)))
{
var page = urlResolver.Route(new UrlBuilder(linkItem.Href)) as PageData;
if (page != null)
{
pages.Add(page);
}
}
return pages;
}
if (!PermanentLinkMapStore.TryToPermanent(linkItem.Href, out linkUrl)) continue;
you can use UrlResolver.TryToPermanent instead. Same parameters
Sorry for being a bit late and thanks both of you
I ended up like this, see below:
public static class LinkItemExtensions
{
public static IEnumerable<IContent> ContentData(this LinkItemCollection linkItemCollection)
{
var pages = new List<IContent>();
if (linkItemCollection == null) return pages;
var urlResolver = ServiceLocator.Current.GetInstance<IUrlResolver>();
foreach (var linkItem in linkItemCollection.Where(linkItem => !string.IsNullOrEmpty(linkItem.Href)))
{
string linkUrl;
if (!urlResolver.TryToPermanent(linkItem.Href, out linkUrl)) continue;
var page = urlResolver.Route(new UrlBuilder(linkUrl)) as PageData;
if (page != null) pages.Add(page);
}
return pages;
}
}
Hi!
Getting warnings as follow:
IContentExtensions.PublicUrl(IContent)' is obsolete: 'Will remain at least until jan 2017.
and
'PermanentLinkMapStore' is obsolete: 'Use IPermanentLinkMapper instead'
and we cant find any solution to fix these warnings
Thanks in advance
/Fredrik and Mats