From 98ab5d0164040427f7c554febae125686284e2a7 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:03:55 +0000 Subject: modification structure svn --- IvyToDel/Ivy/IvyBindingAttribute.cs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 IvyToDel/Ivy/IvyBindingAttribute.cs (limited to 'IvyToDel/Ivy/IvyBindingAttribute.cs') diff --git a/IvyToDel/Ivy/IvyBindingAttribute.cs b/IvyToDel/Ivy/IvyBindingAttribute.cs new file mode 100644 index 0000000..90c44ce --- /dev/null +++ b/IvyToDel/Ivy/IvyBindingAttribute.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace IvyBus +{ + [AttributeUsage(AttributeTargets.Method,AllowMultiple = true)] + public sealed class IvyBindingAttribute : Attribute + { + private string expression; + private string[] args; + + // translate part of expression to object property + public string GetExpression(object obj) + { + if (obj == null) return string.Format(expression); + object[] values = new object[args.Length]; + for (int i = 0; i < args.Length; i++) + { + values[i] = obj.GetType().GetProperty(args[i]).GetValue(obj,null); + } + return string.Format(expression,values); + } + + public IvyBindingAttribute(string expression, params string[] args) + { + this.expression = expression; + this.args = args; + } + } +} -- cgit v1.1