From f83df6ab64222597883715847c099ccaf392749e Mon Sep 17 00:00:00 2001
From: fcolin
Date: Thu, 1 Feb 2007 09:43:17 +0000
Subject: Utilisateur : Fcolin Date : 23/01/06 Heure : 18:08 Archivé
dans $/CSharp/Ivy/Ivy Commentaire: (vss 40)
---
CSharp/Ivy/Ivy/Ivy.cs | 70 +++++++++++++++++++++++++++++++++++++--------------
1 file changed, 51 insertions(+), 19 deletions(-)
(limited to 'CSharp')
diff --git a/CSharp/Ivy/Ivy/Ivy.cs b/CSharp/Ivy/Ivy/Ivy.cs
index 30b5592..40caf48 100644
--- a/CSharp/Ivy/Ivy/Ivy.cs
+++ b/CSharp/Ivy/Ivy/Ivy.cs
@@ -57,7 +57,7 @@ namespace IvyBus
/// fires when a client receive a remove binding from another client
public event ClientRemoveBindingHandler BindingRemove;
-
+ [Category("Ivy")]
public bool Debug
{
get
@@ -70,7 +70,7 @@ namespace IvyBus
}
}
-
+ [Category("Ivy")]
public CultureInfo Culture
{
get
@@ -85,7 +85,8 @@ namespace IvyBus
}
/// IvyClients accesses the list of the connected clients
- public List IvyClients
+ [Browsable(false)]
+ public List IvyClients
{
get
{
@@ -93,8 +94,8 @@ namespace IvyBus
}
}
- /// ClientNames accesses the name list of the connected clients
- private string ClientNames
+ /// ClientNames accesses the name list of the connected clientsAppName the application name
- public string AppName
+ [Category("Ivy")]
+ public string AppName
{
set
{
@@ -126,7 +128,8 @@ namespace IvyBus
}
}
- public string AppId
+ [Browsable(false)]
+ public string AppId
{
get
{
@@ -134,6 +137,7 @@ namespace IvyBus
}
}
+ [Category("Ivy")]
public ushort AppPriority
{
set
@@ -154,6 +158,7 @@ namespace IvyBus
}
}
+ [Browsable(false)]
public int ProtocolVersion
{
get
@@ -165,6 +170,7 @@ namespace IvyBus
///SentMessageClasses the first word token of sent messages
/// optimise the parsing process when sending messages
///
+ [Category("Ivy")]
public string[] SentMessageClasses
{
get
@@ -189,14 +195,14 @@ namespace IvyBus
}
/// the name of the application on the bus
- internal string appName;
+ internal string appName;
/// the port for the UDP rendez vous, if none is supplied
internal const ushort DEFAULT_PORT = 2010;
// client default priority
internal const ushort DEFAULT_PRIORITY = 100;
/// the domain for the UDP rendez vous
- internal static readonly string DEFAULT_DOMAIN = "127.255.255.255:" + DEFAULT_PORT;
- internal const string libVersion = "2.0.0";
+ private static readonly string DEFAULT_DOMAIN = "127.255.255.255:" + DEFAULT_PORT;
+ private const string libVersion = "2.0.0";
internal int protocolVersion = 3;
private bool debug = false;
private static ushort serial = 0; /* an unique ID for each regexp */
@@ -222,16 +228,27 @@ namespace IvyBus
internal IPAddress applicationHost; /* Application host number */
internal string applicationUniqueId; /* identifier Application unique timestamp-ipaddress-port */
internal ushort applicationPriority = DEFAULT_PRIORITY;
- internal string ready_message = null;
- internal CultureInfo culture = new CultureInfo("en-us");
-
- // for synchronous event
+ private string ready_message = null;
+ private CultureInfo culture = new CultureInfo("en-us");
+ // for synchronous event
private Control syncControl = null;
-
+
+ [Category("Ivy")]
+ public string ReadyMessage
+ {
+ get { return ready_message; }
+ set { ready_message = value; }
+ }
+
+
+ [Category("Ivy")]
public Control SyncControl
{
get { return syncControl; }
- set { syncControl = value; }
+ set {
+ syncControl = value;
+ AutoBinding(syncControl);
+ }
}
public Ivy()
{
@@ -277,19 +294,34 @@ namespace IvyBus
{
syncControl = sync;
}
+ // Autobinding on static method
public void AutoBinding(Type type)
{
- //Get instance of the IvyBindingAttribute.
+ //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);
+ Console.WriteLine("IvyBinding " + attr.Expression + "to Method " + m.Name);
bindMsg(attr.Expression, (MessageHandler)Delegate.CreateDelegate(typeof(MessageHandler), m));
}
}
+ }
+ // Autobinding on instance method
+ public void AutoBinding(object obj)
+ {
+ Type type = obj.GetType();
+ //Get instance of the IvyBindingAttribute.
+ foreach (MethodInfo m in type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic))
+ {
+ foreach (IvyBindingAttribute attr in Attribute.GetCustomAttributes(m, typeof(IvyBindingAttribute)))
+ {
+ //TODO check paramater type MessageHandler
+ Console.WriteLine("IvyBinding " + attr.Expression + "to Method " + m.Name);
+ bindMsg(attr.Expression, (MessageHandler)Delegate.CreateDelegate(typeof(MessageHandler), obj, m));
+ }
+ }
}
/// connects the Ivy bus to a domain or list of domains.
--
cgit v1.1