Teddy's Aspect Weaver Version 0.2 with Additional Custom Attribute Way Configuration


1. Introduction

In Build a More Powerful AOP Framework Based on AspectDNG's ILML Library - Teddy's Aspect Weaver, I built the Teddy's Aspect Weaver Version 0.1 with the xml based meta way configuration support. And this time, in version 0.2, I provide the addtional custom attribute way configuration support. You can use both meta way and custom attribute way configuration in even one weaving project.

Below is the usage sample:

Configuration

<? xml version="1.0" encoding="utf-8"  ?>  
< Configuration  logFile ="LogWeaving.xml"  cleanTempFiles ="false" >
    
< BaseAssembly > ../TestLib/bin/Debug/TestLib.dll </ BaseAssembly >
    
< OutputAssembly > ../TestLib/bin/Debug/TestLib_output.dll </ OutputAssembly >
    
< AspectAssemblies >
        
< AspectAssembly  uniqueName ="TestAspectLib.dll"  path ="bin/Debug/TestAspectLib.dll"   />
    
</ AspectAssemblies >
</ Configuration >

TestAspectClass.cs

using  System;
using  AspectWeaver.Attributes;

namespace  TestAspectLib
{
    
public class TestAspectClass
    
{
        [Introduce(
"//Type[@name='TestClass']")]
        
private string fieldToBeIntroducedByCustomAttribute = "fieldToBeIntroducedByCustomAttribute";

        [Introduce(
"//Type[@name='TestClass']")]
        
public void MethodToBeIntrodcuedByCustomAttribute()
        
{
        }

    }


    [Introduce()]
    
public class ClassToBeIntroducedByCustomAttribute
    
{
    }

}


This sample is part of sample with both meta way and custom attribute way configuration within AspectWeaver0.2 source code. Be careful, don't define the same advice both in meta xml and custom attribute, or that may cause error. And only the advices with a code element can be configurated with the new custom attribute way. Advices can be configurated by the new way are: Introduce, BeforeConstructor/AfterConstructor, BeforeMethodCall/AfterMethodCall, InlineAtStart, InlineBeforeReturn and AroundBody.

2. Download Source Code

AspectWeaver0.3.zip
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值