mirror of https://github.com/abpframework/abp.git
61 changed files with 1361 additions and 57 deletions
@ -0,0 +1,23 @@ |
|||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.Abp; |
||||
|
using Volo.DependencyInjection; |
||||
|
|
||||
|
namespace Microsoft.AspNetCore.Builder |
||||
|
{ |
||||
|
public static class AbpApplicationBuilderExtensions |
||||
|
{ |
||||
|
public static void InitializeAbpApplication(this IApplicationBuilder app) //TODO: Simply rename to InitializeApplication?
|
||||
|
{ |
||||
|
var abpApplication = app.ApplicationServices.GetRequiredService<IAbpApplication>(); |
||||
|
|
||||
|
app.ApplicationServices.GetRequiredService<ApplicationBuilderAccessor>().App = app; |
||||
|
|
||||
|
abpApplication.Initialize(app.ApplicationServices); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public class ApplicationBuilderAccessor : ISingletonDependency |
||||
|
{ |
||||
|
public IApplicationBuilder App { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.Abp.AspNetCore.Modularity; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.DependencyInjection; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore |
||||
|
{ |
||||
|
public class AbpAspNetCoreModule : IAbpModule |
||||
|
{ |
||||
|
public void ConfigureServices(IServiceCollection services) |
||||
|
{ |
||||
|
services.AddAssemblyOf<AbpAspNetCoreModule>(); |
||||
|
services.AddSingleton<IModuleInitializer, AspNetCoreModuleInitializer>(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,15 @@ |
|||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace Microsoft.Extensions.DependencyInjection |
||||
|
{ |
||||
|
//TODO: Decide to move ABP?
|
||||
|
public static class AbpServiceCollectionExtensions |
||||
|
{ |
||||
|
public static void AddAbpApplication<TStartupModule>(this IServiceCollection services) //TODO: Simply rename to AddApplication?
|
||||
|
where TStartupModule : IAbpModule |
||||
|
{ |
||||
|
AbpApplication.Create<TStartupModule>(services); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,23 @@ |
|||||
|
using Microsoft.AspNetCore.Builder; |
||||
|
using Microsoft.AspNetCore.Hosting; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Builder |
||||
|
{ |
||||
|
public class AspNetConfigurationContext |
||||
|
{ |
||||
|
public IApplicationBuilder App { get; } |
||||
|
|
||||
|
public IHostingEnvironment Environment { get; } |
||||
|
|
||||
|
public ILoggerFactory LoggerFactory { get; } |
||||
|
|
||||
|
public AspNetConfigurationContext(IApplicationBuilder app) |
||||
|
{ |
||||
|
App = app; |
||||
|
Environment = app.ApplicationServices.GetRequiredService<IHostingEnvironment>(); |
||||
|
LoggerFactory = app.ApplicationServices.GetRequiredService<ILoggerFactory>(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
namespace Volo.Abp.AspNetCore.Builder |
||||
|
{ |
||||
|
public interface IConfigureAspNet |
||||
|
{ |
||||
|
void Configure(AspNetConfigurationContext context); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,21 @@ |
|||||
|
using Microsoft.AspNetCore.Builder; |
||||
|
using Volo.Abp.AspNetCore.Builder; |
||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Modularity |
||||
|
{ |
||||
|
public class AspNetCoreModuleInitializer : IModuleInitializer |
||||
|
{ |
||||
|
private readonly AspNetConfigurationContext _configurationContext; |
||||
|
|
||||
|
public AspNetCoreModuleInitializer(ApplicationBuilderAccessor appAccessor) |
||||
|
{ |
||||
|
_configurationContext = new AspNetConfigurationContext(appAccessor.App); |
||||
|
} |
||||
|
|
||||
|
public void Initialize(IAbpModule module) |
||||
|
{ |
||||
|
(module as IConfigureAspNet)?.Configure(_configurationContext); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,19 @@ |
|||||
|
using System.Reflection; |
||||
|
using System.Runtime.CompilerServices; |
||||
|
using System.Runtime.InteropServices; |
||||
|
|
||||
|
// General Information about an assembly is controlled through the following
|
||||
|
// set of attributes. Change these attribute values to modify the information
|
||||
|
// associated with an assembly.
|
||||
|
[assembly: AssemblyConfiguration("")] |
||||
|
[assembly: AssemblyCompany("")] |
||||
|
[assembly: AssemblyProduct("Volo.Abp.AspNetCore")] |
||||
|
[assembly: AssemblyTrademark("")] |
||||
|
|
||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
|
// to COM components. If you need to access a type in this assembly from
|
||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||
|
[assembly: ComVisible(false)] |
||||
|
|
||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
|
[assembly: Guid("02be03ba-3411-448c-ab61-cb36407cc49a")] |
||||
@ -0,0 +1,19 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
|
<PropertyGroup> |
||||
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion> |
||||
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> |
||||
|
</PropertyGroup> |
||||
|
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /> |
||||
|
<PropertyGroup Label="Globals"> |
||||
|
<ProjectGuid>02be03ba-3411-448c-ab61-cb36407cc49a</ProjectGuid> |
||||
|
<RootNamespace>Volo</RootNamespace> |
||||
|
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> |
||||
|
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> |
||||
|
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> |
||||
|
</PropertyGroup> |
||||
|
<PropertyGroup> |
||||
|
<SchemaVersion>2.0</SchemaVersion> |
||||
|
</PropertyGroup> |
||||
|
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" /> |
||||
|
</Project> |
||||
@ -0,0 +1,16 @@ |
|||||
|
{ |
||||
|
"version": "1.0.0-*", |
||||
|
|
||||
|
"dependencies": { |
||||
|
"NETStandard.Library": "1.6.1", |
||||
|
"Volo.Abp": "1.0.0-*", |
||||
|
"Microsoft.AspNetCore.Http.Abstractions": "1.1.0", |
||||
|
"Microsoft.AspNetCore.Hosting.Abstractions": "1.1.0" |
||||
|
}, |
||||
|
|
||||
|
"frameworks": { |
||||
|
"netstandard1.6": { |
||||
|
"imports": "dnxcore50" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,39 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace Volo.Abp |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Base exception type for those are thrown by Abp system for Abp specific exceptions.
|
||||
|
/// </summary>
|
||||
|
public class AbpException : Exception |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Creates a new <see cref="AbpException"/> object.
|
||||
|
/// </summary>
|
||||
|
public AbpException() |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Creates a new <see cref="AbpException"/> object.
|
||||
|
/// </summary>
|
||||
|
/// <param name="message">Exception message</param>
|
||||
|
public AbpException(string message) |
||||
|
: base(message) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Creates a new <see cref="AbpException"/> object.
|
||||
|
/// </summary>
|
||||
|
/// <param name="message">Exception message</param>
|
||||
|
/// <param name="innerException">Inner exception</param>
|
||||
|
public AbpException(string message, Exception innerException) |
||||
|
: base(message, innerException) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,17 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace Volo.Abp |
||||
|
{ |
||||
|
public class AbpKernelModule : IAbpModule |
||||
|
{ |
||||
|
public void ConfigureServices(IServiceCollection services) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,35 @@ |
|||||
|
using System; |
||||
|
using System.Linq; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.DependencyInjection.Extensions; |
||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace Volo.Abp |
||||
|
{ |
||||
|
public static class AbpServiceCollectionExtensions |
||||
|
{ |
||||
|
public static T GetSingletonInstanceOrNull<T>(this IServiceCollection services) |
||||
|
{ |
||||
|
return (T)services |
||||
|
.FirstOrDefault(d => d.ServiceType == typeof(T)) |
||||
|
?.ImplementationInstance; |
||||
|
} |
||||
|
|
||||
|
public static T GetSingletonInstance<T>(this IServiceCollection services) |
||||
|
{ |
||||
|
var service = services.GetSingletonInstanceOrNull<T>(); |
||||
|
if (service == null) |
||||
|
{ |
||||
|
throw new InvalidOperationException("Could not find singleton service: " + typeof(T).AssemblyQualifiedName); |
||||
|
} |
||||
|
|
||||
|
return service; |
||||
|
} |
||||
|
|
||||
|
internal static void AddCoreAbpServices(this IServiceCollection services) |
||||
|
{ |
||||
|
services.TryAddSingleton<IModuleLoader>(new ModuleLoader()); |
||||
|
services.TryAddSingleton<IModuleManager, ModuleManager>(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace Volo.Abp |
||||
|
{ |
||||
|
public interface IAbpApplication : IDisposable |
||||
|
{ |
||||
|
Type StartupModuleType { get; } |
||||
|
|
||||
|
void Initialize(IServiceProvider serviceProvider); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,25 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using JetBrains.Annotations; |
||||
|
|
||||
|
namespace Volo.Abp.Modularity |
||||
|
{ |
||||
|
public class AbpModuleDescriptor |
||||
|
{ |
||||
|
public Type Type { get; } |
||||
|
|
||||
|
public IAbpModule Instance { get; } |
||||
|
|
||||
|
public List<AbpModuleDescriptor> Dependencies { get; } |
||||
|
|
||||
|
public AbpModuleDescriptor([NotNull] Type type, [NotNull] IAbpModule instance) |
||||
|
{ |
||||
|
Check.NotNull(type, nameof(type)); |
||||
|
Check.NotNull(instance, nameof(instance)); |
||||
|
|
||||
|
Type = type; |
||||
|
Instance = instance; |
||||
|
Dependencies = new List<AbpModuleDescriptor>(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,31 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace Volo.Abp.Modularity |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Used to define dependencies of an ABP module to other modules.
|
||||
|
/// It should be used for a class implements <see cref="IAbpModule"/>.
|
||||
|
/// </summary>
|
||||
|
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] |
||||
|
public class DependsOnAttribute : Attribute, IModuleDependencyDescriptor |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Types of depended modules.
|
||||
|
/// </summary>
|
||||
|
public Type[] DependedModuleTypes { get; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Used to define dependencies of an ABP module to other modules.
|
||||
|
/// </summary>
|
||||
|
/// <param name="dependedModuleTypes">Types of depended modules</param>
|
||||
|
public DependsOnAttribute(params Type[] dependedModuleTypes) |
||||
|
{ |
||||
|
DependedModuleTypes = dependedModuleTypes; |
||||
|
} |
||||
|
|
||||
|
public Type[] GetDependedModuleTypes() |
||||
|
{ |
||||
|
return DependedModuleTypes; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace Volo.Abp.Modularity |
||||
|
{ |
||||
|
public interface IModuleDependencyDescriptor |
||||
|
{ |
||||
|
Type[] GetDependedModuleTypes(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
using Volo.DependencyInjection; |
||||
|
|
||||
|
namespace Volo.Abp.Modularity |
||||
|
{ |
||||
|
public interface IModuleInitializer : ISingletonDependency |
||||
|
{ |
||||
|
void Initialize(IAbpModule module); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.DependencyInjection; |
||||
|
|
||||
|
namespace Volo.Abp.Modularity |
||||
|
{ |
||||
|
public interface IModuleLoader : ISingletonDependency |
||||
|
{ |
||||
|
IReadOnlyList<AbpModuleDescriptor> Modules { get; } |
||||
|
|
||||
|
void LoadAll(IServiceCollection services, Type startupModuleType); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
namespace Volo.Abp.Modularity |
||||
|
{ |
||||
|
public interface IModuleManager |
||||
|
{ |
||||
|
void Initialize(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,143 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Collections.Immutable; |
||||
|
using System.Linq; |
||||
|
using System.Reflection; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.Collections.Generic; |
||||
|
|
||||
|
namespace Volo.Abp.Modularity |
||||
|
{ |
||||
|
public class ModuleLoader : IModuleLoader |
||||
|
{ |
||||
|
public IReadOnlyList<AbpModuleDescriptor> Modules => _modules.ToImmutableList(); |
||||
|
private readonly List<AbpModuleDescriptor> _modules; |
||||
|
|
||||
|
public ModuleLoader() |
||||
|
{ |
||||
|
_modules = new List<AbpModuleDescriptor>(); |
||||
|
} |
||||
|
|
||||
|
public virtual void LoadAll(IServiceCollection services, Type startupModuleType) |
||||
|
{ |
||||
|
if (_modules.Any()) |
||||
|
{ |
||||
|
throw new InvalidOperationException($"{nameof(LoadAll)} should be called only once!"); |
||||
|
} |
||||
|
|
||||
|
FillModules(startupModuleType); |
||||
|
SetModuleDependencies(); |
||||
|
ConfigureServices(services); |
||||
|
} |
||||
|
|
||||
|
private void SetModuleDependencies() |
||||
|
{ |
||||
|
foreach (var module in Modules) |
||||
|
{ |
||||
|
SetModuleDependencies(module); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void FillModules(Type startupModuleType) |
||||
|
{ |
||||
|
foreach (var moduleType in FindAllModuleTypes(startupModuleType).Distinct()) |
||||
|
{ |
||||
|
_modules.Add(CreateModuleDescriptor(moduleType)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
protected virtual IEnumerable<Type> FindAllModuleTypes(Type startupModuleType) |
||||
|
{ |
||||
|
var moduleTypes = new List<Type>(); |
||||
|
AddModuleAndDependenciesResursively(moduleTypes, startupModuleType); |
||||
|
moduleTypes.AddIfNotContains(typeof(AbpKernelModule)); |
||||
|
return moduleTypes; |
||||
|
} |
||||
|
|
||||
|
protected virtual AbpModuleDescriptor CreateModuleDescriptor(Type moduleType) |
||||
|
{ |
||||
|
return new AbpModuleDescriptor(moduleType, (IAbpModule)Activator.CreateInstance(moduleType)); |
||||
|
} |
||||
|
|
||||
|
protected virtual void ConfigureServices(IServiceCollection services) |
||||
|
{ |
||||
|
foreach (var module in _modules) |
||||
|
{ |
||||
|
module.Instance.ConfigureServices(services); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
protected virtual void AddModuleAndDependenciesResursively(List<Type> moduleTypes, Type moduleType) |
||||
|
{ |
||||
|
CheckAbpModuleType(moduleType); |
||||
|
|
||||
|
if (moduleTypes.Contains(moduleType)) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
moduleTypes.Add(moduleType); |
||||
|
|
||||
|
foreach (var dependedModuleType in FindDependedModuleTypes(moduleType)) |
||||
|
{ |
||||
|
AddModuleAndDependenciesResursively(moduleTypes, dependedModuleType); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
protected virtual List<Type> FindDependedModuleTypes(Type moduleType) |
||||
|
{ |
||||
|
CheckAbpModuleType(moduleType); |
||||
|
|
||||
|
var dependencies = new List<Type>(); |
||||
|
|
||||
|
var dependencyDescriptors = moduleType |
||||
|
.GetTypeInfo() |
||||
|
.GetCustomAttributes() |
||||
|
.OfType<IModuleDependencyDescriptor>(); |
||||
|
|
||||
|
foreach (var descriptor in dependencyDescriptors) |
||||
|
{ |
||||
|
foreach (var dependedModuleType in descriptor.GetDependedModuleTypes()) |
||||
|
{ |
||||
|
dependencies.AddIfNotContains(dependedModuleType); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return dependencies; |
||||
|
} |
||||
|
|
||||
|
protected virtual void SetModuleDependencies(AbpModuleDescriptor module) |
||||
|
{ |
||||
|
foreach (var dependedModuleType in FindDependedModuleTypes(module.Type)) |
||||
|
{ |
||||
|
var dependedModule = _modules.FirstOrDefault(m => m.Type == dependedModuleType); |
||||
|
if (dependedModule == null) |
||||
|
{ |
||||
|
throw new AbpException("Could not find a depended module " + dependedModuleType.AssemblyQualifiedName + " for " + module.Type.AssemblyQualifiedName); |
||||
|
} |
||||
|
|
||||
|
module.Dependencies.AddIfNotContains(dependedModule); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
protected static void CheckAbpModuleType(Type moduleType) |
||||
|
{ |
||||
|
if (!IsAbpModule(moduleType)) |
||||
|
{ |
||||
|
throw new ArgumentException("Given type is not an ABP module: " + moduleType.AssemblyQualifiedName); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
protected static bool IsAbpModule(Type type) |
||||
|
{ |
||||
|
var typeInfo = type.GetTypeInfo(); |
||||
|
|
||||
|
return |
||||
|
typeInfo.IsClass && |
||||
|
!typeInfo.IsAbstract && |
||||
|
!typeInfo.IsGenericType && |
||||
|
typeof(IAbpModule).GetTypeInfo().IsAssignableFrom(type); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,27 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
|
||||
|
namespace Volo.Abp.Modularity |
||||
|
{ |
||||
|
public class ModuleManager : IModuleManager |
||||
|
{ |
||||
|
private readonly IModuleLoader _moduleLoader; |
||||
|
private readonly IEnumerable<IModuleInitializer> _initializers; |
||||
|
|
||||
|
public ModuleManager(IModuleLoader moduleLoader, IEnumerable<IModuleInitializer> initializers) |
||||
|
{ |
||||
|
_moduleLoader = moduleLoader; |
||||
|
_initializers = initializers; |
||||
|
} |
||||
|
|
||||
|
public void Initialize() |
||||
|
{ |
||||
|
foreach (var initializer in _initializers) |
||||
|
{ |
||||
|
foreach (var module in _moduleLoader.Modules) |
||||
|
{ |
||||
|
initializer.Initialize(module.Instance); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,9 +0,0 @@ |
|||||
namespace Volo.Abp.Modularity |
|
||||
{ |
|
||||
public interface IModuleRunner |
|
||||
{ |
|
||||
void Start(); |
|
||||
|
|
||||
void Stop(); |
|
||||
} |
|
||||
} |
|
||||
@ -1,15 +0,0 @@ |
|||||
namespace Volo.Abp.Modularity |
|
||||
{ |
|
||||
public class ModuleRunner : IModuleRunner |
|
||||
{ |
|
||||
public void Start() |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
|
|
||||
public void Stop() |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,12 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace JetBrains.Annotations |
||||
|
{ |
||||
|
[AttributeUsage( |
||||
|
AttributeTargets.Method | AttributeTargets.Parameter | |
||||
|
AttributeTargets.Property | AttributeTargets.Delegate | |
||||
|
AttributeTargets.Field)] |
||||
|
public sealed class CanBeNullAttribute : Attribute |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,20 @@ |
|||||
|
using System; |
||||
|
using System.Diagnostics; |
||||
|
|
||||
|
namespace JetBrains.Annotations |
||||
|
{ |
||||
|
[DebuggerStepThrough] |
||||
|
public static class Check |
||||
|
{ |
||||
|
[ContractAnnotation("value:null => halt")] |
||||
|
public static T NotNull<T>(T value, [InvokerParameterName] [NotNull] string parameterName) |
||||
|
{ |
||||
|
if (value == null) |
||||
|
{ |
||||
|
throw new ArgumentNullException(parameterName); |
||||
|
} |
||||
|
|
||||
|
return value; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,23 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace JetBrains.Annotations |
||||
|
{ |
||||
|
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] |
||||
|
public sealed class ContractAnnotationAttribute : Attribute |
||||
|
{ |
||||
|
public string Contract { get; private set; } |
||||
|
|
||||
|
public bool ForceFullStates { get; private set; } |
||||
|
|
||||
|
public ContractAnnotationAttribute([NotNull] string contract) |
||||
|
: this(contract, false) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public ContractAnnotationAttribute([NotNull] string contract, bool forceFullStates) |
||||
|
{ |
||||
|
Contract = contract; |
||||
|
ForceFullStates = forceFullStates; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace JetBrains.Annotations |
||||
|
{ |
||||
|
[Flags] |
||||
|
public enum ImplicitUseKindFlags |
||||
|
{ |
||||
|
Default = Access | Assign | InstantiatedWithFixedConstructorSignature, |
||||
|
Access = 1, |
||||
|
Assign = 2, |
||||
|
InstantiatedWithFixedConstructorSignature = 4, |
||||
|
InstantiatedNoFixedConstructorSignature = 8 |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,13 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace JetBrains.Annotations |
||||
|
{ |
||||
|
[Flags] |
||||
|
public enum ImplicitUseTargetFlags |
||||
|
{ |
||||
|
Default = Itself, |
||||
|
Itself = 1, |
||||
|
Members = 2, |
||||
|
WithMembers = Itself | Members |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace JetBrains.Annotations |
||||
|
{ |
||||
|
[AttributeUsage(AttributeTargets.Parameter)] |
||||
|
public sealed class InvokerParameterNameAttribute : Attribute |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace JetBrains.Annotations |
||||
|
{ |
||||
|
[AttributeUsage(AttributeTargets.Parameter)] |
||||
|
internal sealed class NoEnumerationAttribute : Attribute |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace JetBrains.Annotations |
||||
|
{ |
||||
|
[AttributeUsage( |
||||
|
AttributeTargets.Method | AttributeTargets.Parameter | |
||||
|
AttributeTargets.Property | AttributeTargets.Delegate | |
||||
|
AttributeTargets.Field)] |
||||
|
public sealed class NotNullAttribute : Attribute |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace JetBrains.Annotations |
||||
|
{ |
||||
|
[AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Delegate)] |
||||
|
public sealed class StringFormatMethodAttribute : Attribute |
||||
|
{ |
||||
|
public StringFormatMethodAttribute([NotNull] string formatParameterName) |
||||
|
{ |
||||
|
FormatParameterName = formatParameterName; |
||||
|
} |
||||
|
|
||||
|
[NotNull] |
||||
|
public string FormatParameterName { get; private set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,34 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace JetBrains.Annotations |
||||
|
{ |
||||
|
[AttributeUsage(AttributeTargets.All)] |
||||
|
public sealed class UsedImplicitlyAttribute : Attribute |
||||
|
{ |
||||
|
public UsedImplicitlyAttribute() |
||||
|
: this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags) |
||||
|
: this(useKindFlags, ImplicitUseTargetFlags.Default) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public UsedImplicitlyAttribute(ImplicitUseTargetFlags targetFlags) |
||||
|
: this(ImplicitUseKindFlags.Default, targetFlags) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public UsedImplicitlyAttribute( |
||||
|
ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags) |
||||
|
{ |
||||
|
UseKindFlags = useKindFlags; |
||||
|
TargetFlags = targetFlags; |
||||
|
} |
||||
|
|
||||
|
public ImplicitUseKindFlags UseKindFlags { get; private set; } |
||||
|
|
||||
|
public ImplicitUseTargetFlags TargetFlags { get; private set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,19 @@ |
|||||
|
using System.Reflection; |
||||
|
using System.Runtime.CompilerServices; |
||||
|
using System.Runtime.InteropServices; |
||||
|
|
||||
|
// General Information about an assembly is controlled through the following
|
||||
|
// set of attributes. Change these attribute values to modify the information
|
||||
|
// associated with an assembly.
|
||||
|
[assembly: AssemblyConfiguration("")] |
||||
|
[assembly: AssemblyCompany("")] |
||||
|
[assembly: AssemblyProduct("Volo.CodeAnnotations")] |
||||
|
[assembly: AssemblyTrademark("")] |
||||
|
|
||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
|
// to COM components. If you need to access a type in this assembly from
|
||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||
|
[assembly: ComVisible(false)] |
||||
|
|
||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
|
[assembly: Guid("161a6c10-00ff-4348-993f-d19893abc57c")] |
||||
@ -0,0 +1,19 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
|
<PropertyGroup> |
||||
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion> |
||||
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> |
||||
|
</PropertyGroup> |
||||
|
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /> |
||||
|
<PropertyGroup Label="Globals"> |
||||
|
<ProjectGuid>161a6c10-00ff-4348-993f-d19893abc57c</ProjectGuid> |
||||
|
<RootNamespace>Volo</RootNamespace> |
||||
|
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> |
||||
|
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> |
||||
|
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> |
||||
|
</PropertyGroup> |
||||
|
<PropertyGroup> |
||||
|
<SchemaVersion>2.0</SchemaVersion> |
||||
|
</PropertyGroup> |
||||
|
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" /> |
||||
|
</Project> |
||||
@ -0,0 +1,13 @@ |
|||||
|
{ |
||||
|
"version": "1.0.0-*", |
||||
|
|
||||
|
"dependencies": { |
||||
|
"NETStandard.Library": "1.6.1" |
||||
|
}, |
||||
|
|
||||
|
"frameworks": { |
||||
|
"netstandard1.6": { |
||||
|
"imports": "dnxcore50" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,40 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using JetBrains.Annotations; |
||||
|
|
||||
|
namespace Volo.Collections.Generic |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Extension methods for Collections.
|
||||
|
/// </summary>
|
||||
|
public static class CollectionExtensions |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Checks whatever given collection object is null or has no item.
|
||||
|
/// </summary>
|
||||
|
public static bool IsNullOrEmpty<T>([CanBeNull] this ICollection<T> source) |
||||
|
{ |
||||
|
return source == null || source.Count <= 0; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Adds an item to the collection if it's not already in the collection.
|
||||
|
/// </summary>
|
||||
|
/// <param name="source">Collection</param>
|
||||
|
/// <param name="item">Item to check and add</param>
|
||||
|
/// <typeparam name="T">Type of the items in the collection</typeparam>
|
||||
|
/// <returns>Returns True if added, returns False if not.</returns>
|
||||
|
public static bool AddIfNotContains<T>([NotNull] this ICollection<T> source, T item) |
||||
|
{ |
||||
|
Check.NotNull(source, nameof(source)); |
||||
|
|
||||
|
if (source.Contains(item)) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
source.Add(item); |
||||
|
return true; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,80 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
|
||||
|
namespace Volo.Collections.Generic |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Extension methods for Dictionary.
|
||||
|
/// </summary>
|
||||
|
public static class DictionaryExtensions |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// This method is used to try to get a value in a dictionary if it does exists.
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="T">Type of the value</typeparam>
|
||||
|
/// <param name="dictionary">The collection object</param>
|
||||
|
/// <param name="key">Key</param>
|
||||
|
/// <param name="value">Value of the key (or default value if key not exists)</param>
|
||||
|
/// <returns>True if key does exists in the dictionary</returns>
|
||||
|
internal static bool TryGetValue<T>(this IDictionary<string, object> dictionary, string key, out T value) |
||||
|
{ |
||||
|
object valueObj; |
||||
|
if (dictionary.TryGetValue(key, out valueObj) && valueObj is T) |
||||
|
{ |
||||
|
value = (T)valueObj; |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
value = default(T); |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets a value from the dictionary with given key. Returns default value if can not find.
|
||||
|
/// </summary>
|
||||
|
/// <param name="dictionary">Dictionary to check and get</param>
|
||||
|
/// <param name="key">Key to find the value</param>
|
||||
|
/// <typeparam name="TKey">Type of the key</typeparam>
|
||||
|
/// <typeparam name="TValue">Type of the value</typeparam>
|
||||
|
/// <returns>Value if found, default if can not found.</returns>
|
||||
|
public static TValue GetOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key) |
||||
|
{ |
||||
|
TValue obj; |
||||
|
return dictionary.TryGetValue(key, out obj) ? obj : default(TValue); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets a value from the dictionary with given key. Returns default value if can not find.
|
||||
|
/// </summary>
|
||||
|
/// <param name="dictionary">Dictionary to check and get</param>
|
||||
|
/// <param name="key">Key to find the value</param>
|
||||
|
/// <param name="factory">A factory method used to create the value if not found in the dictionary</param>
|
||||
|
/// <typeparam name="TKey">Type of the key</typeparam>
|
||||
|
/// <typeparam name="TValue">Type of the value</typeparam>
|
||||
|
/// <returns>Value if found, default if can not found.</returns>
|
||||
|
public static TValue GetOrAdd<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, Func<TKey, TValue> factory) |
||||
|
{ |
||||
|
TValue obj; |
||||
|
if (dictionary.TryGetValue(key, out obj)) |
||||
|
{ |
||||
|
return obj; |
||||
|
} |
||||
|
|
||||
|
return dictionary[key] = factory(key); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets a value from the dictionary with given key. Returns default value if can not find.
|
||||
|
/// </summary>
|
||||
|
/// <param name="dictionary">Dictionary to check and get</param>
|
||||
|
/// <param name="key">Key to find the value</param>
|
||||
|
/// <param name="factory">A factory method used to create the value if not found in the dictionary</param>
|
||||
|
/// <typeparam name="TKey">Type of the key</typeparam>
|
||||
|
/// <typeparam name="TValue">Type of the value</typeparam>
|
||||
|
/// <returns>Value if found, default if can not found.</returns>
|
||||
|
public static TValue GetOrAdd<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, Func<TValue> factory) |
||||
|
{ |
||||
|
return dictionary.GetOrAdd(key, k => factory()); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,65 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
|
||||
|
namespace Volo.Collections.Generic |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Extension methods for <see cref="IEnumerable{T}"/>.
|
||||
|
/// </summary>
|
||||
|
public static class EnumerableExtensions |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Concatenates the members of a constructed <see cref="IEnumerable{T}"/> collection of type System.String, using the specified separator between each member.
|
||||
|
/// This is a shortcut for string.Join(...)
|
||||
|
/// </summary>
|
||||
|
/// <param name="source">A collection that contains the strings to concatenate.</param>
|
||||
|
/// <param name="separator">The string to use as a separator. separator is included in the returned string only if values has more than one element.</param>
|
||||
|
/// <returns>A string that consists of the members of values delimited by the separator string. If values has no members, the method returns System.String.Empty.</returns>
|
||||
|
public static string JoinAsString(this IEnumerable<string> source, string separator) |
||||
|
{ |
||||
|
return string.Join(separator, source); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Concatenates the members of a collection, using the specified separator between each member.
|
||||
|
/// This is a shortcut for string.Join(...)
|
||||
|
/// </summary>
|
||||
|
/// <param name="source">A collection that contains the objects to concatenate.</param>
|
||||
|
/// <param name="separator">The string to use as a separator. separator is included in the returned string only if values has more than one element.</param>
|
||||
|
/// <typeparam name="T">The type of the members of values.</typeparam>
|
||||
|
/// <returns>A string that consists of the members of values delimited by the separator string. If values has no members, the method returns System.String.Empty.</returns>
|
||||
|
public static string JoinAsString<T>(this IEnumerable<T> source, string separator) |
||||
|
{ |
||||
|
return string.Join(separator, source); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Filters a <see cref="IEnumerable{T}"/> by given predicate if given condition is true.
|
||||
|
/// </summary>
|
||||
|
/// <param name="source">Enumerable to apply filtering</param>
|
||||
|
/// <param name="condition">A boolean value</param>
|
||||
|
/// <param name="predicate">Predicate to filter the enumerable</param>
|
||||
|
/// <returns>Filtered or not filtered enumerable based on <paramref name="condition"/></returns>
|
||||
|
public static IEnumerable<T> WhereIf<T>(this IEnumerable<T> source, bool condition, Func<T, bool> predicate) |
||||
|
{ |
||||
|
return condition |
||||
|
? source.Where(predicate) |
||||
|
: source; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Filters a <see cref="IEnumerable{T}"/> by given predicate if given condition is true.
|
||||
|
/// </summary>
|
||||
|
/// <param name="source">Enumerable to apply filtering</param>
|
||||
|
/// <param name="condition">A boolean value</param>
|
||||
|
/// <param name="predicate">Predicate to filter the enumerable</param>
|
||||
|
/// <returns>Filtered or not filtered enumerable based on <paramref name="condition"/></returns>
|
||||
|
public static IEnumerable<T> WhereIf<T>(this IEnumerable<T> source, bool condition, Func<T, int, bool> predicate) |
||||
|
{ |
||||
|
return condition |
||||
|
? source.Where(predicate) |
||||
|
: source; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,73 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
|
||||
|
namespace Volo.Collections.Generic |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Extension methods for <see cref="IList{T}"/>.
|
||||
|
/// </summary>
|
||||
|
public static class ListExtensions |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Sort a list by a topological sorting, which consider their dependencies
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="T">The type of the members of values.</typeparam>
|
||||
|
/// <param name="source">A list of objects to sort</param>
|
||||
|
/// <param name="getDependencies">Function to resolve the dependencies</param>
|
||||
|
/// <returns></returns>
|
||||
|
public static List<T> SortByDependencies<T>(this IEnumerable<T> source, Func<T, IEnumerable<T>> getDependencies) |
||||
|
{ |
||||
|
/* See: http://www.codeproject.com/Articles/869059/Topological-sorting-in-Csharp
|
||||
|
* http://en.wikipedia.org/wiki/Topological_sorting
|
||||
|
*/ |
||||
|
|
||||
|
var sorted = new List<T>(); |
||||
|
var visited = new Dictionary<T, bool>(); |
||||
|
|
||||
|
foreach (var item in source) |
||||
|
{ |
||||
|
SortByDependenciesVisit(item, getDependencies, sorted, visited); |
||||
|
} |
||||
|
|
||||
|
return sorted; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="T">The type of the members of values.</typeparam>
|
||||
|
/// <param name="item">Item to resolve</param>
|
||||
|
/// <param name="getDependencies">Function to resolve the dependencies</param>
|
||||
|
/// <param name="sorted">List with the sortet items</param>
|
||||
|
/// <param name="visited">Dictionary with the visited items</param>
|
||||
|
private static void SortByDependenciesVisit<T>(T item, Func<T, IEnumerable<T>> getDependencies, List<T> sorted, Dictionary<T, bool> visited) |
||||
|
{ |
||||
|
bool inProcess; |
||||
|
var alreadyVisited = visited.TryGetValue(item, out inProcess); |
||||
|
|
||||
|
if (alreadyVisited) |
||||
|
{ |
||||
|
if (inProcess) |
||||
|
{ |
||||
|
throw new ArgumentException("Cyclic dependency found! Item: " + item); |
||||
|
} |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
visited[item] = true; |
||||
|
|
||||
|
var dependencies = getDependencies(item); |
||||
|
if (dependencies != null) |
||||
|
{ |
||||
|
foreach (var dependency in dependencies) |
||||
|
{ |
||||
|
SortByDependenciesVisit(dependency, getDependencies, sorted, visited); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
visited[item] = false; |
||||
|
sorted.Add(item); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,19 @@ |
|||||
|
using System.Reflection; |
||||
|
using System.Runtime.CompilerServices; |
||||
|
using System.Runtime.InteropServices; |
||||
|
|
||||
|
// General Information about an assembly is controlled through the following
|
||||
|
// set of attributes. Change these attribute values to modify the information
|
||||
|
// associated with an assembly.
|
||||
|
[assembly: AssemblyConfiguration("")] |
||||
|
[assembly: AssemblyCompany("")] |
||||
|
[assembly: AssemblyProduct("Volo.ExtensionMethods")] |
||||
|
[assembly: AssemblyTrademark("")] |
||||
|
|
||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
|
// to COM components. If you need to access a type in this assembly from
|
||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||
|
[assembly: ComVisible(false)] |
||||
|
|
||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
|
[assembly: Guid("fc889503-0bf4-4959-ac80-f51073787025")] |
||||
@ -0,0 +1,19 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
|
<PropertyGroup> |
||||
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion> |
||||
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> |
||||
|
</PropertyGroup> |
||||
|
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /> |
||||
|
<PropertyGroup Label="Globals"> |
||||
|
<ProjectGuid>fc889503-0bf4-4959-ac80-f51073787025</ProjectGuid> |
||||
|
<RootNamespace>Volo</RootNamespace> |
||||
|
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> |
||||
|
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> |
||||
|
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> |
||||
|
</PropertyGroup> |
||||
|
<PropertyGroup> |
||||
|
<SchemaVersion>2.0</SchemaVersion> |
||||
|
</PropertyGroup> |
||||
|
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" /> |
||||
|
</Project> |
||||
@ -0,0 +1,14 @@ |
|||||
|
{ |
||||
|
"version": "1.0.0-*", |
||||
|
|
||||
|
"dependencies": { |
||||
|
"NETStandard.Library": "1.6.1", |
||||
|
"Volo.CodeAnnotations": "1.0.0-*" |
||||
|
}, |
||||
|
|
||||
|
"frameworks": { |
||||
|
"netstandard1.6": { |
||||
|
"imports": "dnxcore50" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,35 @@ |
|||||
|
using Microsoft.AspNetCore.Builder; |
||||
|
using Microsoft.AspNetCore.Hosting; |
||||
|
using Microsoft.AspNetCore.Http; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
using Volo.Abp.AspNetCore; |
||||
|
using Volo.Abp.AspNetCore.Builder; |
||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace AspNetCoreDemo |
||||
|
{ |
||||
|
[DependsOn(typeof(AbpAspNetCoreModule))] |
||||
|
public class AppModule : IAbpModule, IConfigureAspNet |
||||
|
{ |
||||
|
public void ConfigureServices(IServiceCollection services) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public void Configure(AspNetConfigurationContext context) |
||||
|
{ |
||||
|
context.LoggerFactory.AddConsole(); |
||||
|
|
||||
|
if (context.Environment.IsDevelopment()) |
||||
|
{ |
||||
|
context.App.UseDeveloperExceptionPage(); |
||||
|
} |
||||
|
|
||||
|
context.App.Run(async (ctx) => |
||||
|
{ |
||||
|
await ctx.Response.WriteAsync("Hello World 3!"); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,25 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
|
<PropertyGroup> |
||||
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion> |
||||
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /> |
||||
|
<PropertyGroup Label="Globals"> |
||||
|
<ProjectGuid>12e14d95-4aba-4290-ab1d-ccf5eb158411</ProjectGuid> |
||||
|
<RootNamespace>AspNetCoreDemo</RootNamespace> |
||||
|
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> |
||||
|
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> |
||||
|
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<SchemaVersion>2.0</SchemaVersion> |
||||
|
</PropertyGroup> |
||||
|
<ItemGroup> |
||||
|
<DnxInvisibleContent Include="bower.json" /> |
||||
|
<DnxInvisibleContent Include=".bowerrc" /> |
||||
|
</ItemGroup> |
||||
|
<Import Project="$(VSToolsPath)\DotNet.Web\Microsoft.DotNet.Web.targets" Condition="'$(VSToolsPath)' != ''" /> |
||||
|
</Project> |
||||
@ -0,0 +1,20 @@ |
|||||
|
using System.IO; |
||||
|
using Microsoft.AspNetCore.Hosting; |
||||
|
|
||||
|
namespace AspNetCoreDemo |
||||
|
{ |
||||
|
public class Program |
||||
|
{ |
||||
|
public static void Main(string[] args) |
||||
|
{ |
||||
|
var host = new WebHostBuilder() |
||||
|
.UseKestrel() |
||||
|
.UseContentRoot(Directory.GetCurrentDirectory()) |
||||
|
.UseIISIntegration() |
||||
|
.UseStartup<Startup>() |
||||
|
.Build(); |
||||
|
|
||||
|
host.Run(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,27 @@ |
|||||
|
{ |
||||
|
"iisSettings": { |
||||
|
"windowsAuthentication": false, |
||||
|
"anonymousAuthentication": true, |
||||
|
"iisExpress": { |
||||
|
"applicationUrl": "http://localhost:59980/", |
||||
|
"sslPort": 0 |
||||
|
} |
||||
|
}, |
||||
|
"profiles": { |
||||
|
"IIS Express": { |
||||
|
"commandName": "IISExpress", |
||||
|
"launchBrowser": true, |
||||
|
"environmentVariables": { |
||||
|
"ASPNETCORE_ENVIRONMENT": "Development" |
||||
|
} |
||||
|
}, |
||||
|
"AspNetCoreDemo": { |
||||
|
"commandName": "Project", |
||||
|
"launchBrowser": true, |
||||
|
"launchUrl": "http://localhost:5000", |
||||
|
"environmentVariables": { |
||||
|
"ASPNETCORE_ENVIRONMENT": "Development" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,21 @@ |
|||||
|
using Microsoft.AspNetCore.Builder; |
||||
|
using Microsoft.AspNetCore.Hosting; |
||||
|
using Microsoft.AspNetCore.Http; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
|
||||
|
namespace AspNetCoreDemo |
||||
|
{ |
||||
|
public class Startup |
||||
|
{ |
||||
|
public void ConfigureServices(IServiceCollection services) |
||||
|
{ |
||||
|
services.AddAbpApplication<AppModule>(); |
||||
|
} |
||||
|
|
||||
|
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) |
||||
|
{ |
||||
|
app.InitializeAbpApplication(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,48 @@ |
|||||
|
{ |
||||
|
"dependencies": { |
||||
|
"Microsoft.NETCore.App": { |
||||
|
"version": "1.0.1", |
||||
|
"type": "platform" |
||||
|
}, |
||||
|
"Microsoft.AspNetCore.Diagnostics": "1.1.0", |
||||
|
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0", |
||||
|
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0", |
||||
|
"Microsoft.Extensions.Logging.Console": "1.1.0", |
||||
|
"Volo.Abp.AspNetCore": "1.0.0-*" |
||||
|
}, |
||||
|
|
||||
|
"tools": { |
||||
|
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final" |
||||
|
}, |
||||
|
|
||||
|
"frameworks": { |
||||
|
"netcoreapp1.0": { |
||||
|
"imports": [ |
||||
|
"dotnet5.6", |
||||
|
"portable-net45+win8" |
||||
|
] |
||||
|
} |
||||
|
}, |
||||
|
|
||||
|
"buildOptions": { |
||||
|
"emitEntryPoint": true, |
||||
|
"preserveCompilationContext": true |
||||
|
}, |
||||
|
|
||||
|
"runtimeOptions": { |
||||
|
"configProperties": { |
||||
|
"System.GC.Server": true |
||||
|
} |
||||
|
}, |
||||
|
|
||||
|
"publishOptions": { |
||||
|
"include": [ |
||||
|
"wwwroot", |
||||
|
"web.config" |
||||
|
] |
||||
|
}, |
||||
|
|
||||
|
"scripts": { |
||||
|
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<configuration> |
||||
|
|
||||
|
<!-- |
||||
|
Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380 |
||||
|
--> |
||||
|
|
||||
|
<system.webServer> |
||||
|
<handlers> |
||||
|
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/> |
||||
|
</handlers> |
||||
|
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/> |
||||
|
</system.webServer> |
||||
|
</configuration> |
||||
@ -0,0 +1,19 @@ |
|||||
|
using System.Reflection; |
||||
|
using System.Runtime.CompilerServices; |
||||
|
using System.Runtime.InteropServices; |
||||
|
|
||||
|
// General Information about an assembly is controlled through the following
|
||||
|
// set of attributes. Change these attribute values to modify the information
|
||||
|
// associated with an assembly.
|
||||
|
[assembly: AssemblyConfiguration("")] |
||||
|
[assembly: AssemblyCompany("")] |
||||
|
[assembly: AssemblyProduct("Volo.Abp.AspNetCore.Tests")] |
||||
|
[assembly: AssemblyTrademark("")] |
||||
|
|
||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
|
// to COM components. If you need to access a type in this assembly from
|
||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||
|
[assembly: ComVisible(false)] |
||||
|
|
||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
|
[assembly: Guid("b1d860bb-6ec6-4bae-adaa-c2aec2ffb510")] |
||||
@ -0,0 +1,21 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
|
<PropertyGroup> |
||||
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion> |
||||
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /> |
||||
|
<PropertyGroup Label="Globals"> |
||||
|
<ProjectGuid>b1d860bb-6ec6-4bae-adaa-c2aec2ffb510</ProjectGuid> |
||||
|
<RootNamespace>Volo.Abp.AspNetCore.Tests</RootNamespace> |
||||
|
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> |
||||
|
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> |
||||
|
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<SchemaVersion>2.0</SchemaVersion> |
||||
|
</PropertyGroup> |
||||
|
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" /> |
||||
|
</Project> |
||||
@ -0,0 +1,21 @@ |
|||||
|
{ |
||||
|
"version": "1.0.0-*", |
||||
|
|
||||
|
"testRunner": "xunit", |
||||
|
|
||||
|
"dependencies": { |
||||
|
"AbpTestBase": "1.0.0-*", |
||||
|
"Volo.Abp.AspNetCore": "1.0.0-*" |
||||
|
}, |
||||
|
|
||||
|
"frameworks": { |
||||
|
"netcoreapp1.0": { |
||||
|
"dependencies": { |
||||
|
"Microsoft.NETCore.App": { |
||||
|
"type": "platform", |
||||
|
"version": "1.0.0" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue