Results 1 to 5 of 5

Thread: Trying to refactor this code and hit a wall. [resolved]

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2001
    Location
    Garden Grove, CA
    Posts
    72

    Trying to refactor this code and hit a wall. [resolved]

    Here is a sample of the code I am refactoring it works great as is, but I don't want to write (copy/paste/change) this code for every time I need it.

    VB Code:
    1. Public Sub RaiseSendMessageEvent(ByVal e As DocGenCommon.DocGen.DocGenEventArgs)
    2.  
    3.         For Each del As [Delegate] In SendMessageEvent.GetInvocationList()
    4.             Try
    5.                 del.Method.Invoke(del.Target, New Object() {e})
    6.             Catch
    7.                 SendMessageEvent = DirectCast(System.Delegate.Remove(SendMessageEvent, del), IDocGenEventServer.SendMessageHandler)
    8.             End Try
    9.         Next
    10.  
    11.     End Sub

    So far I have gotten this far and my problem is I cannot pass in the Type to the directcast statement.

    VB Code:
    1. Public Sub RaiseRemotedEvent(ByVal sender As [Delegate], ByVal eventtype As Type, ByVal e As DocGenCommon.DocGen.DocGenEventArgs)
    2.  
    3.         For Each del As [Delegate] In sender.GetInvocationList()
    4.             Try
    5.                 del.Method.Invoke(del.Target, New Object() {e})
    6.             Catch
    7.                 ' this is where the error is "Type 'eventtype' is not defined."
    8.                 sender = DirectCast(System.Delegate.Remove(sender, del), eventtype)
    9.             End Try
    10.         Next
    11.  
    12.     End Sub

    Any suggestions?
    Last edited by TType85; Jun 16th, 2005 at 02:00 PM.
    Chris Wilson

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width