~ubuntu-branches/ubuntu/karmic/mono-addins/karmic

« back to all changes in this revision

Viewing changes to Samples/TextEditor.CompilerService.CSharp/CSharpCompiler.cs

  • Committer: Bazaar Package Importer
  • Author(s): Mirco Bauer
  • Date: 2007-07-14 12:07:48 UTC
  • Revision ID: james.westby@ubuntu.com-20070714120748-2elczfsjlrdsrpms
Tags: upstream-0.2
ImportĀ upstreamĀ versionĀ 0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using System;
 
2
using System.IO;
 
3
using System.Diagnostics;
 
4
using Mono.Addins;
 
5
using TextEditor.CompilerService;
 
6
 
 
7
[assembly:Addin]
 
8
[assembly:AddinDependency ("TextEditor.CompilerService", "1.0")]
 
9
 
 
10
namespace TextEditor.CompilerService.CSharp
 
11
{
 
12
        [Extension]
 
13
        public class CSharpCompiler: ICompiler
 
14
        {
 
15
                public bool CanCompile (string file)
 
16
                {
 
17
                        return Path.GetExtension (file) == ".cs";
 
18
                }
 
19
                
 
20
                public string Compile (string file, string outFile) 
 
21
                {
 
22
                        string messages = "";
 
23
                        
 
24
                        ProcessStartInfo ps = new ProcessStartInfo ();
 
25
                        ps.FileName = "mcs";
 
26
                        ps.Arguments = "file";
 
27
                        ps.UseShellExecute = false;
 
28
                        ps.RedirectStandardOutput = true;
 
29
                        Process p = Process.Start (ps);
 
30
                        
 
31
                        string line = null;
 
32
                        while ((line = p.StandardOutput.ReadLine ()) != null) {
 
33
                                messages += line + "\n";
 
34
                        }
 
35
                        return messages;
 
36
                }
 
37
        }
 
38
}
 
 
b'\\ No newline at end of file'