All Projects → sagifogel → NCop

sagifogel / NCop

Licence: MIT license
Composite-aspect oriented framework for .NET

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to NCop

AspecTS
An aspect-oriented programming library implemented in TypeScript
Stars: ✭ 21 (-30%)
Mutual labels:  aspect, aop, aspect-oriented-programming
aspectgo
Aspect-Oriented Programming framework for Go
Stars: ✭ 62 (+106.67%)
Mutual labels:  aop, aspect-oriented-programming
Decor.NET
A simple way to decorate a class with additional functionality using attributes.
Stars: ✭ 29 (-3.33%)
Mutual labels:  aop, aspect-oriented-programming
Norns
dotnet core aop static weaving on roslyn
Stars: ✭ 23 (-23.33%)
Mutual labels:  aspect, aop
monogram
Aspect-oriented layer on top of the MongoDB Node.js driver
Stars: ✭ 76 (+153.33%)
Mutual labels:  aspect-oriented-framework, aspect-oriented-programming
CNeptune
CNeptune improve productivity & efficiency by urbanize .net module with meta-code to lay foundation for frameworks
Stars: ✭ 30 (+0%)
Mutual labels:  aop, aspect-oriented-programming
Mimick.Fody
An integrated framework for dependency injection and aspect-oriented processing.
Stars: ✭ 15 (-50%)
Mutual labels:  aop, aspect-oriented-programming
goaop-laravel-bridge
Integration bridge for Go! AOP framework and Laravel
Stars: ✭ 91 (+203.33%)
Mutual labels:  aop, aspect-oriented-programming
Aspect4Delphi
Concepts of aspect-oriented programming (AOP) in Delphi.
Stars: ✭ 28 (-6.67%)
Mutual labels:  aop, aspect-oriented-programming
Framework
💎 Go! AOP PHP - modern aspect-oriented framework for the new level of software development
Stars: ✭ 1,559 (+5096.67%)
Mutual labels:  aop, aspect-oriented-framework
Cauldron
C# Toolkit
Stars: ✭ 68 (+126.67%)
Mutual labels:  aspect, aop
Beike AspectD
Flutter AOP framework.(Flutter面向切面库, 最新适配Flutter v2.5.3, null-safety)
Stars: ✭ 39 (+30%)
Mutual labels:  aspect, aop
Aspect Injector
AOP framework for .NET (c#, vb, etc)
Stars: ✭ 398 (+1226.67%)
Mutual labels:  mixins, aop
Skeleton Sass
Skeleton Sass is a highly modular version of Skeleton CSS
Stars: ✭ 151 (+403.33%)
Mutual labels:  mixins
Hyperium
Hyperium, Free Minecraft client with HUDs and Popular mods
Stars: ✭ 217 (+623.33%)
Mutual labels:  mixins
Mimic
mimic: Define your Deployments, Infrastructure and Configuration as a Go Code 🚀
Stars: ✭ 145 (+383.33%)
Mutual labels:  mixins
Super module
SuperModule allows defining class methods and method invocations the same way a super class does without using def included(base). This also succeeds ActiveSupport::Concern by offering lighter syntax
Stars: ✭ 133 (+343.33%)
Mutual labels:  mixins
media-blender
Easy and predictable SASS/SCSS media queries
Stars: ✭ 26 (-13.33%)
Mutual labels:  mixins
Pug Bootstrap
Bootstrap framework written completely using mixins in Pug
Stars: ✭ 212 (+606.67%)
Mutual labels:  mixins
Accecss
AcceCSS A Sass Mixin That debug & check the accessibility of your designs
Stars: ✭ 132 (+340%)
Mutual labels:  mixins

NCop

What is NCop?

NCop is a framework that implements Composite/Aspect Oriented Programming that encapsulates the concepts of Mixins, Aspects and Dependency Injection, using the standard .NET.
The main purpose of composites is separation of concerns. You achieve it by defining different roles within different entities and combine all of them using NCop (much like multiple inheritance).

Installing

Install-Package NCop

Please visit the Wiki page for explanations and demos.

Mixins

A mixin is an interface with implemented methods.
Mixins exists in .NET in the form of object oriented interfaces implementation.

public interface IDeveloper
{
    void Code();
}
public class CSharpDeveloperMixin : IDeveloper
{
    public void Code() {
        Console.WriteLine("C# coding");
    }
}

Composites

Composites are the artifacts of NCop processing. A composite is a combination of Mixins and Aspects.
In order to create a composite type you need to annotate one of the interfaces with a CompositeAttribute
and also to tell NCop to match between interface and implementation by annotating the composite type with a MixinsAttribute.

[TransientComposite]
[Mixins(typeof(CSharpDeveloperMixin))]
public interface IDeveloper
{
    void Code();
}

Aspects

Aspects aims to increase modularity by allowing the separation of cross-cutting concerns.
In order to create an aspect you should first create an aspect class that will hold your desired join points.

public class StopwatchActionInterceptionAspect : ActionInterceptionAspect
{
    private readonly Stopwatch stopwatch = null;

    public StopwatchActionInterceptionAspect() {
        stopwatch = new Stopwatch();
    }

    public override void OnInvoke(ActionInterceptionArgs args) {
        stopwatch.Restart();
        args.Proceed();
        stopwatch.Stop();
        Console.WriteLine("Elapsed Ticks: {0}", stopwatch.ElapsedTicks);
    }
}

The second thing that you will need to do is to annotate the method which you want to apply the aspect on.

[TransientComposite]
[Mixins(typeof(CSharpDeveloperMixin))]
public interface IDeveloper
{
    [MethodInterceptionAspect(typeof(StopwatchActionInterceptionAspect))]
    void Code();
}

Dependency Injection

NCop IoC is based on Funq - which was adopted because of its excellent performance and memory characteristics.
In order to resolve an artifact of NCop you need to create a composite IoC Container,
and call the Resolve function.

static void Main(string[] args) {
    IDeveloper developer = null;
    var container = new CompositeContainer();

    container.Configure();
    developer = container.Resolve<IDeveloper>();
    developer.Code();
}

The expected output should be:

"C# coding"
"Elapsed Ticks: [Number of ticks]"
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].