summaryrefslogtreecommitdiff
path: root/CSharp
diff options
context:
space:
mode:
authorfcolin2007-02-01 09:56:47 +0000
committerfcolin2007-02-01 09:56:47 +0000
commit64e0fd69a88c5527698b85f33df4933638448161 (patch)
treee986df82c05a6e77152e65884b56b0ce9c5035d4 /CSharp
parent2fac7f440359885e464e34d25554c2068eb3350b (diff)
downloadivy-csharp-64e0fd69a88c5527698b85f33df4933638448161.zip
ivy-csharp-64e0fd69a88c5527698b85f33df4933638448161.tar.gz
ivy-csharp-64e0fd69a88c5527698b85f33df4933638448161.tar.bz2
ivy-csharp-64e0fd69a88c5527698b85f33df4933638448161.tar.xz
Utilisateur : Fcolin Date : 19/09/05 Heure : 14:14 Archivé dans $/CSharp/Ivy Commentaire: Passage Nouvel API IVY ( pas teste ) (vss 2)
Diffstat (limited to 'CSharp')
-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;
}
}