Conditional C# Binary Serialization

前端 未结 3 1475
小鲜肉
小鲜肉 2021-01-16 06:32

I am using BinaryFormatter to serialize a class and its variables by condition. For example:

[Serializable]
public class Class1
{
private Class2 B;
...
}

[S         


        
3条回答
  •  -上瘾入骨i
    2021-01-16 06:53

    I wrote a rather simple but extensible framework to solve this sort of problem using bindings. Not sure I completely understand but this is possible:

    public class Class1
    {
      [Ignore]
      public bool IsRemoting { get; set; }
    
      [SerializeWhen("IsRemoting", true)]
      public Class2 B;
    }
    

    http://binaryserializer.codeplex.com

提交回复
热议问题