Custom resource provider considerations

If you use a custom resource provider, which implements the IResourceProvider interface, you must include the following code at the beginning of the GetObject method:

C#
using System.Globalization;
using Telerik.Sitefinity.Services;
using Telerik.Sitefinity.Web;

namespace SitefinityWebApp
{
   public class CustomResourceProviderClass : IResourceProvider
   {
        public object GetObject(string resourceKey, CultureInfo culture)
        {
            if (SystemManager.CurrentHttpContext == null)
                return "Compile time value";
            
            //custom code
            return "some object";
        }

       public string GetResourceContent(string resourceName)
       {
           throw new System.NotImplementedException();
       }

       public bool TryGetResourceContent(string resourceName, out string resourceContent)
       {
           throw new System.NotImplementedException();
       }
   }
}

This is required, because some resources are dynamic and cannot be resolved during compilation

Want to learn more?
Enhance your Sitefinity skills by enrolling in free training sessions. Become Sitefinity certified through Progress Education Community to strengthen your professional credentials.
New to Sitefinity?