November Happy Hour will be moved to Thursday December 5th.

'UIDescriptorRegistry.Add(UIDescriptor)' is obsolete: 'Inherit UIDescriptorProvider to add new ui descriptors'

Vote:
 

Hi

I have a website on Episerver CMS 9.7.2 with an obsolete method warning that I am trying to fix... however, the class the warning recommends I use is the UIDescriptorProvider which has no 'Add' method.  So I'm not sure how I would go about adding a UIDescriptor to the descriptor registry 

In my site initialize method it exists

UiDescriptorRegistry.Service.Add(new UIDescriptor(typeof(IDefaultAllPropertiesView)) { DefaultView = CmsViewNames.AllPropertiesView });



Episerver documentation says the code isn't thread safe and recommends the UIDescriptorProvider instead to add ui descriptors.

http://world.episerver.com/documentation/Class-library/?documentId=cms/8/C63AC665

Not seeing how that would be done with this class http://world.episerver.com/documentation/Class-library/?documentId=cms/8/FC9EA5EB

Haven't been able to find much help online or on the forums for this yet.

Thanks in advanced.

Ben 

#185811
Dec 01, 2017 20:28
Vote:
 

Hi,

You can just implement your own UIDescriptorProvider, like this

[ServiceConfiguration(typeof(UIDescriptorProvider))]
public class MyContentUIDescriptorProvider : UIDescriptorProvider
{

/// <summary>
/// Returns UI descriptors for all content types with a model type in the content type respository.
/// </summary>
/// <returns>A list of <see cref="UIDescriptor"/> instances</returns>
public override IEnumerable<UIDescriptor> GetDescriptors()
{
  return new [] { 
new UIDescriptor(typeof(IDefaultAllPropertiesView)) { DefaultView = CmsViewNames.AllPropertiesView }

}
}
9.7.2 is a bit old, I'm not sure it's like that, but you get the idea
#185812
Dec 01, 2017 20:50
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.