/// <summary> /// Returns file content as stream. /// </summary> /// <returns>File content as stream.</returns> public static Stream GetContentAsStream(this IFileContentReader file) { Ensure.NotNull(file, "file"); Task <Stream> task = file.GetContentAsStreamAsync(); if (!task.IsCompleted && !task.IsCanceled) { task.RunSynchronously(); } return(task.Result); }
/// <summary> /// Returns file content as byte array. /// </summary> /// <returns>File content as byte array.</returns> public static byte[] GetContentAsByteArray(this IFileContentReader file) { Ensure.NotNull(file, "file"); Task <byte[]> task = file.GetContentAsByteArrayAsync(); if (!task.IsCompleted && !task.IsCanceled) { task.RunSynchronously(); } return(task.Result); }
/// <summary> /// Initializes a new Instance /// </summary> /// <param name="comPort">COM Port</param> /// <param name="filename">Payload path</param> /// <param name="fileEncoding">Payload Encoding</param> public BtSppPrinter(SerialPort comPort, string filename, Encoding fileEncoding) { if (comPort == null) { throw new ArgumentNullException("comPort", "comPort cannot be null"); } if (string.IsNullOrEmpty(filename)) { throw new ArgumentException("filename cannot be empty or null", "filename"); } if (fileEncoding == null) { throw new ArgumentNullException("encoding", "encoding cannot be null"); } this.SerialPort = comPort; this.fileReader = new FileContentReader(filename); this.CurrentEncoding = fileEncoding; this.PersistConnection = false; }
public DocumentLuceneBaseSearchProvider(IFileContentReader fileContentReader) { setFileReader(fileContentReader); }
public static bool TryWithFileContentReader(this IFile model, out IFileContentReader feature) { Ensure.NotNull(model, "model"); return(model.TryWith <IFileContentReader>(out feature)); }
/// <summary> /// Initiliazies a new Instance /// </summary> /// <param name="reader">Content reader</param> /// <param name="parameters">Parameters</param> public BtSppPrinter(IFileContentReader reader, IContentParameters parameters) { this.fileReader = reader; this.parameters = parameters; this.replacer = new ContentReplacer(this.parameters); }
public void setFileReader(IFileContentReader reader) { _reader = reader; }