summaryrefslogtreecommitdiff
path: root/CSharp/Ivy/IvyPPC/Ivy.cs
diff options
context:
space:
mode:
Diffstat (limited to 'CSharp/Ivy/IvyPPC/Ivy.cs')
-rw-r--r--CSharp/Ivy/IvyPPC/Ivy.cs29
1 files 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;
/// <summary> The Main bus Class
/// </summary>
@@ -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));
+ }
+ }
+
+ }
/// <summary> connects the Ivy bus to a domain or list of domains.
/// </summary>
/// <remarks>
@@ -481,6 +497,7 @@ namespace IvyBus
/// </returns>
//
// 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