本文整理汇总了C#中Mono.CSharp.CompilerSettings类的典型用法代码示例。如果您正苦于以下问题:C# CompilerSettings类的具体用法?C# CompilerSettings怎么用?C# CompilerSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CompilerSettings类属于Mono.CSharp命名空间,在下文中一共展示了CompilerSettings类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: InitializeEvaluator
private static void InitializeEvaluator()
{
_Interop.VarStorage["ReplVersion"] = typeof(Program).Assembly.GetName().Version;
var settings = new CompilerSettings() {
StdLib = true
};
var reportPrinter = new ConsoleReportPrinter();
var ctx = new CompilerContext(settings, reportPrinter);
evaluator = new Evaluator(ctx);
evaluator.ReferenceAssembly(typeof(_Interop).Assembly);
evaluator.Run(
@"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
");
evaluator.Run("var _v = _Interop.VarStorage;");
evaluator.Run("var _h = _Interop.History;");
evaluator.Run("_Interop.VoidMethod exit = _Interop.Exit;");
evaluator.Run("_Interop.ReturnStringListMethod globals = _Interop.GetGlobals");
}
开发者ID:mkaput,项目名称:csrepl,代码行数:29,代码来源:Program.cs
示例2: CSharpCompiler
public CSharpCompiler()
{
CompilerSettings settings = new CompilerSettings ();
Report report = new Report (new NullReportPrinter ());
evaluator = new Evaluator (settings, report);
}
开发者ID:syoubin,项目名称:gbrainy_android,代码行数:7,代码来源:CSharpCompiler.cs
示例3: Run
public int Run()
{
// Enable unsafe code by default
var settings = new CompilerSettings () {
Unsafe = true
};
var startup_files = new string [0];
settings.SourceFiles.Clear ();
ReportPrinter printer= new ConsoleReportPrinter ();
var eval = new Evaluator (new CompilerContext (settings, printer));
eval.InteractiveBaseClass = typeof (InteractiveBaseShell);
eval.DescribeTypeExpressions = true;
eval.WaitOnTask = true;
CSharpShell shell;
#if !ON_DOTNET
if (attach.HasValue) {
shell = new ClientCSharpShell (eval, attach.Value);
} else if (agent != null) {
new CSharpAgent (eval, agent, agent_stderr).Run (startup_files);
return 0;
} else
#endif
{
shell = new CSharpShell (eval, console);
}
return shell.Run (startup_files);
}
开发者ID:stangelandcl,项目名称:csharp-repl,代码行数:29,代码来源:repl.cs
示例4: Create
public static DynamicContext Create ()
{
if (dc != null)
return dc;
lock (compiler_initializer) {
if (dc != null)
return dc;
var reporter = new Compiler.Report (ErrorPrinter.Instance) {
WarningLevel = 0
};
var settings = new Compiler.CompilerSettings ();
var cc = new Compiler.CompilerContext (settings, reporter) {
IsRuntimeBinder = true
};
//IList<Compiler.PredefinedTypeSpec> core_types = null;
//// HACK: To avoid re-initializing static TypeManager types, like string_type
//if (!Compiler.RootContext.EvalMode) {
// core_types = Compiler.TypeManager.InitCoreTypes ();
//}
//
// Any later loaded assemblies are handled internally by GetAssemblyDefinition
// domain.AssemblyLoad cannot be used as that would be too destructive as we
// would hold all loaded assemblies even if they can be never visited
//
// TODO: Remove this code and rely on GetAssemblyDefinition only
//
var module = new Compiler.ModuleContainer (cc);
module.HasTypesFullyDefined = true;
var temp = new Compiler.AssemblyDefinitionDynamic (module, "dynamic");
module.SetDeclaringAssembly (temp);
// Import all currently loaded assemblies
var domain = AppDomain.CurrentDomain;
temp.Create (domain, System.Reflection.Emit.AssemblyBuilderAccess.Run);
var importer = new Compiler.ReflectionImporter (module, cc.BuiltinTypes) {
IgnorePrivateMembers = false
};
foreach (var a in AppDomain.CurrentDomain.GetAssemblies ()) {
importer.ImportAssembly (a, module.GlobalRootNamespace);
}
cc.BuiltinTypes.CheckDefinitions (module);
module.InitializePredefinedTypes ();
dc = new DynamicContext (module, importer);
}
return dc;
}
开发者ID:ngraziano,项目名称:mono,代码行数:57,代码来源:DynamicContext.cs
示例5: Compiler
/// <summary>
/// Initializes a new instance of the <see cref="Dynamic.Compiler"/> class.
/// </summary>
/// <param name="project">Project.</param>
public Compiler(Project project)
{
Project = project;
Settings = new CompilerSettings()
{
OutputFile = "DynamicCodeTests-Scene.dll"
};
// Settings.AssemblyReferences.Remove("system.dll");
Trace.Log(TraceEventType.Information, "Project=\"{0}\"\nSettings:\n{1}", project.Name, Settings.ToString());
}
开发者ID:jbowwww,项目名称:JGL,代码行数:14,代码来源:Compiler.cs
示例6: Setup
public void Setup()
{
var builder = new StringBuilder();
var writer = new StringWriter(builder);
var printer = new StreamReportPrinter(writer);
var settings = new CompilerSettings();
settings.AssemblyReferences.Add("DbTool.Testing");
var context = new CompilerContext(settings, printer);
_evaluator = new Evaluator(context);
}
开发者ID:pedershk,项目名称:dotnetprograms,代码行数:11,代码来源:EvaluatorTest.cs
示例7: Create
public static DynamicContext Create ()
{
if (dc != null)
return dc;
lock (compiler_initializer) {
if (dc != null)
return dc;
var settings = new Compiler.CompilerSettings () {
WarningLevel = 0
};
var cc = new Compiler.CompilerContext (settings, ErrorPrinter.Instance) {
IsRuntimeBinder = true
};
//
// Any later loaded assemblies are handled internally by GetAssemblyDefinition
// domain.AssemblyLoad cannot be used as that would be too destructive as we
// would hold all loaded assemblies even if they can be never visited
//
// TODO: Remove this code and rely on GetAssemblyDefinition only
//
var module = new Compiler.ModuleContainer (cc);
module.HasTypesFullyDefined = true;
// Setup fake assembly, it's used mostly to simplify checks like friend-access
var temp = new Compiler.AssemblyDefinitionDynamic (module, "dynamic");
module.SetDeclaringAssembly (temp);
var importer = new Compiler.ReflectionImporter (module, cc.BuiltinTypes) {
IgnorePrivateMembers = false,
IgnoreCompilerGeneratedField = false
};
// Import all currently loaded assemblies
// TODO: Rewrite this to populate type cache on-demand, that should greatly
// reduce our start-up cost
var domain = AppDomain.CurrentDomain;
foreach (var a in AppDomain.CurrentDomain.GetAssemblies ()) {
importer.ImportAssembly (a, module.GlobalRootNamespace);
}
cc.BuiltinTypes.CheckDefinitions (module);
module.InitializePredefinedTypes ();
dc = new DynamicContext (module, importer);
}
return dc;
}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:52,代码来源:DynamicContext.cs
示例8: Evaluator
public Evaluator (CompilerSettings settings, Report report)
{
ctx = new CompilerContext (settings, report);
module = new ModuleContainer (ctx);
module.Evaluator = this;
// FIXME: Importer needs this assembly for internalsvisibleto
module.SetDeclaringAssembly (new AssemblyDefinitionDynamic (module, "evaluator"));
importer = new ReflectionImporter (module, ctx.BuildinTypes);
InteractiveBaseClass = typeof (InteractiveBase);
fields = new Dictionary<string, Tuple<FieldSpec, FieldInfo>> ();
}
开发者ID:famousthom,项目名称:monodevelop,代码行数:14,代码来源:eval.cs
示例9: Main
static int Main (string [] args)
{
var cmd = new CommandLineParser (Console.Out);
cmd.UnknownOptionHandler += HandleExtraArguments;
// Enable unsafe code by default
var settings = new CompilerSettings () {
Unsafe = true
};
if (!cmd.ParseArguments (settings, args))
return 1;
var startup_files = new string [settings.SourceFiles.Count];
int i = 0;
foreach (var source in settings.SourceFiles)
startup_files [i++] = source.FullPathName;
settings.SourceFiles.Clear ();
TextWriter agent_stderr = null;
ReportPrinter printer;
if (agent != null) {
agent_stderr = new StringWriter ();
printer = new StreamReportPrinter (agent_stderr);
} else {
printer = new ConsoleReportPrinter ();
}
var eval = new Evaluator (new CompilerContext (settings, printer));
eval.InteractiveBaseClass = typeof (InteractiveBaseShell);
eval.DescribeTypeExpressions = true;
eval.WaitOnTask = true;
CSharpShell shell;
#if !ON_DOTNET
if (attach.HasValue) {
shell = new ClientCSharpShell (eval, attach.Value);
} else if (agent != null) {
new CSharpAgent (eval, agent, agent_stderr).Run (startup_files);
return 0;
} else
#endif
{
shell = new CSharpShell (eval);
}
return shell.Run (startup_files);
}
开发者ID:GirlD,项目名称:mono,代码行数:48,代码来源:repl.cs
示例10: Init
public void Init()
{
var printer = new StreamReportPrinter(_stringWriter);
var settings = new CompilerSettings();
settings.AssemblyReferences.AddRange(InitialAssemblies);
var context = new CompilerContext(settings, printer);
_evaluator = new Evaluator(context)
{
InteractiveBaseClass = typeof (DbToolInteractive),
DescribeTypeExpressions = true,
};
ReferenceAssemblies(typeof(Database).Assembly, typeof(DynamicSqlQuery).Assembly);
Using(InitialUsings);
DbToolInteractive.Evaluator = _evaluator;
DbToolInteractive.Output = _stringWriter;
}
开发者ID:pedershk,项目名称:dotnetprograms,代码行数:17,代码来源:MonoCSharpEvaluator.cs
示例11: CreateContext
private CompilerContext CreateContext([NotNull] string source)
{
var settings = new CompilerSettings
{
Target = Target.Library,
TargetExt = ".dll",
LoadDefaultReferences = true,
ShowFullPaths = false,
StdLib = true,
};
var context = new CompilerContext(settings, new ConsoleReportPrinter(_logger));
context.SourceFiles.Add(new SourceFile("Source", source, 0));
_report = new Report(context, new ConsoleReportPrinter(_logger));
return context;
}
开发者ID:Tauron1990,项目名称:Radio-Streamer,代码行数:18,代码来源:StyleScriptCompiler.cs
示例12: evaluateCode
// This method evaluates the given code and returns a CompilerOutput object
public static CompilerOutput evaluateCode(string code)
{
CompilerOutput compilerOutput = new CompilerOutput ();
/*
var compilerContext = new CompilerContext(new CompilerSettings(), new ConsoleReportPrinter());
var evaluator = new Evaluator(compilerContext);
*/
var reportWriter = new StringWriter();
var settings = new CompilerSettings();
var printer = new ConsoleReportPrinter(reportWriter);
var compilerContext = new CompilerContext (settings, printer);
var reports = new Report(compilerContext, printer);
var evaluator = new Evaluator(compilerContext);
var myString = "";
originalConsoleOut_global = Console.Out; // preserve the original stream
using(var writer = new StringWriter())
{
Console.SetOut(writer);
evaluator.Run (code);
evaluator.Run ("MainClass m1 = new MainClass(); m1.Main();");
//bConsole.WriteLine ("after executing code");
if (reports.Errors > 0) {
Console.WriteLine ("reportWriter.ToString: \n" + reportWriter.ToString ());
compilerOutput.errors = reportWriter.ToString ();
}
writer.Flush(); // make sure everything is written out of consule
myString = writer.GetStringBuilder().ToString();
compilerOutput.consoleOut = myString;
}
Console.SetOut(originalConsoleOut_global); // restore Console.Out
return compilerOutput;
}
开发者ID:sameli,项目名称:online-compiler,代码行数:45,代码来源:MonoCompiler.aspx.cs
示例13: Initialize
///////////////////////////////////////////////////////////////////////
private void Initialize()
{
CompilerSettings sett = new CompilerSettings();
ReportPrinter prnt = new ConsoleReportPrinter();
// TODO programatically add references for all flynn assemblies
sett.AssemblyReferences.Add("Flynn.Core.dll");
sett.AssemblyReferences.Add("Flynn.X10.dll");
sett.AssemblyReferences.Add("Flynn.Cron.dll");
sett.AssemblyReferences.Add("Flynn.Utilities.dll");
CompilerContext ctx = new CompilerContext(sett, prnt);
_eval = new Evaluator(ctx);
_eval.Run(Resources.CSharpEngine_InitUsings);
_eval.Run(Resources.CSharpEngine_InitScript);
}
开发者ID:jheddings,项目名称:flynn,代码行数:20,代码来源:CSharpEngine.cs
示例14: Evaluator
public Evaluator (CompilerSettings settings, Report report)
{
ctx = new CompilerContext (settings, report);
module = new ModuleContainer (ctx);
module.Evaluator = this;
source_file = new CompilationSourceFile ("{interactive}", "", 1);
source_file.NamespaceContainer = new NamespaceContainer (null, module, null, source_file);
ctx.SourceFiles.Add (source_file);
// FIXME: Importer needs this assembly for internalsvisibleto
module.SetDeclaringAssembly (new AssemblyDefinitionDynamic (module, "evaluator"));
importer = new ReflectionImporter (module, ctx.BuiltinTypes);
InteractiveBaseClass = typeof (InteractiveBase);
fields = new Dictionary<string, Tuple<FieldSpec, FieldInfo>> ();
}
开发者ID:constructor-igor,项目名称:cudafy,代码行数:19,代码来源:eval.cs
示例15: MonoCSharpExecutor
public MonoCSharpExecutor()
{
_reportBuilder = new StringBuilder();
var writer = new StringWriter(_reportBuilder);
var printer = new StreamReportPrinter(writer);
var settings = new CompilerSettings();
var context = new CompilerContext(settings, printer);
_evaluator = new Evaluator(context);
_evaluator.InteractiveBaseClass = typeof (InteractiveStuff);
_evaluator.ReferenceAssembly(typeof(HttpContext).Assembly);
_evaluator.ReferenceAssembly(typeof(VisualFarmRepo).Assembly);
_evaluator.ReferenceAssembly(typeof(BondegardFacade).Assembly);
_evaluator.ReferenceAssembly(typeof(IVFSConfig).Assembly);
Execute("using System;");
Execute("using System.Linq;");
Execute("using System.Web;");
Execute("using VisualFarmStudio.Core.Domain;");
Execute("using VisualFarmStudio.Core.Repository;");
Execute("using VisualFarmStudio.Lib.Model;");
Execute("using VisualFarmStudio.Lib.Containers;");
}
开发者ID:pedershk,项目名称:dotnetprograms,代码行数:22,代码来源:MonoCSharpExecutor.cs
示例16: DebuggerWindow
public DebuggerWindow(PluginContext context, String hackPath)
{
this.InitializeComponent();
Trace.Listeners.Add(this.listener);
var compilerSettings = new CompilerSettings
{
Unsafe = true,
};
compilerSettings.AssemblyReferences.Add("System.dll");
compilerSettings.AssemblyReferences.Add("System.Core.dll");
compilerSettings.AssemblyReferences.Add(typeof(MessageBox).Assembly.CodeBase); // PresentationFramework.dll
compilerSettings.AssemblyReferences.Add(Path.Combine(hackPath, "SharpCraft.dll"));
var compilerContext = new CompilerContext(compilerSettings, new DebuggerReportPrinter());
evaluator = new Evaluator(compilerContext);
evaluator.Compile("using System;");
evaluator.Compile("using TinkerWorX.SharpCraft;");
CompositionTarget.Rendering += CompositionTarget_Rendering;
}
开发者ID:Mofsy,项目名称:SharpCraft,代码行数:22,代码来源:DebuggerWindow.xaml.cs
示例17: InitIfNeeded
void InitIfNeeded()
{
if (eval == null) {
Log ("INIT EVAL");
var settings = new CompilerSettings ();
settings.AddConditionalSymbol ("__Continuous__");
settings.AddConditionalSymbol ("DEBUG");
PlatformSettings (settings);
var context = new CompilerContext (settings, printer);
eval = new Evaluator (context);
//
// Add References to get UIKit, etc. Also add a hook to catch dynamically loaded assemblies.
//
AppDomain.CurrentDomain.AssemblyLoad += (_, e) => {
Log ("DYNAMIC REF {0}", e.LoadedAssembly);
AddReference (e.LoadedAssembly);
};
foreach (var a in AppDomain.CurrentDomain.GetAssemblies ()) {
Log ("STATIC REF {0}", a);
AddReference (a);
}
//
// Add default namespaces
//
object res;
bool hasRes;
eval.Evaluate ("using System;", out res, out hasRes);
eval.Evaluate ("using System.Collections.Generic;", out res, out hasRes);
eval.Evaluate ("using System.Linq;", out res, out hasRes);
PlatformInit ();
}
}
开发者ID:mono,项目名称:Continuous,代码行数:36,代码来源:VM.cs
示例18: Create
public IController Create(RequestContext requestContext, Type controllerType)
{
CompilerSettings settings = new CompilerSettings();
Report report = new Report(new ConsoleReportPrinter());
Evaluator eval = new Evaluator(settings, report);
object instance = null;
bool instanceCreated = false;
eval.ReferenceAssembly(typeof(Controller).Assembly);
foreach (Assembly assembly in assemblies)
{
eval.ReferenceAssembly(assembly);
}
string controllerName = GetControllerName(requestContext, controllerType);
string path = pathProvider.GetPath(requestContext, controllerName);
CSharpControllerFile controllerFile = CSharpControllerFile.Parse(File.ReadAllText(path));
eval.Run(controllerFile.ClassSource);
eval.Evaluate("new " + controllerName + "();", out instance, out instanceCreated);
return (IController)instance;
}
开发者ID:friism,项目名称:RuntimeControllerFactory,代码行数:24,代码来源:RuntimeControllerActivator.cs
示例19: AddResource
void AddResource (AssemblyResource res, CompilerSettings settings)
{
if (settings.Resources == null) {
settings.Resources = new List<AssemblyResource> ();
settings.Resources.Add (res);
return;
}
if (settings.Resources.Contains (res)) {
report.Error (1508, "The resource identifier `{0}' has already been used in this assembly", res.Name);
return;
}
settings.Resources.Add (res);
}
开发者ID:OpenFlex,项目名称:playscript-mono,代码行数:15,代码来源:settings.cs
示例20: ParseOption
//
// This parses the -arg and /arg options to the compiler, even if the strings
// in the following text use "/arg" on the strings.
//
ParseResult ParseOption (string option, ref string[] args, CompilerSettings settings)
{
int idx = option.IndexOf (':');
string arg, value;
if (idx == -1) {
arg = option;
value = "";
} else {
arg = option.Substring (0, idx);
value = option.Substring (idx + 1);
}
switch (arg.ToLowerInvariant ()) {
case "/nologo":
return ParseResult.Success;
case "/t":
case "/target":
bool is_dotnet = true;
switch (value) {
case "exe":
settings.Target = Target.Exe;
break;
case "winexe":
settings.Target = Target.WinExe;
break;
case "library":
settings.Target = Target.Library;
settings.TargetExt = ".dll";
break;
case "module":
settings.Target = Target.Module;
settings.TargetExt = ".netmodule";
break;
case "javascript":
settings.Target = Target.JavaScript;
settings.TargetExt = ".js";
settings.AddConditionalSymbol ("TARGET_JS");
is_dotnet = false;
break;
case "cpp":
settings.Target = Target.Cpp;
settings.TargetExt = ".cpp";
settings.AddConditionalSymbol ("TARGET_CPP");
is_dotnet = false;
break;
default:
report.Error (2019, "Invalid target type for -target. Valid options are `exe', `winexe', `library', `module', `javascript' or `cpp'");
return ParseResult.Error;
}
if (is_dotnet) {
settings.AddConditionalSymbol ("TARGET_IL");
}
return ParseResult.Success;
case "/out":
if (value.Length == 0) {
Error_RequiresFileName (option);
return ParseResult.Error;
}
settings.OutputFile = value;
return ParseResult.Success;
case "/o":
case "/o+":
case "/optimize":
case "/optimize+":
settings.Optimize = true;
return ParseResult.Success;
case "/o-":
case "/optimize-":
settings.Optimize = false;
return ParseResult.Success;
// TODO: Not supported by csc 3.5+
case "/incremental":
case "/incremental+":
case "/incremental-":
// nothing.
return ParseResult.Success;
case "/d":
case "/define": {
if (value.Length == 0) {
Error_RequiresArgument (option);
return ParseResult.Error;
}
//.........这里部分代码省略.........
开发者ID:OpenFlex,项目名称:playscript-mono,代码行数:101,代码来源:settings.cs
注:本文中的Mono.CSharp.CompilerSettings类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论