Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Serialization question

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

    Serialization question

    I have developed an indicator that uses a lot of dictionaries. I have to do a lot of merging copying dictionaries.....

    Now I have created a method to copy one dictionary to another :

    This is an extension method..

    publicstatic T DeepClone<T>(this T a)
    {
    using (MemoryStream stream = new MemoryStream())
    {
    BinaryFormatter formatter =
    new BinaryFormatter();
    formatter.Serialize(stream, a);
    stream.Position =
    0;
    return (T)formatter.Deserialize(stream);
    }
    }


    Now I have to copy (DeepClone()) one dictionary that contains an object. Here is the class :

    internalclass items
    {
    publicdouble up=0;
    publicdouble down=0;
    publicint dailyBars=0;
    }

    I get a message that items is not marked as serializable...

    What do I have to do to serialize this object (items)...


    I just put [Serializable()] in front of the class but didn't work..

    Thank you




    #2
    Unfortunately this is a more advanced C# question than the scope of what we can support. The general idea of how to serialize objects can be seen here though: http://www.ninjatrader.com/support/f...ead.php?t=4977
    Josh P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    80 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    40 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    63 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    63 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    54 views
    0 likes
    Last Post CarlTrading  
    Working...
    X