From 6e3ecf34f1bf10dcfda57a80308ff1fcfccad682 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 09:55:04 +0000 Subject: Utilisateur : Fcolin Date : 13/01/06 Heure : 16:28 Archivé dans $/CSharp/Ivy/Ivy Commentaire: (vss 34) --- CSharp/Ivy/IvyPPC/Ivy.cs | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/CSharp/Ivy/IvyPPC/Ivy.cs b/CSharp/Ivy/IvyPPC/Ivy.cs index d99942b..46ce746 100644 --- a/CSharp/Ivy/IvyPPC/Ivy.cs +++ b/CSharp/Ivy/IvyPPC/Ivy.cs @@ -18,6 +18,7 @@ namespace IvyBus using System.Globalization; using System.Text.RegularExpressions; using System.Text; + using System.Reflection; /// The Main bus Class /// @@ -237,12 +238,27 @@ namespace IvyBus debug = Properties.Settings.Default.IvyDebug; protocolVersion = Properties.Settings.Default.IvyProtocolVersion; #endif + } public Ivy(string name, string message, Control sync) :this( name, message ) { syncControl = sync; } - + public void AutoBinding(Type type) + { + //Get instance of the IvyBindingAttribute. + foreach (MethodInfo m in type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic)) + { + Console.WriteLine("IvyBinding Method " + m.Name); + foreach (IvyBindingAttribute attr in Attribute.GetCustomAttributes(m, typeof(IvyBindingAttribute))) + { + //TODO check paramater type MessageHandler + Console.WriteLine("IvyBinding " + attr.Expression); + bindMsg(attr.Expression, (MessageHandler)Delegate.CreateDelegate(typeof(MessageHandler), m)); + } + } + + } /// connects the Ivy bus to a domain or list of domains. /// /// @@ -481,6 +497,7 @@ namespace IvyBus /// // // for compatibility raison with old IVY + [Obsolete("Will be removed in next version")] public int bindMsg(string regexp, MessageHandler callback) { return bindMsg( regexp, callback, null); @@ -864,6 +881,12 @@ namespace IvyBus return domainaddr + ":" + port; } } - - } + + + public static bool ValidatingDomain(string p) + { + // domain if of the form ip1[:port][,ip2[:port]] with ip of the form n1.n2.n3.n4 + return Regex.IsMatch(p, @"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d+"); + } + } } \ No newline at end of file -- cgit v1.1