Hello everyone,

I am in the process of adapting our internal framework (for .NET 2.0)
to the .NET 2.0 CF (target is Windows CE 5.0).

So far, it is only a matter of removing stuff and using different
overloads, but now I got this problem:

We have a WeakMulticastDelegate class that we use in various places.
This class is just like a delegate, but the target is a WeakReference
instead. The problem I have is that there is no Target and Method
properties on delegates in .NET 2.0 CF. How can I replace them in this
code for example:

public WeakMulticastDelegate(Delegate strongDelegate)
{
 if (strongDelegate == null)
   throw new ArgumentNullException("strongDelegate");

 Delegate[] delegates = strongDelegate.GetInvocationList();

 if (delegates.Length > 0)
 {
   int start = 0;

   for (int i = 0; i < delegates.Length; i++, start++)
   {
     if (delegates[i] != null)
       break;
   }

   if (start == delegates.Length)
     throw new ArgumentException("No valid delegate in invocation
list.", "strongDelegate");

   if (delegates[start].Target != null)
     _weakTarget = new WeakReference(delegates[start].Target);

   _method = delegates[start].Method;

   WeakMulticastDelegate current = this;

   for (int i = start + 1; i < delegates.Length; i++)
   {
     if (delegates[i] != null)
     {
       current._next = new WeakMulticastDelegate(delegates[i].Target,
delegates[i].Method);
       current = current._next;
     }
   }
 }
}

Thanks !

Sébastien

--
Sébastien Lorion
Software Architect / Architecte organique
[EMAIL PROTECTED]

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to