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 kinfxhk, 07-13-2026, 10:18 AM
    0 responses
    28 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 09:50 AM
    0 responses
    17 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 07:21 AM
    0 responses
    26 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-11-2026, 02:11 AM
    0 responses
    24 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    139 views
    0 likes
    Last Post SalmaTrader  
    Working...
    X