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 Hwop38, 05-04-2026, 07:02 PM
    0 responses
    164 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    318 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    246 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    350 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    179 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Working...
    X