Skip to content

Commit 24553a4

Browse files
committed
Migrated to file-scoped namespaces
1 parent 21261c4 commit 24553a4

33 files changed

+398
-423
lines changed
Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
using Abp.Application.Services;
22

3-
namespace AbpCompanyName.AbpProjectName
3+
namespace AbpCompanyName.AbpProjectName;
4+
5+
/// <summary>
6+
/// Derive your application services from this class.
7+
/// </summary>
8+
public abstract class AbpProjectNameAppServiceBase : ApplicationService
49
{
5-
/// <summary>
6-
/// Derive your application services from this class.
7-
/// </summary>
8-
public abstract class AbpProjectNameAppServiceBase : ApplicationService
10+
protected AbpProjectNameAppServiceBase()
911
{
10-
protected AbpProjectNameAppServiceBase()
11-
{
12-
LocalizationSourceName = AbpProjectNameConsts.LocalizationSourceName;
13-
}
12+
LocalizationSourceName = AbpProjectNameConsts.LocalizationSourceName;
1413
}
1514
}

src/AbpCompanyName.AbpProjectName.Application/AbpProjectNameApplicationModule.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22
using Abp.Modules;
33
using Abp.Reflection.Extensions;
44

5-
namespace AbpCompanyName.AbpProjectName
5+
namespace AbpCompanyName.AbpProjectName;
6+
7+
[DependsOn(
8+
typeof(AbpProjectNameCoreModule),
9+
typeof(AbpAutoMapperModule))]
10+
public class AbpProjectNameApplicationModule : AbpModule
611
{
7-
[DependsOn(
8-
typeof(AbpProjectNameCoreModule),
9-
typeof(AbpAutoMapperModule))]
10-
public class AbpProjectNameApplicationModule : AbpModule
12+
public override void Initialize()
1113
{
12-
public override void Initialize()
13-
{
14-
IocManager.RegisterAssemblyByConvention(typeof(AbpProjectNameApplicationModule).GetAssembly());
15-
}
14+
IocManager.RegisterAssemblyByConvention(typeof(AbpProjectNameApplicationModule).GetAssembly());
1615
}
1716
}

src/AbpCompanyName.AbpProjectName.Application/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Reflection;
2-
using System.Runtime.CompilerServices;
32
using System.Runtime.InteropServices;
43

54
// General Information about an assembly is controlled through the following
Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
namespace AbpCompanyName.AbpProjectName
1+
namespace AbpCompanyName.AbpProjectName;
2+
3+
public class AbpProjectNameConsts
24
{
3-
public class AbpProjectNameConsts
4-
{
5-
public const string LocalizationSourceName = "AbpProjectName";
5+
public const string LocalizationSourceName = "AbpProjectName";
6+
7+
public const string ConnectionStringName = "Default";
68

7-
public const string ConnectionStringName = "Default";
8-
9-
/// <summary>
10-
/// Default pass phrase for SimpleStringCipher decrypt/encrypt operations
11-
/// </summary>
12-
public const string DefaultPassPhrase = "{{DEFAULT_PASS_PHRASE_HERE}}";
13-
}
9+
/// <summary>
10+
/// Default pass phrase for SimpleStringCipher decrypt/encrypt operations
11+
/// </summary>
12+
public const string DefaultPassPhrase = "{{DEFAULT_PASS_PHRASE_HERE}}";
1413
}

src/AbpCompanyName.AbpProjectName.Core/AbpProjectNameCoreModule.cs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,21 @@
22
using Abp.Reflection.Extensions;
33
using AbpCompanyName.AbpProjectName.Localization;
44

5-
namespace AbpCompanyName.AbpProjectName
5+
namespace AbpCompanyName.AbpProjectName;
6+
7+
public class AbpProjectNameCoreModule : AbpModule
68
{
7-
public class AbpProjectNameCoreModule : AbpModule
9+
public override void PreInitialize()
810
{
9-
public override void PreInitialize()
10-
{
11-
Configuration.Auditing.IsEnabledForAnonymousUsers = true;
11+
Configuration.Auditing.IsEnabledForAnonymousUsers = true;
12+
13+
AbpProjectNameLocalizationConfigurer.Configure(Configuration.Localization);
1214

13-
AbpProjectNameLocalizationConfigurer.Configure(Configuration.Localization);
14-
15-
Configuration.Settings.SettingEncryptionConfiguration.DefaultPassPhrase = AbpProjectNameConsts.DefaultPassPhrase;
16-
}
15+
Configuration.Settings.SettingEncryptionConfiguration.DefaultPassPhrase = AbpProjectNameConsts.DefaultPassPhrase;
16+
}
1717

18-
public override void Initialize()
19-
{
20-
IocManager.RegisterAssemblyByConvention(typeof(AbpProjectNameCoreModule).GetAssembly());
21-
}
18+
public override void Initialize()
19+
{
20+
IocManager.RegisterAssemblyByConvention(typeof(AbpProjectNameCoreModule).GetAssembly());
2221
}
2322
}
Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,40 @@
1-
using System.Collections.Concurrent;
2-
using Abp.Extensions;
1+
using Abp.Extensions;
32
using Microsoft.Extensions.Configuration;
3+
using System.Collections.Concurrent;
44

5-
namespace AbpCompanyName.AbpProjectName.Configuration
5+
namespace AbpCompanyName.AbpProjectName.Configuration;
6+
7+
public static class AppConfigurations
68
{
7-
public static class AppConfigurations
9+
private static readonly ConcurrentDictionary<string, IConfigurationRoot> ConfigurationCache;
10+
11+
static AppConfigurations()
812
{
9-
private static readonly ConcurrentDictionary<string, IConfigurationRoot> ConfigurationCache;
13+
ConfigurationCache = new ConcurrentDictionary<string, IConfigurationRoot>();
14+
}
1015

11-
static AppConfigurations()
12-
{
13-
ConfigurationCache = new ConcurrentDictionary<string, IConfigurationRoot>();
14-
}
16+
public static IConfigurationRoot Get(string path, string environmentName = null)
17+
{
18+
var cacheKey = path + "#" + environmentName;
19+
return ConfigurationCache.GetOrAdd(
20+
cacheKey,
21+
_ => BuildConfiguration(path, environmentName)
22+
);
23+
}
1524

16-
public static IConfigurationRoot Get(string path, string environmentName = null)
17-
{
18-
var cacheKey = path + "#" + environmentName;
19-
return ConfigurationCache.GetOrAdd(
20-
cacheKey,
21-
_ => BuildConfiguration(path, environmentName)
22-
);
23-
}
25+
private static IConfigurationRoot BuildConfiguration(string path, string environmentName = null)
26+
{
27+
var builder = new ConfigurationBuilder()
28+
.SetBasePath(path)
29+
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
2430

25-
private static IConfigurationRoot BuildConfiguration(string path, string environmentName = null)
31+
if (!environmentName.IsNullOrWhiteSpace())
2632
{
27-
var builder = new ConfigurationBuilder()
28-
.SetBasePath(path)
29-
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
30-
31-
if (!environmentName.IsNullOrWhiteSpace())
32-
{
33-
builder = builder.AddJsonFile($"appsettings.{environmentName}.json", optional: true);
34-
}
35-
36-
builder = builder.AddEnvironmentVariables();
37-
38-
return builder.Build();
33+
builder = builder.AddJsonFile($"appsettings.{environmentName}.json", optional: true);
3934
}
35+
36+
builder = builder.AddEnvironmentVariables();
37+
38+
return builder.Build();
4039
}
4140
}
Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
1-
using System.Reflection;
2-
using Abp.Configuration.Startup;
1+
using Abp.Configuration.Startup;
32
using Abp.Localization;
43
using Abp.Localization.Dictionaries;
54
using Abp.Localization.Dictionaries.Json;
65
using Abp.Reflection.Extensions;
76

8-
namespace AbpCompanyName.AbpProjectName.Localization
7+
namespace AbpCompanyName.AbpProjectName.Localization;
8+
9+
public static class AbpProjectNameLocalizationConfigurer
910
{
10-
public static class AbpProjectNameLocalizationConfigurer
11+
public static void Configure(ILocalizationConfiguration localizationConfiguration)
1112
{
12-
public static void Configure(ILocalizationConfiguration localizationConfiguration)
13-
{
14-
localizationConfiguration.Languages.Add(new LanguageInfo("en", "English", "famfamfam-flags england", isDefault: true));
15-
localizationConfiguration.Languages.Add(new LanguageInfo("tr", "Türkçe", "famfamfam-flags tr"));
13+
localizationConfiguration.Languages.Add(new LanguageInfo("en", "English", "famfamfam-flags england", isDefault: true));
14+
localizationConfiguration.Languages.Add(new LanguageInfo("tr", "Türkçe", "famfamfam-flags tr"));
1615

17-
localizationConfiguration.Sources.Add(
18-
new DictionaryBasedLocalizationSource(AbpProjectNameConsts.LocalizationSourceName,
19-
new JsonEmbeddedFileLocalizationDictionaryProvider(
20-
typeof(AbpProjectNameLocalizationConfigurer).GetAssembly(),
21-
"AbpCompanyName.AbpProjectName.Localization.SourceFiles"
22-
)
16+
localizationConfiguration.Sources.Add(
17+
new DictionaryBasedLocalizationSource(AbpProjectNameConsts.LocalizationSourceName,
18+
new JsonEmbeddedFileLocalizationDictionaryProvider(
19+
typeof(AbpProjectNameLocalizationConfigurer).GetAssembly(),
20+
"AbpCompanyName.AbpProjectName.Localization.SourceFiles"
2321
)
24-
);
25-
}
22+
)
23+
);
2624
}
2725
}

src/AbpCompanyName.AbpProjectName.Core/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Reflection;
2-
using System.Runtime.CompilerServices;
32
using System.Runtime.InteropServices;
43

54
// General Information about an assembly is controlled through the following

src/AbpCompanyName.AbpProjectName.Core/Web/WebContentFolderHelper.cs

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,38 @@
22
using System.IO;
33
using System.Linq;
44

5-
namespace AbpCompanyName.AbpProjectName.Web
5+
namespace AbpCompanyName.AbpProjectName.Web;
6+
7+
/// <summary>
8+
/// This class is used to find root path of the web project in;
9+
/// unit tests (to find views) and entity framework core command line commands (to find conn string).
10+
/// </summary>
11+
public static class WebContentDirectoryFinder
612
{
7-
/// <summary>
8-
/// This class is used to find root path of the web project in;
9-
/// unit tests (to find views) and entity framework core command line commands (to find conn string).
10-
/// </summary>
11-
public static class WebContentDirectoryFinder
13+
public static string CalculateContentRootFolder()
1214
{
13-
public static string CalculateContentRootFolder()
15+
var coreAssemblyDirectoryPath = Path.GetDirectoryName(AppContext.BaseDirectory);
16+
if (coreAssemblyDirectoryPath == null)
1417
{
15-
var coreAssemblyDirectoryPath = Path.GetDirectoryName(AppContext.BaseDirectory);
16-
if (coreAssemblyDirectoryPath == null)
17-
{
18-
throw new Exception("Could not find location of AbpCompanyName.AbpProjectName.Core assembly!");
19-
}
18+
throw new Exception("Could not find location of AbpCompanyName.AbpProjectName.Core assembly!");
19+
}
2020

21-
var directoryInfo = new DirectoryInfo(coreAssemblyDirectoryPath);
22-
while (!DirectoryContains(directoryInfo.FullName, "AbpCompanyName.AbpProjectName.sln"))
21+
var directoryInfo = new DirectoryInfo(coreAssemblyDirectoryPath);
22+
while (!DirectoryContains(directoryInfo.FullName, "AbpCompanyName.AbpProjectName.sln"))
23+
{
24+
if (directoryInfo.Parent == null)
2325
{
24-
if (directoryInfo.Parent == null)
25-
{
26-
throw new Exception("Could not find content root folder!");
27-
}
28-
29-
directoryInfo = directoryInfo.Parent;
26+
throw new Exception("Could not find content root folder!");
3027
}
3128

32-
return Path.Combine(directoryInfo.FullName, $"src{Path.DirectorySeparatorChar}AbpCompanyName.AbpProjectName.Web");
29+
directoryInfo = directoryInfo.Parent;
3330
}
3431

35-
private static bool DirectoryContains(string directory, string fileName)
36-
{
37-
return Directory.GetFiles(directory).Any(filePath => string.Equals(Path.GetFileName(filePath), fileName));
38-
}
32+
return Path.Combine(directoryInfo.FullName, $"src{Path.DirectorySeparatorChar}AbpCompanyName.AbpProjectName.Web");
33+
}
34+
35+
private static bool DirectoryContains(string directory, string fileName)
36+
{
37+
return Directory.GetFiles(directory).Any(filePath => string.Equals(Path.GetFileName(filePath), fileName));
3938
}
4039
}
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
using Abp.EntityFrameworkCore;
22
using Microsoft.EntityFrameworkCore;
33

4-
namespace AbpCompanyName.AbpProjectName.EntityFrameworkCore
4+
namespace AbpCompanyName.AbpProjectName.EntityFrameworkCore;
5+
6+
public class AbpProjectNameDbContext : AbpDbContext
57
{
6-
public class AbpProjectNameDbContext : AbpDbContext
7-
{
8-
//Add DbSet properties for your entities...
8+
//Add DbSet properties for your entities...
99

10-
public AbpProjectNameDbContext(DbContextOptions<AbpProjectNameDbContext> options)
11-
: base(options)
12-
{
10+
public AbpProjectNameDbContext(DbContextOptions<AbpProjectNameDbContext> options)
11+
: base(options)
12+
{
1313

14-
}
1514
}
1615
}

0 commit comments

Comments
 (0)