Example #1
1
 public DisassembledIl Read(Pathname path)
 {
   using (StringWriter writer = new StringWriter())
   {
     using (StreamReader reader = new StreamReader(path.AsString))
     {
       foreach (string line in reader.Lines())
       {
         writer.WriteLine(line);
       }
     }
     return new DisassembledIl(writer.ToString());
   }
 }
 ///<summary>Streams the rows returned by the FileStream one at a time.</summary>
 public static IEnumerable<string> Lines(this FileStream me)
 {
     Contract.Requires(me != null);
     using(var reader = new StreamReader(me))
     {
         return reader.Lines().ToList();
     }
 }
Example #3
0
 public static IEnumerable <string> Lines(this FileInfo file)
 {
     using (var reader = new StreamReader(file.FullName))
     {
         foreach (var line in reader.Lines())
         {
             yield return(line);
         }
     }
 }
Example #4
0
 public static IEnumerable <string> Lines(this FsPath path)
 {
     using (var reader = new StreamReader(path))
     {
         foreach (var line in reader.Lines())
         {
             yield return(line);
         }
     }
 }
        // Decided it would be more efficient to use
        // the list of possible valid words from the dictionary and evaluate them then
        // against the keyboard Knight Move permutations using PLinq.
        private static string[] FindValidWords(Character[,] characterSet)
        {
            string fileName = @"..\..\Data\SINGLE.TXT";
            string[] filteredDictionary; // PLinq is more efficient with arrays.
            Keyboard board = new Keyboard(characterSet, SEARCH_DEPTH);

            using (StreamReader sr = new StreamReader(fileName))
            {
                filteredDictionary = sr.Lines().ToArray();
            }

            string[] finalWordList = (from word in filteredDictionary.AsParallel()
                                            .WithMergeOptions(ParallelMergeOptions.NotBuffered)
                                            .WithDegreeOfParallelism(Environment.ProcessorCount)
                                      where board.ValidateWord(new Word(word))
                                      select word).ToArray();

            return finalWordList;
        }
 /// <summary>
 /// Submits the form.
 /// </summary>
 protected override void ExecuteTask()
 {
     var wc = new WebClient();
     var nvc = CreateNameValueCollection(Fields);
     Log(Level.Info, "POSTing to '{0}' with {1} form fields.", Action, nvc.Count);
     var result = wc.UploadValues(Action, "POST", nvc);
     using (var resultStream = new MemoryStream(result))
     using (var sr = new StreamReader(resultStream))
     {
         foreach (var line in sr.Lines())
         {
             Log(Level.Verbose, line);
         }
     }
 }
        /// <summary>Get the content of hosts file (or host file profile) with the specified <paramref name="filePath"/>.</summary>
        /// <param name="filePath">The path to the hosts file or an host file profile.</param>
        /// <returns>All lines from the hostfile with the specified <paramref name="filePath"/>.</returns>
        public List<string> GetHostfileContent(string filePath)
        {
            this.VerifyFile(filePath);

            using (var stream = new StreamReader(filePath))
            {
                return (from line in stream.Lines() select line).ToList();
            }
        }
Example #8
0
 public void LinesTest()
 {
     using (var sr = new StreamReader(_testStringsFile, true))
     Assert.AreEqual(sr.Lines().Count(), 10);
 }