2012-08-05 49 views
0

我遇到了一些問題,我堅持 - 我的類定義了自定義子集合,在實例化對象時得到實例化。是否可能在反序列化中告訴json.net不要實例化一個新的集合,而只是將反序列化的集合項添加到現有的集合中?我正在談論的代碼與下面類似,你可以看到我將一個函數傳遞給它用於構建和編譯表達式的集合的構造函數,我真的不想知道如何獲得該創建序列化程序中發生的邏輯。謝謝!在反序列化過程中將項目添加到現有列表中

public class ClassWithChildCollection 
{ 
    private CustomCollection<TestClass1> _childCollection; 

    public CustomCollection<TestClass1> ChildCollection 
    { 
     get 
     { 
     return _childCollection; 
     } 
    } 

    public ClassWithChildCollection() 
    { 
     _childCollection= new CustomCollection<TestClass1>(this, x => x.TestClass1Property); 
    } 
} 

回答

0

玉以及我覺得問這個了,因爲事實證明這是一個簡單的修復就有點傻了 - 剛剛設置ObjectCreationHandling在串行重用。哎呀!謝謝。