mirror of https://github.com/abpframework/abp.git
8 changed files with 61 additions and 45 deletions
@ -1,29 +0,0 @@ |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Volo.Abp.Settings |
|||
{ |
|||
public class DefaultStoreSettingValueProvider : SettingValueProvider |
|||
{ |
|||
public override string EntityType => null; |
|||
|
|||
public DefaultStoreSettingValueProvider(ISettingStore settingStore) |
|||
: base(settingStore) |
|||
{ |
|||
} |
|||
|
|||
public override Task<string> GetOrNullAsync(SettingDefinition setting, string entityId) |
|||
{ |
|||
return SettingStore.GetOrNullAsync(setting.Name, null, null); |
|||
} |
|||
|
|||
public override Task SetAsync(SettingDefinition setting, string value, string entityId) |
|||
{ |
|||
return SettingStore.SetAsync(setting.Name, value, null, null); |
|||
} |
|||
|
|||
public override Task ClearAsync(SettingDefinition setting, string entityId) |
|||
{ |
|||
return SettingStore.DeleteAsync(setting.Name, null, null); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using JetBrains.Annotations; |
|||
|
|||
namespace Volo.Abp.Settings |
|||
{ |
|||
public static class GlobalSettingManagerExtensions |
|||
{ |
|||
public static Task<string> GetOrNullGlobalAsync(this ISettingManager settingManager, [NotNull] string name, bool fallback = true) |
|||
{ |
|||
return settingManager.GetOrNullAsync(name, GlobalSettingValueProvider.DefaultEntityType, null, fallback); |
|||
} |
|||
|
|||
public static Task<List<SettingValue>> GetAllGlobalAsync(this ISettingManager settingManager, bool fallback = true) |
|||
{ |
|||
return settingManager.GetAllAsync(GlobalSettingValueProvider.DefaultEntityType, null, fallback); |
|||
} |
|||
|
|||
public static Task SetGlobalAsync(this ISettingManager settingManager, [NotNull] string name, [CanBeNull] string value) |
|||
{ |
|||
return settingManager.SetAsync(name, value, GlobalSettingValueProvider.DefaultEntityType, null); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Volo.Abp.Settings |
|||
{ |
|||
public class GlobalSettingValueProvider : SettingValueProvider |
|||
{ |
|||
public const string DefaultEntityType = "Global"; |
|||
|
|||
public override string EntityType => DefaultEntityType; |
|||
|
|||
public GlobalSettingValueProvider(ISettingStore settingStore) |
|||
: base(settingStore) |
|||
{ |
|||
} |
|||
|
|||
public override Task<string> GetOrNullAsync(SettingDefinition setting, string entityId) |
|||
{ |
|||
return SettingStore.GetOrNullAsync(setting.Name, EntityType, null); |
|||
} |
|||
|
|||
public override Task SetAsync(SettingDefinition setting, string value, string entityId) |
|||
{ |
|||
return SettingStore.SetAsync(setting.Name, value, EntityType, null); |
|||
} |
|||
|
|||
public override Task ClearAsync(SettingDefinition setting, string entityId) |
|||
{ |
|||
return SettingStore.DeleteAsync(setting.Name, EntityType, null); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue