private void setEmptyTitleFromResources()
        {
            if (string.IsNullOrWhiteSpace(TitleResourceName) || TitleResourceType == null)
            {
                return;
            }

            var property = TitleResourceType.GetTypeInfo().GetDeclaredProperty(TitleResourceName);

            if (property != null)
            {
                var propertyGetter = property.GetMethod;

                // We only support internal and public properties
                if (propertyGetter == null || (!propertyGetter.IsAssembly && !propertyGetter.IsPublic))
                {
                    // Set the property to null so the exception is thrown as if the property wasn't found
                    property = null;
                }
            }

            if (property == null)
            {
                throw new InvalidOperationException($"ResourceType `{TitleResourceType.FullName}` does not have the `{TitleResourceName}` property.");
            }

            if (property.PropertyType != typeof(string))
            {
                throw new InvalidOperationException($"`{TitleResourceType.FullName}.{TitleResourceName}` property is not an string.");
            }

            Title = (string)property.GetValue(null, null);
        }
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var controller = filterContext.Controller;

            if (_viewDataFunction != null)
            {
                controller.ViewData = _viewDataFunction(filterContext.ActionDescriptor);
            }

            //Display the localized title from the resource files.
            if (String.IsNullOrWhiteSpace(Title) && !String.IsNullOrWhiteSpace(TitleResourceName) && TitleResourceType != null)
            {
                PropertyInfo nameProperty = TitleResourceType.GetProperty(TitleResourceName, BindingFlags.Static | BindingFlags.Public);
                Title = (string)nameProperty.GetValue(nameProperty.DeclaringType, null);
            }


#if NET45
            controller.FlushHead(Title, null, FlushAntiForgeryToken, HeaderName);
#else
            controller.FlushHead(Title, null, HeaderName);
#endif
        }