summaryrefslogtreecommitdiff
path: root/CSharp/Ivy/IvyPPC/IvyBinding.cs
diff options
context:
space:
mode:
Diffstat (limited to 'CSharp/Ivy/IvyPPC/IvyBinding.cs')
-rw-r--r--CSharp/Ivy/IvyPPC/IvyBinding.cs33
1 files changed, 15 insertions, 18 deletions
diff --git a/CSharp/Ivy/IvyPPC/IvyBinding.cs b/CSharp/Ivy/IvyPPC/IvyBinding.cs
index c7be101..c5fd5fe 100644
--- a/CSharp/Ivy/IvyPPC/IvyBinding.cs
+++ b/CSharp/Ivy/IvyPPC/IvyBinding.cs
@@ -7,7 +7,7 @@ namespace IvyBus
/// <summary>
/// Description résumée de IvyBinding.
/// </summary>
- internal class IvyBindingBase
+ internal abstract class IvyBindingBase
{
internal int key;
@@ -18,10 +18,7 @@ namespace IvyBus
key = id;
expression = exp;
}
- public virtual string[] Match(string message)
- {
- return null;
- }
+ public abstract IvyArgument Match(string message);
}
internal class IvyBindingRegexp : IvyBindingBase
@@ -32,21 +29,21 @@ namespace IvyBus
{
regexp = new Regex(expression,RegexOptions.Compiled|RegexOptions.IgnoreCase);
}
- public override string[] Match(string message)
+ public override IvyArgument Match(string message)
{
- string[] array = null;
+ IvyArgument args = null;
// use of regexp to extract info
Match result = regexp.Match(message);
if (result.Success)
{
// Start at 1 because group 0 represent entire matching
- array = new string[result.Groups.Count -1];
+ args = new IvyArgument("");
for (int sub = 1; sub < result.Groups.Count; sub++)
{
- array[sub-1] = result.Groups[sub].Value;
+ args.addChild( new IvyArgument( result.Groups[sub].Value ));
}
}
- return array;
+ return args;
}
}
internal class IvyBindingSimple : IvyBindingBase
@@ -54,7 +51,7 @@ namespace IvyBus
internal string msgname; // message name
internal string[] msgargs; // list of message args names
static string msgtag; // send message name
- static Hashtable args = null; // send message args[name]=value
+ static Hashtable args_values = null; // send message args[name]=value
public IvyBindingSimple(int id, string exp):base(id,exp)
{
@@ -68,12 +65,12 @@ namespace IvyBus
{
string[] msg = message.Split(' ');
msgtag = msg[0];
- args = new Hashtable();
+ args_values = new Hashtable();
for( int sub=1 ; sub < msg.Length; sub++ )
{
string[] arg = msg[sub].Split('='); // champ = valeur
if ( arg.Length == 2 )
- args[arg[0]] = arg[1];
+ args_values[arg[0]] = arg[1];
else
{
Console.Out.WriteLine("abnormally Formed message expected 'msg champ=valeur champ=valeur....' :" + message);
@@ -81,21 +78,21 @@ namespace IvyBus
}
}
- public override string[] Match(string message)
+ public override IvyArgument Match(string message)
{
// the message is already parsed by prepare
//
- string[] array = null;
+ IvyArgument args = null;
if (msgtag == msgname)
{
- array = new string[msgargs.Length];
+ args = new IvyArgument("");
for( int sub= 0; sub < msgargs.Length; sub++)
{
- array[sub] = (string) args[ msgargs[sub]];
+ args.addChild( new IvyArgument( (string) args_values[ msgargs[sub]] ));
}
}
- return array;
+ return args;
}
}