diff options
author | fcolin | 2007-02-01 12:05:47 +0000 |
---|---|---|
committer | fcolin | 2007-02-01 12:05:47 +0000 |
commit | 3593a483d5566779f1d56e037615685cdc77c0a0 (patch) | |
tree | 300986bb2f463148fd0773efc5f69654ae2cd53f /IvyToDel/IvyPPC/IvyBinding.cs | |
parent | 3ce9b3f180e3f52c7be79e0a23bbd1a0b5120ac6 (diff) | |
download | ivy-csharp-3593a483d5566779f1d56e037615685cdc77c0a0.zip ivy-csharp-3593a483d5566779f1d56e037615685cdc77c0a0.tar.gz ivy-csharp-3593a483d5566779f1d56e037615685cdc77c0a0.tar.bz2 ivy-csharp-3593a483d5566779f1d56e037615685cdc77c0a0.tar.xz |
modification structure svn
Diffstat (limited to 'IvyToDel/IvyPPC/IvyBinding.cs')
-rw-r--r-- | IvyToDel/IvyPPC/IvyBinding.cs | 118 |
1 files changed, 0 insertions, 118 deletions
diff --git a/IvyToDel/IvyPPC/IvyBinding.cs b/IvyToDel/IvyPPC/IvyBinding.cs deleted file mode 100644 index 624b401..0000000 --- a/IvyToDel/IvyPPC/IvyBinding.cs +++ /dev/null @@ -1,118 +0,0 @@ -using System;
-using System.Collections;
-using System.Collections.Specialized;
-using System.Text.RegularExpressions;
-using System.Diagnostics;
-
-namespace IvyBus
-{
- /* This is the Client side of binding storage */
- /* association of a generated Key and the expression and a compiled Expression matching */
- /* this is RECEIVED from other client */
-
- /// <summary>
- /// Description résumée de IvyBinding.
- /// </summary>
- internal abstract class IvyBindingBase
- {
-
- private ushort key;
-
- internal ushort Key
- {
- get { return key; }
- }
- protected string expression;
-
- internal string Expression
- {
- get { return expression; }
- }
-
- internal IvyBindingBase(ushort id, string exp)
- {
- key = id;
- expression = exp;
- }
- internal abstract string[] Match(string message);
-
- }
- internal class IvyBindingRegexp : IvyBindingBase
- {
- internal Regex regexp;
-
- public IvyBindingRegexp(ushort id, string exp)
- : base(id, exp)
- {
- regexp = new Regex(expression, /* RegexOptions.Compiled | */RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
- //regexp.Match("###"); // for really compile the expression really slow on 3000 expression
- }
- internal override string[] Match(string message)
- {
- 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 string[result.Groups.Count-1];
- for (int sub = 1; sub < result.Groups.Count; sub++)
- {
- args[sub-1] = result.Groups[sub].Value;
- }
- }
- return args;
- }
- }
- internal class IvyBindingSimple : IvyBindingBase
- {
- internal string msgname; // message name
- internal string[] msgargs; // list of message args names
- static string msgtag; // send message name
- static StringDictionary args_values; // send message args[name]=value
-
- internal IvyBindingSimple(ushort id, string exp)
- : base(id, exp)
- {
- string[] expr = expression.Split( ' ' );
- msgname = expr[0];
- msgargs = new string[ expr.Length -1 ];
- for ( int i = 1; i < expr.Length; i++ )
- msgargs[i-1] = expr[i];
- }
- static internal void Prepare(string message)
- {
- string[] msg = message.Split(' ');
- msgtag = msg[0];
- args_values = new StringDictionary();
- for( int sub=1 ; sub < msg.Length; sub++ )
- {
- string[] arg = msg[sub].Split('='); // champ = valeur
- if ( arg.Length == 2 )
- args_values[arg[0]] = arg[1];
- else
- {
- Ivy.traceError("IvyBindingSimple" , "abnormally Formed message expected 'msg champ=valeur champ=valeur....' :" + message);
- }
- }
-
- }
- internal override string[] Match(string message)
- {
- // the message is already parsed by prepare
- //
- string[] args = null;
-
- if (msgtag == msgname)
- {
- args = new string[msgargs.Length];
- for( int sub= 0; sub < msgargs.Length; sub++)
- {
- args[sub] = args_values[msgargs[sub]];
- }
- }
- return args;
- }
-
- }
-}
|