예제 #1
0
        public void ContentReplacerConstructorTest1()
        {
            IContentParameters contentParameters = null; // TODO: Initialize to an appropriate value
            ContentReplacer    target            = new ContentReplacer(contentParameters);

            Assert.Inconclusive("TODO: Implement code to verify target");
        }
        public void Print(FileInfo filename, Encoding fileEncoding, IContentParameters parameters)
        {
            if (filename == null)
            {
                throw new ArgumentNullException("filename cannot be null", "filename");
            }

            if (fileEncoding == null)
            {
                throw new ArgumentNullException("encoding", "encoding cannot be null");
            }

            if (parameters == null)
            {
                throw new ArgumentNullException("parameters", "parameters cannot be null");
            }

            this.CurrentEncoding = fileEncoding;

            IFileContentReader fileReader = new FileContentReader(filename.Name);

            var readedBytes = fileReader.ReadAllAsByte();

            IContentReplacer replacer = new ContentReplacer(parameters, fileEncoding);

            var result = replacer.Replace(readedBytes);

            if (result != null)
            {
                Print(result);
            }
        }
        /// <summary>
        /// Writes contents of toPrint to designated Port based on parameters
        /// </summary>
        /// <param name="filename">Payload path</param>
        /// <param name="fileEncoding">Read encoding</param>
        /// <param name="parameters">Parameters</param>
        public void Print(string filename, Encoding fileEncoding, IContentParameters parameters)
        {
            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");
            }

            if (parameters == null)
            {
                throw new ArgumentNullException("parameters", "parameters cannot be null");
            }

            this.CurrentEncoding = fileEncoding;

            var readedBytes = fileReader.ReadAllAsByte(filename);

            IContentReplacer replacer = new ContentReplacer(parameters);

            var result = replacer.Replace(readedBytes);

            if (result != null)
            {
                Print(result);
            }
        }
예제 #4
0
        /// <summary>
        /// Creates a new Instance of ContentReplacer with given parameters
        /// </summary>
        /// <param name="contentParameters">Parameters</param>
        public ContentReplacer(IContentParameters contentParameters)
        {
            if (contentParameters == null)
            {
                throw new ArgumentNullException("contentParameters", "contentParameters cannot be null");
            }

            this.ContentParameters = contentParameters;
        }
        /// <summary>
        /// Writes contents of toPrint to designated Port based on parameters
        /// </summary>
        /// <param name="toPrint"></param>
        /// <param name="parameters"></param>
        public void Print(string toPrint, IContentParameters parameters)
        {
            if (string.IsNullOrEmpty(toPrint))
            {
                throw new ArgumentException("toPrint cannot be empty or null", "toPrint");
            }

            if (parameters == null)
            {
                throw new ArgumentNullException("parameters", "parameters cannot be null");
            }
        }
예제 #6
0
        public void ReplaceTest1()
        {
            ContentReplacer target = new ContentReplacer(); // TODO: Initialize to an appropriate value

            byte[]             source            = null;    // TODO: Initialize to an appropriate value
            IContentParameters contentParameters = null;    // TODO: Initialize to an appropriate value

            byte[] expected = null;                         // TODO: Initialize to an appropriate value
            byte[] actual;
            actual = target.Replace(source, contentParameters);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
예제 #7
0
        /// <summary>
        /// Creates a new Instance of ContentReplacer with given parameters and encoding
        /// </summary>
        /// <param name="contentParameters">Parameters</param>
        /// <param name="encoding">Encoding</param>
        public ContentReplacer(IContentParameters contentParameters, Encoding encoding)
        {
            if (contentParameters == null)
            {
                throw new ArgumentNullException("contentParameters", "contentParameters cannot be null");
            }
            if (encoding == null)
            {
                throw new ArgumentNullException("encoding", "encoding cannot be null");
            }

            this.ContentParameters = contentParameters;
            this.Encoding          = encoding;
        }
예제 #8
0
        /// <summary>
        /// Replaces source contens with given parameter values
        /// </summary>
        /// <param name="source">Source</param>
        /// <param name="contentParameters">Content paramaters</param>
        /// <returns>Replaced source content</returns>
        public byte[] Replace(byte[] source, IContentParameters contentParameters)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source", "source cannot be null");
            }

            if (contentParameters == null)
            {
                throw new ArgumentNullException("contentParameters", "contentParameters cannot be null");
            }

            foreach (var param in contentParameters.Parameters)
            {
                source = ReplaceFirstOccurance(source, param.Key, param.Value);
            }

            return(source);
        }
        public void Print(byte[] toPrint, IContentParameters parameters)
        {
            if (toPrint == null)
            {
                throw new ArgumentNullException("toPrint", "toPrint cannot be null");
            }
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters", "parameters cannot be null");
            }

            IContentReplacer replacer = new ContentReplacer(parameters);

            var result = replacer.Replace(toPrint);

            if (result != null)
            {
                Print(result);
            }
        }
        public void Print(string toPrint, IContentParameters parameters)
        {
            IContentReplacer replacer = new ContentReplacer(parameters);

            Print(replacer.Replace(CurrentEncoding.GetBytes(toPrint)));
        }
 public void BeginPrint(FileInfo payloadFile, Encoding fileEncoding, IContentParameters parameters)
 {
     throw new NotImplementedException();
 }
 public void BeginPrint(byte[] toBeginPrint, IContentParameters parameters)
 {
     throw new NotImplementedException();
 }
        public void BeginPrint(FileInfo payloadFile, Encoding fileEncoding, IContentParameters parameters)
        {
            var t = new Thread(() => Print(payloadFile, fileEncoding, parameters));

            t.Start();
        }
        public void BeginPrint(byte[] toPrint, IContentParameters parameters)
        {
            var t = new Thread(() => Print(toPrint, parameters));

            t.Start();
        }
 /// <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);
 }