Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Custom Events

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Zeos6
    replied
    Hi ChelseaB,

    Thank you for the follow up. I am aware of the object class. I was simply passing a strongly typed list, and was unpacking it via casting. Indexers allow instances of a class, struct, list, etc. to be indexed just like arrays. So a first element of a list called myList can be accessed as myList[0] (or myList.ElementAt(0)).

    My issue was simply that I forgot to cast the object back to a list before accesing it's elements and casting those elements to their respective types.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello Zeos6,

    What are you passing this? This will only take an object.

    Below is a link to a microsoft site on the object class.

    https://msdn.microsoft.com/en-us/lib...vs.110%29.aspx

    You could have that object contain a indexer... (by indexer is this a method that sorts something)?

    Leave a comment:


  • Zeos6
    replied
    Thank you for the response Chelsea but you are not answering the question. If the object is ANY object, as you state, why does it not support an indexer?

    *** EDIT ****

    Figured it out. My apologies Chelsea. It was simply a casting issue on my end. Thank you for the confirmation that the object can be anything.
    Last edited by Zeos6; 03-16-2015, 11:48 AM.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello Zeos6,

    Object is any object you want to pass to your custom method.

    State is just the variable name used in the example but this is really any thing you want to pass.

    Leave a comment:


  • Zeos6
    started a topic Custom Events

    Custom Events

    HI

    I currently wrote a custom event handler. My question deals with the

    TriggerCustomEvent(CustomEvent customEvent, int barsIndex, object state)


    Can you please clarify the nature of the state object. I have tried using an object array, and i have tried isung a strongly-typed list. In both cases the issue seemed to be that indexing was not supported. I have even tried using the ElementAt method with the list but not extension method of that type was provided. Clearly there are some severe restrictions on the nature of the object. Can you please suggest a way to pass more than a simple refernce type as the state? Thank you.

Latest Posts

Collapse

Topics Statistics Last Post
Started by vivek.n, Today, 03:19 AM
0 responses
4 views
0 likes
Last Post vivek.n
by vivek.n
 
Started by ashwagandhaplus, Today, 12:04 AM
0 responses
6 views
0 likes
Last Post ashwagandhaplus  
Started by ashwagandhaplus, Today, 12:02 AM
0 responses
9 views
0 likes
Last Post ashwagandhaplus  
Started by truvalastfrnce, Today, 12:01 AM
0 responses
5 views
0 likes
Last Post truvalastfrnce  
Started by truvalastfrnce, Today, 12:00 AM
0 responses
4 views
0 likes
Last Post truvalastfrnce  
Working...
X