summaryrefslogtreecommitdiff
path: root/CSharp
diff options
context:
space:
mode:
authorfcolin2007-02-01 09:56:16 +0000
committerfcolin2007-02-01 09:56:16 +0000
commit91bd8eb5c7b7e982b0aee3c83dd7884891ca35dc (patch)
tree611f60fbf6feecf6240573202adb851bbef257e4 /CSharp
parent683fa99d6ccdba424a659892bc7cf39bee7ac7ad (diff)
downloadivy-csharp-91bd8eb5c7b7e982b0aee3c83dd7884891ca35dc.zip
ivy-csharp-91bd8eb5c7b7e982b0aee3c83dd7884891ca35dc.tar.gz
ivy-csharp-91bd8eb5c7b7e982b0aee3c83dd7884891ca35dc.tar.bz2
ivy-csharp-91bd8eb5c7b7e982b0aee3c83dd7884891ca35dc.tar.xz
Utilisateur : Fcolin Date : 30/06/06 Heure : 16:43 Archivé dans $/CSharp/Ivy/IvyPPC Commentaire: (vss 70)
Diffstat (limited to 'CSharp')
-rw-r--r--CSharp/Ivy/IvyPPC/Ivy.cs92
1 files changed, 50 insertions, 42 deletions
diff --git a/CSharp/Ivy/IvyPPC/Ivy.cs b/CSharp/Ivy/IvyPPC/Ivy.cs
index 5ae69d6..892ed0f 100644
--- a/CSharp/Ivy/IvyPPC/Ivy.cs
+++ b/CSharp/Ivy/IvyPPC/Ivy.cs
@@ -23,7 +23,9 @@ namespace IvyBus
using System.ComponentModel;
using System.Diagnostics;
+#if (!PocketPC)
using System.ComponentModel.Design;
+#endif
// using System.Drawing.Design;
@@ -194,14 +196,15 @@ namespace IvyBus
///</summary>
#if (!PocketPC)
[Category("Ivy")]
-#endif
+
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
// sinon bug System.String constructor not found !
[Editor(
"System.Windows.Forms.Design.StringCollectionEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
"System.Drawing.Design.UITypeEditor,System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
)]
- public StringCollection SentMessageFilter
+#endif
+ public List<string> SentMessageFilter
{
get
{
@@ -226,6 +229,7 @@ namespace IvyBus
#if (!PocketPC)
[Category("Ivy")]
#endif
+#if (PocketPC)
[DefaultValue(null)]
public System.Windows.Forms.ContainerControl ContainerControl
{
@@ -235,11 +239,11 @@ namespace IvyBus
parentControl = value;
}
}
-
+#endif
#if (!PocketPC)
[Category("Ivy")]
-#endif
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+#endif
public List<IvyApplicationBinding> Bindings
{
get { return app_bindings; }
@@ -275,7 +279,7 @@ namespace IvyBus
//TODO should be remove samve as above
private List<IvyApplicationBinding> app_bindings;
private List<IvyClient> clients;
- private StringCollection sent_messageFilter;
+ private List<string> sent_messageFilter;
private bool stopped = true;
internal ushort applicationPort; /* Application port number */
internal IPAddress applicationHost; /* Application host number */
@@ -284,31 +288,31 @@ namespace IvyBus
private string ready_message;
private CultureInfo culture = new CultureInfo("en-us");
// for synchronous event
-#if (SyncContext)
- private readonly SynchronizationContext syncContext;
-#else
+#if (PocketPC)
private System.Windows.Forms.ContainerControl parentControl;
-#endif
-
+#else
+ private readonly SynchronizationContext syncContext;
+#endif
+
public Ivy()
{
-#if (SynContext)
+#if (!PocketPC)
syncContext = SynchronizationContext.Current;
#endif
clients = new List<IvyClient>();
bindings = new Dictionary<int, IvyApplicationBinding>();
app_bindings = new List<IvyApplicationBinding>();
- sent_messageFilter = new StringCollection();
+ sent_messageFilter = new List<string>();
#if (!PocketPC)
debug = Properties.Settings.Default.IvyDebug;
protocolVersion = Properties.Settings.Default.IvyProtocolVersion;
#endif
}
- public Ivy(System.Windows.Forms.ContainerControl parentControl)
+ public Ivy(IContainer container)
: this()
{
- this.parentControl = parentControl;
+ container.Add(this);
}
/// <summary> Readies the structures for the software bus connexion.
/// </summary>
@@ -403,7 +407,7 @@ namespace IvyBus
// Autobinding on IvyBindingAttribute method
public void AutoBinding(Assembly assy)
{
- foreach (Type typ in assy.GetExportedTypes())
+ foreach (Type typ in assy.GetTypes())
{
AutoBinding(typ);
}
@@ -746,37 +750,38 @@ namespace IvyBus
v[i].stream.TokenPing(message);
return v.Count;
}
-#if (SyncContext)
+#if (PocketPC)
internal virtual void FireEvent(EventHandler<IvyEventArgs> ev, IvyEventArgs e)
{
if (ev != null)
{
- if (syncContext != null)
+ if (parentControl != null)
{
- SendOrPostCallback update = delegate(object state)
- {
- IvyEventArgs args = (IvyEventArgs)state;
- ev(this, args);
- };
- syncContext.Send(update, e);
+ parentControl.Invoke(ev, this, e);
}
else
ev(this, e);
}
}
#else
- internal virtual void FireEvent(EventHandler<IvyEventArgs> ev, IvyEventArgs e)
+ internal virtual void FireEvent(EventHandler<IvyEventArgs> ev, IvyEventArgs e)
{
if (ev != null)
{
- if (parentControl != null)
+ if (syncContext != null)
{
- parentControl.Invoke(ev, this, e);
+ SendOrPostCallback update = delegate(object state)
+ {
+ IvyEventArgs args = (IvyEventArgs)state;
+ ev(this, args);
+ };
+ syncContext.Send(update, e);
}
else
ev(this, e);
}
}
+
#endif
internal virtual void OnDirectMessage(IvyEventArgs e)
{
@@ -828,26 +833,22 @@ namespace IvyBus
EventHandler<IvyEventArgs> temp = ErrorMessage;
FireEvent(temp, e);
}
-#if (SyncContext)
+#if (PocketPC)
internal virtual void OnDie(IvyDieEventArgs e)
{
// Copy to a temporary variable to be thread-safe.
EventHandler<IvyDieEventArgs> temp = DieReceived;
if (temp != null)
{
- if (syncContext != null)
+ if (parentControl != null)
{
- SendOrPostCallback update = delegate(object state)
- {
- IvyDieEventArgs args = (IvyDieEventArgs)state;
- temp(this, args);
- };
- syncContext.Send(update, e);
+ parentControl.Invoke(temp, this, e);
}
else
temp(this, e);
}
}
+
#else
internal virtual void OnDie(IvyDieEventArgs e)
{
@@ -855,9 +856,14 @@ namespace IvyBus
EventHandler<IvyDieEventArgs> temp = DieReceived;
if (temp != null)
{
- if (parentControl != null)
+ if (syncContext != null)
{
- parentControl.Invoke(temp, this, e);
+ SendOrPostCallback update = delegate(object state)
+ {
+ IvyDieEventArgs args = (IvyDieEventArgs)state;
+ temp(this, args);
+ };
+ syncContext.Send(update, e);
}
else
temp(this, e);
@@ -934,13 +940,13 @@ namespace IvyBus
}
return returnaddr;
}
-
+
public static string GetDomain(string domainbus)
{
-#if (PocketPC)
+#if (PocketPC) // TODO integrate in normal version
if (domainbus == null || domainbus.Length == 0)
{
- IPAddress addr = getLocalIP();
+ IPAddress addr = GetLocalIP();
//TODO Find Braodcast addr from IP;
byte[] bytes = addr.GetAddressBytes();
if (IPAddress.IsLoopback(addr))
@@ -957,7 +963,7 @@ namespace IvyBus
bytes[3] = 255;
}
IPAddress bcast = new IPAddress(bytes);
- domainbus = bcast + ":" + IvyWatcher.getPort(domainbus);
+ domainbus = bcast + ":" + Domain.getPort(domainbus);
}
#else
if (domainbus == null || domainbus.Length == 0 )
@@ -1088,7 +1094,7 @@ namespace IvyBus
{
return domainaddr + ":" + port;
}
- private static string getDomain(string net)
+ public static string getDomain(string net)
{
int sep_index = net.LastIndexOf(":");
if (sep_index != -1)
@@ -1109,7 +1115,7 @@ namespace IvyBus
return net;
}
- private static int getPort(string net)
+ public static int getPort(string net)
{
if (net == null) return Ivy.DEFAULT_PORT;
int sep_index = net.LastIndexOf(":");
@@ -1135,8 +1141,10 @@ namespace IvyBus
public void EndInit()
{
//TODO Autobinding attribute
+#if (PocketPC)
if (parentControl != null)
AutoBinding(parentControl);
+#endif
AutoBinding(Assembly.GetCallingAssembly());
// TODO ugly should be added directly the bindings Dictionary !
foreach (IvyApplicationBinding bind in app_bindings)