Skip to content

Commit

Permalink
Merge pull request aspnetboilerplate#1008 from carldai0106/master
Browse files Browse the repository at this point in the history
Add DontCreateAttribute, To be more simply disable a Service Or a  Action to be Dynamic WebApi
  • Loading branch information
hikalkan committed May 9, 2016
2 parents ab9c23b + f0a02d0 commit 314a8ec
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http.Filters;
using Abp.Application.Services;
using Abp.WebApi.Controllers.Dynamic.Interceptors;

namespace Abp.WebApi.Controllers.Dynamic.Builders
Expand Down Expand Up @@ -50,6 +52,11 @@ public ApiControllerBuilder(string serviceName)
foreach (var methodInfo in DynamicApiControllerActionHelper.GetMethodsOfType(typeof(T)))
{
_actionBuilders[methodInfo.Name] = new ApiControllerActionBuilder<T>(this, methodInfo);
var list = methodInfo.GetCustomAttributes(false);
if (list.Any(x => x.GetType() == typeof(DontCreateAttribute)))
{
_actionBuilders[methodInfo.Name].DontCreateAction();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Linq;
using System.Reflection;
using System.Web.Http.Filters;
using Abp.Application.Services;
using Abp.Dependency;
using Abp.Extensions;

Expand Down Expand Up @@ -67,6 +68,9 @@ public void Build()

foreach (var type in types)
{
if (type.GetCustomAttributes().Any(x => x.GetType() == typeof (DontCreateAttribute)))
continue;

var serviceName = _serviceNameSelector != null
? _serviceNameSelector(type)
: GetConventionalServiceName(type);
Expand Down
1 change: 1 addition & 0 deletions src/Abp/Abp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
<ItemGroup>
<Compile Include="AbpConsts.cs" />
<Compile Include="AbpServiceBase.cs" />
<Compile Include="Application\Services\DontCreateAttribute.cs" />
<Compile Include="Auditing\AuditingContractResolver.cs" />
<Compile Include="Authorization\PermissionDependencyContext.cs" />
<Compile Include="Authorization\PermissionDependencyExtensions.cs" />
Expand Down
10 changes: 10 additions & 0 deletions src/Abp/Application/Services/DontCreateAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;
namespace Abp.Application.Services
{
[Serializable]
[AttributeUsage(AttributeTargets.Interface | AttributeTargets.Method)]
public class DontCreateAttribute : Attribute
{

}
}

0 comments on commit 314a8ec

Please sign in to comment.