summaryrefslogtreecommitdiff
path: root/CSharp
diff options
context:
space:
mode:
authorfcolin2007-02-01 09:56:49 +0000
committerfcolin2007-02-01 09:56:49 +0000
commit5e415074ec406ff083e49cc156b38e51f8af4cc0 (patch)
tree0fa8e19032d79c83737ffaab546e8a584ea9a706 /CSharp
parent64e0fd69a88c5527698b85f33df4933638448161 (diff)
downloadivy-csharp-5e415074ec406ff083e49cc156b38e51f8af4cc0.zip
ivy-csharp-5e415074ec406ff083e49cc156b38e51f8af4cc0.tar.gz
ivy-csharp-5e415074ec406ff083e49cc156b38e51f8af4cc0.tar.bz2
ivy-csharp-5e415074ec406ff083e49cc156b38e51f8af4cc0.tar.xz
Utilisateur : Fcolin Date : 19/12/05 Heure : 16:54 Archivé dans $/CSharp/Ivy Commentaire: (vss 3)
Diffstat (limited to 'CSharp')
-rw-r--r--CSharp/Ivy/IvyPPC/IvyBinding.cs41
1 files changed, 24 insertions, 17 deletions
diff --git a/CSharp/Ivy/IvyPPC/IvyBinding.cs b/CSharp/Ivy/IvyPPC/IvyBinding.cs
index c5fd5fe..1ff96e5 100644
--- a/CSharp/Ivy/IvyPPC/IvyBinding.cs
+++ b/CSharp/Ivy/IvyPPC/IvyBinding.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections;
+using System.Collections.Specialized;
using System.Text.RegularExpressions;
namespace IvyBus
@@ -9,39 +10,42 @@ namespace IvyBus
/// </summary>
internal abstract class IvyBindingBase
{
-
- internal int key;
+
+ internal ushort key;
internal string expression;
-
- public IvyBindingBase(int id, string exp)
+
+ public IvyBindingBase(ushort id, string exp)
{
key = id;
expression = exp;
}
- public abstract IvyArgument Match(string message);
+ public abstract string[] Match(string message);
}
internal class IvyBindingRegexp : IvyBindingBase
{
internal Regex regexp;
-
- public IvyBindingRegexp(int id, string exp):base(id,exp)
+
+ public IvyBindingRegexp(ushort id, string exp)
+ : base(id, exp)
{
regexp = new Regex(expression,RegexOptions.Compiled|RegexOptions.IgnoreCase);
}
- public override IvyArgument Match(string message)
+ public override string[] Match(string message)
{
- IvyArgument args = null;
+ string[] 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
- args = new IvyArgument("");
+ StringCollection coll = new StringCollection();
for (int sub = 1; sub < result.Groups.Count; sub++)
{
- args.addChild( new IvyArgument( result.Groups[sub].Value ));
+ coll.Add(result.Groups[sub].Value);
}
+ args = new string[coll.Count];
+ coll.CopyTo(args, 0);
}
return args;
}
@@ -52,8 +56,9 @@ namespace IvyBus
internal string[] msgargs; // list of message args names
static string msgtag; // send message name
static Hashtable args_values = null; // send message args[name]=value
-
- public IvyBindingSimple(int id, string exp):base(id,exp)
+
+ public IvyBindingSimple(ushort id, string exp)
+ : base(id, exp)
{
string[] expr = expression.Split( ' ' );
msgname = expr[0];
@@ -78,19 +83,21 @@ namespace IvyBus
}
}
- public override IvyArgument Match(string message)
+ public override string[] Match(string message)
{
// the message is already parsed by prepare
//
- IvyArgument args = null;
+ string[] args = null;
if (msgtag == msgname)
{
- args = new IvyArgument("");
+ StringCollection coll = new StringCollection();
for( int sub= 0; sub < msgargs.Length; sub++)
{
- args.addChild( new IvyArgument( (string) args_values[ msgargs[sub]] ));
+ coll.Add((string)args_values[msgargs[sub]]);
}
+ args = new string[coll.Count];
+ coll.CopyTo(args, 0);
}
return args;
}