Changed to use Authenticate asp.net event instead of Authorize
[castle.git] / MonoRail / Castle.MonoRail.Framework.Views.NVelocity / Helpers / StaticAccessorHelper.cs
bloba47a40d1aad89bdbd4bf02723eed69ac680a7376
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 Castle.MonoRail.Framework.Views.NVelocity
17 using System.Reflection;
19 /// <summary>
20 /// Provides a helper to access static operations on types to NVelocity.
21 /// </summary>
22 /// <typeparam name="T">the type to access</typeparam>
23 public class StaticAccessorHelper<T> : global::NVelocity.IDuck
25 #region IDuck Members
27 /// <summary>
28 /// Invoke a get operation on the value type
29 /// </summary>
30 /// <param name="propName">the property or field to get</param>
31 /// <returns>the value</returns>
32 public object GetInvoke(string propName)
34 return
35 typeof (T).InvokeMember(propName,
36 BindingFlags.Public | BindingFlags.Static | BindingFlags.GetField |
37 BindingFlags.GetProperty,
38 null, null, new object[] {});
41 /// <summary>
42 /// Invoke a method on the value type
43 /// </summary>
44 /// <param name="method">the method name</param>
45 /// <param name="args">the argumenents.</param>
46 /// <returns>the result of the method invocation.</returns>
47 public object Invoke(string method, params object[] args)
49 return
50 typeof (T).InvokeMember(method, BindingFlags.Public | BindingFlags.Static | BindingFlags.InvokeMethod,
51 null, null, args);
54 /// <summary>
55 /// Invoke a set operation on the value type
56 /// </summary>
57 /// <param name="propName">the property or field to set</param>
58 /// <param name="value">the value to set the property or field to.</param>
59 public void SetInvoke(string propName, object value)
61 typeof (T).InvokeMember(propName,
62 BindingFlags.Public | BindingFlags.Static | BindingFlags.SetField |
63 BindingFlags.SetProperty,
64 null, null, new object[] {value});
67 #endregion