AspNetCore.CoreExtension 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package AspNetCore.CoreExtension --version 1.0.0                
NuGet\Install-Package AspNetCore.CoreExtension -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AspNetCore.CoreExtension" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AspNetCore.CoreExtension --version 1.0.0                
#r "nuget: AspNetCore.CoreExtension, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AspNetCore.CoreExtension as a Cake Addin
#addin nuget:?package=AspNetCore.CoreExtension&version=1.0.0

// Install AspNetCore.CoreExtension as a Cake Tool
#tool nuget:?package=AspNetCore.CoreExtension&version=1.0.0                

##core mvc or api 中使用Castle.Core IOC容器(支持伪属性注入)

Startup.cs 中配置

public void ConfigureServices(IServiceCollection services)
        {       
           //使用Castle.Core dll 重写IOC容器,支持PropertyInjection,
            services.AddCastleCoreService();
            //service打上AopAttribute的实现类标记
            services.AddTransient<ITestServiceA, TestServiceA>();
        }

业务service

    public interface ITestServiceA
    {        
        [LogBefore]        
        [LogAfter]
        [Monitor]
        int Calculator(int a, int b);
    }
   public class TestServiceA : ITestServiceA
    {       
        public int Calculator(int p, int b)
        {
            return p + b;
        }
    }

添加Aop业务

public class MonitorAttribute : AopAttribute
    {
        public override Action ExecutIntercepting(IInvocation invocation, Action action)
        {
            return () =>
            {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();            
               
                action.Invoke();

                stopwatch.Stop();
                Console.WriteLine($"=======耗时{stopwatch.ElapsedMilliseconds}ms=====");
            };
        }
    }

 public class LogBeforeAttribute : AopAttribute
    {
        public override Action ExecutIntercepting(IInvocation invocation, Action action)
        {
            return () =>
            {
                Console.WriteLine($"=====AOP  before This is {invocation.Method.Name}");
                foreach (var para in invocation.Arguments)
                {
                    Console.WriteLine($"para is {para}");
                }
                Console.WriteLine("====**************************************");
                action.Invoke();
            };
        }
    }

 public class LogAfterAttribute : AopAttribute
    {
        public override Action ExecutIntercepting(IInvocation invocation, Action action)
        {
            return () =>
            {
                action.Invoke();
                Console.WriteLine($"=====AOP   After This is {invocation.Method.Name}");
                foreach (var para in invocation.Arguments)
                {
                    Console.WriteLine($"para is {para}");
                }
                Console.WriteLine("====**************************************");
            };
        }
    }

controller 下

    [Route("api/[controller]")]
    [ApiController]
    public class ValuesController : ControllerBase
    {
        [PropertyInjection]
        public ITestServiceA _testServiceA { get; set; }
        
        // GET api/values
        [HttpGet]
        public ActionResult<IEnumerable<string>> Get()
        {
            ITestServiceA f = (ITestServiceA)this._testServiceA.AOP(typeof(ITestServiceA));          
            var re=f.Calculator(10,999);
            return new string[] { "value1", "this is test ioc " };
        }      
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 514 7/2/2020
1.0.0 459 7/1/2020