コード例 #1
0
 public static string WriteFile(IIntermediateProject project, IIntermediateCodeTranslator translator, TemporaryDirectory td, TempFileCollection tfc, Stack <IIntermediateProject> partialCompletions, IDeclaredType target, string extension, string tabString = "    ")
 {
     if (td == null)
     {
         throw new ArgumentNullException("td");
     }
     if (!partialCompletions.Contains(target.Project))
     {
         bool autoResolveRefs = translator.Options.AutoResolveReferences;
         translator.Options.AutoResolveReferences = false;
         var      folderName = GetFolderName(target);
         var      tempDir    = td;
         string[] folders    = folderName.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries);
         foreach (var item in folders)
         {
             tempDir = tempDir.Directories.GetTemporaryDirectory(item);
         }
         TemporaryFile tf = tempDir.Files.GetTemporaryFile(string.Format("{0}{1}", GetTargetFullName(target), extension));
         tfc.AddFile(tf.FileName, tfc.KeepFiles);
         translator.Options.AutoResolveReferences = autoResolveRefs;
         //If it's segmentable, there's going to be multiple files...
         tf.OpenStream(FileMode.Create);
         translator.Target = new IndentedTextWriter(new StreamWriter(tf.FileStream, Encoding.Unicode), tabString);
         translator.TranslateProject(target.Project);
         translator.Target.Flush();
         tf.CloseStream();
         partialCompletions.Push(target.Project);
         return(tf.FileName);
     }
     return(null);
 }
コード例 #2
0
        private static string WriteAttributeFile(IIntermediateProject project, IIntermediateCodeTranslator translator, TemporaryDirectory td, TempFileCollection tfc, Stack <IIntermediateProject> partialCompletions, string extension, string tabString)
        {
            if (td == null)
            {
                throw new ArgumentNullException("td");
            }
            var root = project;

            if (!root.IsRoot)
            {
                root = root.GetRootDeclaration();
            }
            if (!partialCompletions.Contains(root))
            {
                bool autoResolveRefs = translator.Options.AutoResolveReferences;
                translator.Options.AutoResolveReferences = false;
                TemporaryFile tf = td.Directories.GetTemporaryDirectory(root.RootModule.Name).Files.GetTemporaryFile(string.Format("AssemblyInfo{0}", extension));
                tfc.AddFile(tf.FileName, false);
                translator.Options.AutoResolveReferences = autoResolveRefs;
                tf.OpenStream(FileMode.Create);
                translator.Target = new IndentedTextWriter(new StreamWriter(tf.FileStream), tabString);
                translator.TranslateProject(root);
                translator.Target.Flush();
                partialCompletions.Push(root);
                tf.CloseStream();
                return(tf.FileName);
            }
            return(null);
        }