예제 #1
0
        public void Constructor2_Deny_Unrestricted()
        {
            TempFileCollection tfc = new TempFileCollection(temp, true);

            Assert.AreEqual(0, tfc.Count, "Count");
            Assert.IsTrue(tfc.KeepFiles, "KeepFiles");
            Assert.AreEqual(temp, tfc.TempDir, "TempDir");
            tfc.AddFile("main.cs", false);
            tfc.CopyTo(array, 0);
            tfc.Delete();
            (tfc as IDisposable).Dispose();
        }
예제 #2
0
        public void CopyTo()
        {
            using (var collection = new TempFileCollection())
            {
                const int    ArrayIndex = 1;
                const string FileName   = "File";
                collection.AddFile(FileName, keepFile: false);

                var array = new string[ArrayIndex + collection.Count];
                collection.CopyTo(array, ArrayIndex);

                Assert.Null(array[0]);
                Assert.Equal(FileName, array[ArrayIndex]);
            }
        }
예제 #3
0
        private CompilerResults CompileAssemblyFromReader(CompilerParameters options, params TextReader[] readers)
        {
            var tempFiles = new TempFileCollection(Path.GetTempPath(), false);

            for (int i = 0; i < readers.Length; i++)
            {
                string file = tempFiles.AddExtension(FileExtension, false);
                File.WriteAllText(file, readers[i].ReadToEnd());
            }

            var fileNames = new string[tempFiles.Count];

            tempFiles.CopyTo(fileNames, 0);
            var results = CompileAssemblyFromFile(options, fileNames);

            tempFiles.Delete();
            return(results);
        }