Created Volo.Abp.Core package.

pull/179/head
Halil İbrahim Kalkan 8 years ago
parent 7c7f500863
commit 5de19c03f7

@ -0,0 +1,11 @@
using Volo.Abp;
using Volo.Abp.Modularity;
namespace AbpDesk
{
[DependsOn(typeof(AbpCommonModule))]
public class AbpDeskApplicationContractsModule : AbpModule
{
}
}

@ -4,7 +4,11 @@ using Volo.Abp.Modularity;
namespace AbpDesk
{
[DependsOn(typeof(AbpDeskDomainModule), typeof(AbpAutoMapperModule))]
[DependsOn(
typeof(AbpDeskDomainModule),
typeof(AbpDeskApplicationContractsModule),
typeof(AbpAutoMapperModule)
)]
public class AbpDeskApplicationModule : AbpModule
{
public override void ConfigureServices(IServiceCollection services)

@ -1,8 +1,10 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp;
using Volo.Abp.Modularity;
namespace AbpDesk
{
[DependsOn(typeof(AbpCommonModule))]
public class AbpDeskDomainModule : AbpModule
{
public override void ConfigureServices(IServiceCollection services)

@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp;
using Volo.Abp.Modularity;
namespace AbpDesk.SamplePlugInModule
@ -6,6 +7,7 @@ namespace AbpDesk.SamplePlugInModule
/* This is just a sample plugin module to test loading plugin modules.
*/
[DependsOn(typeof(AbpCommonModule))]
public class AbpDeskSamplePlugInModule : AbpModule
{
public override void ConfigureServices(IServiceCollection services)

@ -3,6 +3,7 @@ using Volo.Abp.Modularity;
namespace Volo.Abp.Account
{
[DependsOn(typeof(AbpCommonModule))]
public class AbpAccountApplicationContractsModule : AbpModule
{
public override void ConfigureServices(IServiceCollection services)

@ -10,6 +10,7 @@ using Volo.Abp.Reflection;
namespace Volo.Abp.AutoMapper
{
[DependsOn(typeof(AbpCommonModule))]
public class AbpAutoMapperModule : AbpModule
{
private static volatile bool _createdMappingsBefore;

@ -19,7 +19,6 @@
<ItemGroup>
<ProjectReference Include="..\Volo.Abp.Castle.Core\Volo.Abp.Castle.Core.csproj" />
<ProjectReference Include="..\Volo.Abp\Volo.Abp.csproj" />
</ItemGroup>
</Project>

@ -4,6 +4,7 @@ using Volo.Abp.Modularity;
namespace Volo.Abp.Castle
{
[DependsOn(typeof(AbpCommonModule))]
public class AbpCastleCoreModule : AbpModule
{
public override void ConfigureServices(IServiceCollection services)

@ -124,7 +124,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// Returns a <see cref="Lazy{T}"/> to resolve a service from given <see cref="IServiceCollection"/>
/// once dependency injection registration phase completed.
/// </summary>
internal static Lazy<T> GetServiceLazy<T>(this IServiceCollection services)
public static Lazy<T> GetServiceLazy<T>(this IServiceCollection services)
{
return new Lazy<T>(services.GetService<T>, true);
}
@ -133,7 +133,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// Returns a <see cref="Lazy{T}"/> to resolve a service from given <see cref="IServiceCollection"/>
/// once dependency injection registration phase completed.
/// </summary>
internal static Lazy<object> GetServiceLazy(this IServiceCollection services, Type type)
public static Lazy<object> GetServiceLazy(this IServiceCollection services, Type type)
{
return new Lazy<object>(() => services.GetService(type), true);
}
@ -142,7 +142,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// Returns a <see cref="Lazy{T}"/> to resolve a service from given <see cref="IServiceCollection"/>
/// once dependency injection registration phase completed.
/// </summary>
internal static Lazy<T> GetRequiredServiceLazy<T>(this IServiceCollection services)
public static Lazy<T> GetRequiredServiceLazy<T>(this IServiceCollection services)
{
return new Lazy<T>(services.GetRequiredService<T>, true);
}
@ -151,7 +151,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// Returns a <see cref="Lazy{T}"/> to resolve a service from given <see cref="IServiceCollection"/>
/// once dependency injection registration phase completed.
/// </summary>
internal static Lazy<object> GetRequiredServiceLazy(this IServiceCollection services, Type type)
public static Lazy<object> GetRequiredServiceLazy(this IServiceCollection services, Type type)
{
return new Lazy<object>(() => services.GetRequiredService(type), true);
}

@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Volo.Abp.Logging;
using Volo.Abp.Validation;
namespace Microsoft.Extensions.Logging
{
@ -63,42 +61,37 @@ namespace Microsoft.Extensions.Logging
var logLevel = (ex as IHasLogLevel)?.LogLevel ?? LogLevel.Error;
logger.LogWithLevel(logLevel, ex.Message, ex);
LogValidationErrors(logger, ex);
LogDetails(logger, ex);
}
private static void LogValidationErrors(ILogger logger, Exception exception)
private static void LogDetails(ILogger logger, Exception exception)
{
//Try to find inner validation exception
if (exception is AggregateException && exception.InnerException != null)
{
var aggException = exception as AggregateException;
if (aggException.InnerException is AbpValidationException)
{
exception = aggException.InnerException;
}
}
var loggingExceptions = new List<IExceptionCanLogDetails>();
if (!(exception is AbpValidationException))
if (exception is IExceptionCanLogDetails)
{
return;
loggingExceptions.Add(exception as IExceptionCanLogDetails);
}
var validationException = exception as AbpValidationException;
if (validationException.ValidationErrors.IsNullOrEmpty())
else if (exception is AggregateException && exception.InnerException != null)
{
return;
}
var aggException = exception as AggregateException;
if (aggException.InnerException is IExceptionCanLogDetails)
{
loggingExceptions.Add(aggException.InnerException as IExceptionCanLogDetails);
}
logger.LogWithLevel(validationException.LogLevel, "There are " + validationException.ValidationErrors.Count + " validation errors:");
foreach (var validationResult in validationException.ValidationErrors)
{
var memberNames = "";
if (validationResult.MemberNames != null && validationResult.MemberNames.Any())
foreach (var innerException in aggException.InnerExceptions)
{
memberNames = " (" + string.Join(", ", validationResult.MemberNames) + ")";
if (innerException is IExceptionCanLogDetails)
{
loggingExceptions.AddIfNotContains(innerException as IExceptionCanLogDetails);
}
}
}
logger.LogWithLevel(validationException.LogLevel, validationResult.ErrorMessage + memberNames);
foreach (var ex in loggingExceptions)
{
ex.LogDetails(logger);
}
}
}

@ -1,7 +1,6 @@
using System.Linq.Expressions;
using JetBrains.Annotations;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
namespace System.Linq
{
@ -20,18 +19,6 @@ namespace System.Linq
return query.Skip(skipCount).Take(maxResultCount);
}
/// <summary>
/// Used for paging with an <see cref="IPagedResultRequest"/> object.
/// </summary>
/// <param name="query">Queryable to apply paging</param>
/// <param name="pagedResultRequest">An object implements <see cref="IPagedResultRequest"/> interface</param>
public static IQueryable<T> PageBy<T>([NotNull] this IQueryable<T> query, IPagedResultRequest pagedResultRequest)
{
Check.NotNull(query, nameof(query));
return query.PageBy(pagedResultRequest.SkipCount, pagedResultRequest.MaxResultCount);
}
/// <summary>
/// Filters a <see cref="IQueryable{T}"/> by given predicate if given condition is true.
/// </summary>

@ -37,6 +37,8 @@ namespace Volo.Abp
services.AddSingleton<IAbpApplication>(this);
services.AddSingleton<IModuleContainer>(this);
services.AddCoreServices();
services.AddCoreAbpServices(this);
Modules = LoadModules(services, options);

@ -7,6 +7,13 @@ namespace Volo.Abp.Internal
{
internal static class InternalServiceCollectionExtensions
{
internal static void AddCoreServices(this IServiceCollection services)
{
services.AddOptions();
services.AddLogging();
services.AddLocalization();
}
internal static void AddCoreAbpServices(this IServiceCollection services, IAbpApplication abpApplication)
{
var moduleLoader = new ModuleLoader();
@ -16,6 +23,16 @@ namespace Volo.Abp.Internal
services.TryAddSingleton<IModuleLoader>(moduleLoader);
services.TryAddSingleton<IAssemblyFinder>(assemblyFinder);
services.TryAddSingleton<ITypeFinder>(typeFinder);
services.AddAssemblyOf<IAbpApplication>();
services.Configure<ModuleLifecycleOptions>(options =>
{
options.Contributers.Add<OnPreApplicationInitializationModuleLifecycleContributer>();
options.Contributers.Add<OnApplicationInitializationModuleLifecycleContributer>();
options.Contributers.Add<OnPostApplicationInitializationModuleLifecycleContributer>();
options.Contributers.Add<OnApplicationShutdownModuleLifecycleContributer>();
});
}
}
}

@ -3,7 +3,7 @@ using System.Text;
namespace Volo.Abp.Internal
{
internal static class Utf8Helper
public static class Utf8Helper
{
public static string ReadStringFromStream(Stream stream)
{

@ -0,0 +1,9 @@
using Microsoft.Extensions.Logging;
namespace Volo.Abp.Logging
{
public interface IExceptionCanLogDetails
{
void LogDetails(ILogger logger);
}
}

@ -11,7 +11,6 @@ namespace Volo.Abp.Modularity
{
var moduleTypes = new List<Type>();
AddModuleAndDependenciesResursively(moduleTypes, startupModuleType);
moduleTypes.AddIfNotContains(typeof(AbpKernelModule));
return moduleTypes;
}

@ -73,7 +73,6 @@ namespace Volo.Abp.Modularity
protected virtual List<IAbpModuleDescriptor> SortByDependency(List<IAbpModuleDescriptor> modules, Type startupModuleType)
{
var sortedModules = modules.SortByDependencies(m => m.Dependencies);
sortedModules.MoveItem(m => m.Type == typeof(AbpKernelModule), 0);
sortedModules.MoveItem(m => m.Type == startupModuleType, modules.Count - 1);
return sortedModules;
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save