1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace AspectSharp
.LoggingExample
18 using AspectSharp
.Builder
;
19 using AspectSharp
.LoggingExample
.Model
;
22 /// Sample application demonstrating a very basic use of Aspect#.
26 private static AspectEngine _engine
;
29 static void Main(string[] args
)
31 //Reading the config from an application configuration file.
32 AppDomainConfigurationBuilder builder
= new AppDomainConfigurationBuilder();
34 //Creating the AspectEngine, based on the configuration.
35 _engine
= builder
.Build();
39 Console
.WriteLine(" ");
40 Console
.WriteLine(" ");
42 InterfaceInvocation();
44 Console
.WriteLine("\r\nPress any key to exit." );
49 /// Shows interception of an interface method.
51 private static void InterfaceInvocation()
53 Console
.WriteLine("InterfaceInvocation");
55 //Wraping the class which is compatible with the inteface.
56 IAgatKiller agatKiller
= _engine
.WrapInterface(typeof(IAgatKiller
), new Ronin()) as IAgatKiller
;
58 agatKiller
.KillAgat("Demon's Castle", "Bleed Sword");
62 /// Shows interception of an class method.
64 private static void ClassInvocation()
66 Console
.WriteLine("ClassInvocation");
69 MachineGun machineGun
= _engine
.WrapClass(typeof(MachineGun
)) as MachineGun
;
71 //Not intercepted. It isn't a virtual method.
75 machineGun
.FireTenTimes();