public T GetUserSetting <T>(ProviderMetadata metadata, Expression <Func <ProviderMetadata, T> > propertyAccessor)
        {
            Guard.NotNull(metadata, nameof(metadata));
            Guard.NotNull(propertyAccessor, nameof(propertyAccessor));

            var settingKey = metadata.SettingKeyPattern.FormatInvariant(metadata.SystemName, propertyAccessor.ExtractPropertyInfo().Name);

            return(_settingService.GetSettingByKey <T>(settingKey));
        }
        public ApplySettingResult ApplyUserSetting <T>(ProviderMetadata metadata, Expression <Func <ProviderMetadata, T> > propertyAccessor)
        {
            Guard.NotNull(metadata, nameof(metadata));
            Guard.NotNull(propertyAccessor, nameof(propertyAccessor));

            var settingKey = metadata.SettingKeyPattern.FormatInvariant(metadata.SystemName, propertyAccessor.ExtractPropertyInfo().Name);
            var value      = propertyAccessor.Compile().Invoke(metadata);

            return(_settingService.ApplySettingAsync(settingKey, value).Await());
        }
        protected virtual void SetUserData(ProviderMetadata metadata)
        {
            if (!metadata.IsEditable)
            {
                return;
            }

            metadata.FriendlyName = GetUserSetting(metadata, x => x.FriendlyName);
            metadata.Description  = GetUserSetting(metadata, x => x.Description);

            var displayOrder = GetUserSetting <int?>(metadata, x => x.DisplayOrder);

            if (displayOrder.HasValue)
            {
                metadata.DisplayOrder = displayOrder.Value;
            }
        }