Create something like an insert code template?

Answered

When first implementing an explicit ISerializable  implementation it would be nice to generate a default implementation first. This feels like I could code a macro/code template/something to do this automatically but not sure where to start. I would want to grab all fields and implement a constructor like this

public $class(SerializationInfo info, StreamingContext context) {
$field0 = info.GetValue(nameof($field0), $field0);
// field1.. field2.. etc
}

and

public void GetObjectData(SerializationInfo info, StreamingContext context) {
info.AddValue(nameof($field0), $field0);
// field1.. field2.. etc
}

Is that possible? Any pointers to where to do it?
1 comment
Comment actions Permalink

Hi! 

Live Templates feature could help you. Please, let me know if you meet with any problems with it. 

0

Please sign in to leave a comment.