예제 #1
0
        /// <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);
        }
예제 #2
0
        /// <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;
        }
예제 #4
0
 public DocumentLuceneBaseSearchProvider(IFileContentReader fileContentReader)
 {
     setFileReader(fileContentReader);
 }
예제 #5
0
 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);
 }
예제 #7
0
 public void setFileReader(IFileContentReader reader)
 {
     _reader = reader;
 }