Skip to content

Commit

Permalink
COM: added helper methods for saving bytes to files in IProtocolDocument
Browse files Browse the repository at this point in the history
  • Loading branch information
asvyazin committed May 10, 2017
1 parent ce32da5 commit 155c859
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/Proto/Documents/DocumentProtocol.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Runtime.InteropServices;
using System;
using System.IO;
using System.Runtime.InteropServices;

namespace Diadoc.Api.Proto.Documents
{
Expand All @@ -8,6 +10,8 @@ public interface IDocumentProtocol
{
byte[] PrintForm { get; }
byte[] Signature { get; }
void SavePrintFormToFile(string path);
void SaveSignatureToFile(string path);
}

[ComVisible(true)]
Expand All @@ -16,6 +20,25 @@ public interface IDocumentProtocol
[ComDefaultInterface(typeof(IDocumentProtocol))]
public partial class DocumentProtocol: SafeComObject, IDocumentProtocol
{
public void SavePrintFormToFile(string path)
{
if (PrintForm == null)
{
throw new Exception("There is no content to save");
}

File.WriteAllBytes(path, PrintForm);
}

public void SaveSignatureToFile(string path)
{
if (Signature == null)
{
throw new Exception("There is no content to save");
}

File.WriteAllBytes(path, Signature);
}
}

[ComVisible(true)]
Expand Down

0 comments on commit 155c859

Please sign in to comment.