Added container accessor to Castle.Core
[castle.git] / AspectSharp / AspectSharp.Tests / Classes / LogInvocationInterceptor.cs
blob51c46023e56856211cfa0d21feac251d96b44f90
1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
2 //
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
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
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.Tests.Classes
17 using System;
18 using System.Collections;
19 using System.Reflection;
21 using AopAlliance.Intercept;
24 public class LogInvocationInterceptor : IMethodInterceptor
26 private static readonly ArrayList _list = new ArrayList();
28 public LogInvocationInterceptor()
32 public static void Clear()
34 _list.Clear();
37 public static String[] Messages
39 get { return (String[]) _list.ToArray( typeof(String) ); }
42 public object Invoke(IMethodInvocation invocation)
44 MethodBase method = invocation.Method;
46 if (method.IsSpecialName)
48 _list.Add("property " + method.Name);
50 else
52 Type[] args = Type.GetTypeArray(invocation.Arguments);
54 String argMessage = "(";
55 foreach(Type arg in args)
57 argMessage += " " + arg.Name;
59 argMessage += ")";
61 _list.Add("method " + method.Name + argMessage);
64 return invocation.Proceed();