diff options
author | Adam Frisby | 2007-06-28 08:35:41 +0000 |
---|---|---|
committer | Adam Frisby | 2007-06-28 08:35:41 +0000 |
commit | 17275f3ab7db6bbcea54c1e88eb05664189af0a6 (patch) | |
tree | 99fcea504aa969d39b83d44ba00d7b24b20e0719 /OpenSim/OpenSim.Region/Scenes/scripting/CSharpScriptEngine.cs | |
parent | * Removing stuff piecemeal since Tortoise SVN blows. (diff) | |
download | opensim-SC_OLD-17275f3ab7db6bbcea54c1e88eb05664189af0a6.zip opensim-SC_OLD-17275f3ab7db6bbcea54c1e88eb05664189af0a6.tar.gz opensim-SC_OLD-17275f3ab7db6bbcea54c1e88eb05664189af0a6.tar.bz2 opensim-SC_OLD-17275f3ab7db6bbcea54c1e88eb05664189af0a6.tar.xz |
* More removing stuff. Tortoise SVN I hate you.
Diffstat (limited to 'OpenSim/OpenSim.Region/Scenes/scripting/CSharpScriptEngine.cs')
-rw-r--r-- | OpenSim/OpenSim.Region/Scenes/scripting/CSharpScriptEngine.cs | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/OpenSim/OpenSim.Region/Scenes/scripting/CSharpScriptEngine.cs b/OpenSim/OpenSim.Region/Scenes/scripting/CSharpScriptEngine.cs deleted file mode 100644 index d5622b8..0000000 --- a/OpenSim/OpenSim.Region/Scenes/scripting/CSharpScriptEngine.cs +++ /dev/null | |||
@@ -1,77 +0,0 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | |||
5 | // Compilation stuff | ||
6 | using System.CodeDom; | ||
7 | using System.CodeDom.Compiler; | ||
8 | using Microsoft.CSharp; | ||
9 | |||
10 | namespace OpenSim.Scripting | ||
11 | { | ||
12 | public class CSharpScriptEngine : IScriptCompiler | ||
13 | { | ||
14 | public string fileExt() | ||
15 | { | ||
16 | return ".cs"; | ||
17 | } | ||
18 | |||
19 | private Dictionary<string,IScript> LoadDotNetScript(ICodeCompiler compiler, string filename) | ||
20 | { | ||
21 | CompilerParameters compilerParams = new CompilerParameters(); | ||
22 | CompilerResults compilerResults; | ||
23 | compilerParams.GenerateExecutable = false; | ||
24 | compilerParams.GenerateInMemory = true; | ||
25 | compilerParams.IncludeDebugInformation = false; | ||
26 | compilerParams.ReferencedAssemblies.Add("OpenSim.Region.dll"); | ||
27 | compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll"); | ||
28 | compilerParams.ReferencedAssemblies.Add("libsecondlife.dll"); | ||
29 | compilerParams.ReferencedAssemblies.Add("System.dll"); | ||
30 | |||
31 | compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename); | ||
32 | |||
33 | if (compilerResults.Errors.Count > 0) | ||
34 | { | ||
35 | OpenSim.Framework.Console.MainLog.Instance.Error("Compile errors"); | ||
36 | foreach (CompilerError error in compilerResults.Errors) | ||
37 | { | ||
38 | OpenSim.Framework.Console.MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString()); | ||
39 | } | ||
40 | } | ||
41 | else | ||
42 | { | ||
43 | Dictionary<string,IScript> scripts = new Dictionary<string,IScript>(); | ||
44 | |||
45 | foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes()) | ||
46 | { | ||
47 | Type testInterface = pluginType.GetInterface("IScript", true); | ||
48 | |||
49 | if (testInterface != null) | ||
50 | { | ||
51 | IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString()); | ||
52 | |||
53 | string scriptName = "C#/" + script.getName(); | ||
54 | Console.WriteLine("Script: " + scriptName + " loaded."); | ||
55 | |||
56 | if (!scripts.ContainsKey(scriptName)) | ||
57 | { | ||
58 | scripts.Add(scriptName, script); | ||
59 | } | ||
60 | else | ||
61 | { | ||
62 | scripts[scriptName] = script; | ||
63 | } | ||
64 | } | ||
65 | } | ||
66 | return scripts; | ||
67 | } | ||
68 | return null; | ||
69 | } | ||
70 | |||
71 | public Dictionary<string,IScript> compile(string filename) | ||
72 | { | ||
73 | CSharpCodeProvider csharpProvider = new CSharpCodeProvider(); | ||
74 | return LoadDotNetScript(csharpProvider.CreateCompiler(), filename); | ||
75 | } | ||
76 | } | ||
77 | } | ||