mirror of https://github.com/abpframework/abp.git
19 changed files with 179 additions and 59 deletions
@ -0,0 +1,10 @@ |
|||
namespace Volo.CmsKit |
|||
{ |
|||
public static class FeatureConfigurer |
|||
{ |
|||
public static void Configure() |
|||
{ |
|||
CmsKitFeatures.EnableAll(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,56 @@ |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Volo.CmsKit |
|||
{ |
|||
public static class CmsKitFeatures |
|||
{ |
|||
public const string NamePrefix = "CmsKit"; |
|||
|
|||
public static class Reactions |
|||
{ |
|||
public const string Name = NamePrefix + ".Reactions"; |
|||
|
|||
public static bool IsEnabled |
|||
{ |
|||
get => GlobalFeatures.IsEnabled(Name); |
|||
set => GlobalFeatures.SetEnabled(Name, value); |
|||
} |
|||
} |
|||
|
|||
public static class Comments |
|||
{ |
|||
public const string Name = NamePrefix + ".Comments"; |
|||
|
|||
public static bool IsEnabled |
|||
{ |
|||
get => GlobalFeatures.IsEnabled(Name); |
|||
set => GlobalFeatures.SetEnabled(Name, value); |
|||
} |
|||
} |
|||
|
|||
public static void EnableAll() |
|||
{ |
|||
foreach (var featureName in GetAllNames()) |
|||
{ |
|||
GlobalFeatures.Enable(featureName); |
|||
} |
|||
} |
|||
|
|||
public static void DisableAll() |
|||
{ |
|||
foreach (var featureName in GetAllNames()) |
|||
{ |
|||
GlobalFeatures.Disable(featureName); |
|||
} |
|||
} |
|||
|
|||
public static IEnumerable<string> GetAllNames() |
|||
{ |
|||
return new[] |
|||
{ |
|||
Reactions.Name, |
|||
Comments.Name |
|||
}; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
|
|||
namespace Volo.CmsKit |
|||
{ |
|||
internal static class GlobalFeatures //TODO: Move to the ABP Framework..?
|
|||
{ |
|||
private static readonly HashSet<string> EnabledFeatures = new HashSet<string>(); |
|||
|
|||
public static bool IsEnabled(string featureName) |
|||
{ |
|||
return EnabledFeatures.Contains(featureName); |
|||
} |
|||
|
|||
public static void SetEnabled(string featureName, bool isEnabled) |
|||
{ |
|||
if (isEnabled) |
|||
{ |
|||
Enable(featureName); |
|||
} |
|||
else |
|||
{ |
|||
Disable(featureName); |
|||
} |
|||
} |
|||
|
|||
public static void Enable(string featureName) |
|||
{ |
|||
EnabledFeatures.AddIfNotContains(featureName); |
|||
} |
|||
|
|||
public static void Disable(string featureName) |
|||
{ |
|||
EnabledFeatures.Remove(featureName); |
|||
} |
|||
|
|||
public static IEnumerable<string> GetEnabledFeatures() |
|||
{ |
|||
return EnabledFeatures; |
|||
} |
|||
} |
|||
} |
|||
@ -1,19 +1,10 @@ |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Volo.CmsKit.Comments; |
|||
using Volo.CmsKit.Reactions; |
|||
using Volo.CmsKit.Users; |
|||
|
|||
namespace Volo.CmsKit.EntityFrameworkCore |
|||
{ |
|||
[ConnectionStringName(CmsKitDbProperties.ConnectionStringName)] |
|||
public interface ICmsKitDbContext : IEfCoreDbContext |
|||
{ |
|||
DbSet<UserReaction> UserReactions { get; } |
|||
|
|||
DbSet<Comment> Comments { get; } |
|||
|
|||
DbSet<CmsUser> CmsUsers { get; set; } |
|||
} |
|||
} |
|||
|
|||
Loading…
Reference in new issue