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; } } }