public static void Serialize( Stream stream, XKey key ) { if( stream == null ) { throw new ArgumentNullException( "stream" ); } if( key == null ) { throw new ArgumentNullException( "key" ); } Contract.EndContractBlock(); using( var writer = new KeyValuePairWriter( stream, true ) ) { foreach( var pair in key ) { writer.Write( pair ); } writer.WriteEpilogue(); } }
public static void Serialize( BinaryWriter binaryWriter, XKey key ) { if( binaryWriter == null ) { throw new ArgumentNullException( "binaryWriter" ); } if( key == null ) { throw new ArgumentNullException( "key" ); } Contract.EndContractBlock(); using( var writer = new KeyValuePairWriter( binaryWriter ) ) { foreach( var pair in key ) { writer.Write( pair ); } writer.WriteEpilogue(); } }
public static string Serialize( XKey key ) { if( key == null ) { throw new ArgumentNullException( "key" ); } Contract.Ensures( Contract.Result<string>() != null ); using( var stream = new MemoryStream() ) { using( var writer = new KeyValuePairWriter( stream ) ) { foreach( var pair in key ) { writer.Write( pair ); } writer.WriteEpilogue(); } return Convert.ToBase64String( stream.ToArray() ); } }