本文整理汇总了C#中Microsoft.Scripting.Hosting.ScriptRuntimeSetup.AddRubySetup方法的典型用法代码示例。如果您正苦于以下问题:C# ScriptRuntimeSetup.AddRubySetup方法的具体用法?C# ScriptRuntimeSetup.AddRubySetup怎么用?C# ScriptRuntimeSetup.AddRubySetup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Scripting.Hosting.ScriptRuntimeSetup
的用法示例。
在下文中一共展示了ScriptRuntimeSetup.AddRubySetup方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SassTransformerBase
public SassTransformerBase(string syntaxOption)
{
var pal = new ResourceRedirectionPlatformAdaptationLayer();
var srs = new ScriptRuntimeSetup
{
HostType = typeof(SassCompilerScriptHost),
HostArguments = new List<object> { pal },
};
srs.AddRubySetup();
var runtime = Ruby.CreateRuntime(srs);
var engine = runtime.GetRubyEngine();
// NB: 'R:\{345ED29D-C275-4C64-8372-65B06E54F5A7}' is a garbage path that the PAL override will
// detect and attempt to find via an embedded Resource file
engine.SetSearchPaths(new List<string>
{
@"R:\{345ED29D-C275-4C64-8372-65B06E54F5A7}\lib\ironruby",
@"R:\{345ED29D-C275-4C64-8372-65B06E54F5A7}\lib\ruby\1.9.1"
});
var source = engine.CreateScriptSourceFromString(Utility.ResourceAsString("lib.sass_in_one.rb", typeof(SassCompiler)), SourceCodeKind.File);
var scope = engine.CreateScope();
source.Execute(scope);
sassCompiler = scope.Engine.Runtime.Globals.GetVariable("Sass");
option = engine.Execute(syntaxOption);
}
示例2: SassFileCompiler
static SassFileCompiler()
{
_sassModule = new TrashStack<SassModule>(() => {
var srs = new ScriptRuntimeSetup() {
HostType = typeof (ResourceAwareScriptHost),
//DebugMode = Debugger.IsAttached
};
srs.AddRubySetup();
var runtime = Ruby.CreateRuntime(srs);
var engine = runtime.GetRubyEngine();
// NB: 'R:\' is a garbage path that the PAL override below will
// detect and attempt to find via an embedded Resource file
engine.SetSearchPaths(new[] {@"R:/lib/ironruby", @"R:/lib/ruby/1.9.1"});
var source = engine.CreateScriptSourceFromString(Utility.ResourceAsString("SassAndCoffee.Core.lib.sass_in_one.rb"), "R:/lib/sass_in_one.rb", SourceCodeKind.File);
var scope = engine.CreateScope();
source.Execute(scope);
return new SassModule {
PlatformAdaptationLayer = (VirtualFilePAL)runtime.Host.PlatformAdaptationLayer,
Engine = scope.Engine.Runtime.Globals.GetVariable("Sass"),
SassOption = engine.Execute(@"{:syntax => :sass, :cache_location => ""C:/""}"),
ScssOption = engine.Execute(@"{:syntax => :scss, :cache_location => ""C:/""}"),
ExecuteRubyCode = code => engine.Execute(code, scope)
};
});
}
示例3: MainPage
public MainPage()
{
this.InitializeComponent();
var setup = new ScriptRuntimeSetup();
setup.HostType = typeof(DlrHost);
setup.AddRubySetup();
var runtime = Ruby.CreateRuntime(setup);
this.engine = Ruby.GetEngine(runtime);
this.scope = engine.CreateScope();
this.scope.SetVariable("Main", this);
runtime.LoadAssembly(typeof(object).GetTypeInfo().Assembly);
runtime.LoadAssembly(typeof(TextSetOptions).GetTypeInfo().Assembly);
runtime.LoadAssembly(typeof(TextAlignment).GetTypeInfo().Assembly);
string outputText = @"
box = main.find_name('OutputBox')
p box.text_alignment
box.text_alignment = Windows::UI::Xaml::TextAlignment.Right
p box.text_alignment
";
InputBox.IsSpellCheckEnabled = false;
OutputBox.IsSpellCheckEnabled = false;
InputBox.Document.SetText(TextSetOptions.None, outputText);
}
示例4: MainPage
public MainPage()
{
this.InitializeComponent();
var setup = new ScriptRuntimeSetup();
setup.HostType = typeof(DlrHost);
setup.AddRubySetup();
var runtime = Ruby.CreateRuntime(setup);
this.engine = Ruby.GetEngine(runtime);
this.scope = engine.CreateScope();
this.scope.SetVariable("Main", this);
runtime.LoadAssembly(typeof(object).GetTypeInfo().Assembly);
runtime.LoadAssembly(typeof(TextSetOptions).GetTypeInfo().Assembly);
runtime.LoadAssembly(typeof(TextAlignment).GetTypeInfo().Assembly);
string outputText = @"
box = main.find_name('OutputBox')
p box.text_alignment
box.text_alignment = Windows::UI::Xaml::TextAlignment.Right
p box.text_alignment
";
InputBox.IsSpellCheckEnabled = false;
OutputBox.IsSpellCheckEnabled = false;
InputBox.Document.SetText(TextSetOptions.None, outputText);
// http://msdn.microsoft.com/en-us/library/windows/apps/br211377.aspx
IInspectable insp = (IInspectable)InputBox.Document;
string winTypeName;
insp.GetRuntimeClassName(out winTypeName);
Guid[] iids;
int iidCount;
insp.GetIids(out iidCount, out iids);
// winTypeName = "Windows.Foundation.Collections.IIterator`1<Windows.Foundation.Collections.IMapView`2<Windows.Foundation.Collections.IVector`1<String>, String>>";
var parts = ParseWindowsTypeName(winTypeName);
Type type = MakeWindowsType(parts);
var guid = type.GetTypeInfo().GUID;
}
示例5: DlrHost
public DlrHost()
{
this._Runtime = new Lazy<ScriptRuntime>(() => {
var setup = new ScriptRuntimeSetup();
setup.DebugMode = true;
setup.LanguageSetups.Add(Python.CreateLanguageSetup(null));
setup.AddRubySetup();
var runtime = new ScriptRuntime(setup);
AppDomain.CurrentDomain.GetAssemblies().ForEach(assm => runtime.LoadAssembly(assm));
return runtime;
});
this._Scope = new Lazy<ScriptScope>(() => {
var scope = this._Runtime.Value.CreateScope();
return scope;
});
this._Extensions = new Lazy<ISet<string>>(() => {
return new HashSet<string>(this._Runtime.Value.Setup.LanguageSetups.SelectMany(lang => lang.FileExtensions), StringComparer.OrdinalIgnoreCase);
});
}
示例6: Initialize
void Initialize()
{
if (initialized) return;
pal = new CassettePlatformAdaptationLayer(new ResourceRedirectionPlatformAdaptationLayer(), RootDirectory);
var srs = new ScriptRuntimeSetup
{
HostType = typeof(SassCompilerScriptHost),
HostArguments = new List<object> { pal },
};
srs.AddRubySetup();
var runtime = Ruby.CreateRuntime(srs);
engine = runtime.GetRubyEngine();
// NB: 'R:\{345ED29D-C275-4C64-8372-65B06E54F5A7}' is a garbage path that the PAL override will
// detect and attempt to find via an embedded Resource file
engine.SetSearchPaths(new List<string>
{
@"R:\{345ED29D-C275-4C64-8372-65B06E54F5A7}\lib\ironruby",
@"R:\{345ED29D-C275-4C64-8372-65B06E54F5A7}\lib\ruby\1.9.1"
});
var source = engine.CreateScriptSourceFromString(
Utility.ResourceAsString("lib.sass_in_one.rb", typeof(SassAndCoffee.Ruby.Sass.SassCompiler)),
SourceCodeKind.File);
scope = engine.CreateScope();
source.Execute(scope);
sassCompiler = scope.Engine.Runtime.Globals.GetVariable("Sass");
sassOption = engine.Execute("{:cache => false, :syntax => :sass}");
scssOption = engine.Execute("{:cache => false, :syntax => :scss}");
initialized = true;
}
示例7: RubyHosting5
public void RubyHosting5() {
// app-domain creation:
if (_driver.PartialTrust) return;
AppDomain domain = AppDomain.CreateDomain("foo");
var rs = ScriptRuntimeSetup.ReadConfiguration();
LanguageSetup ls = rs.GetRubySetup();
Debug.Assert(ls.Names.IndexOf("IronRuby") != -1);
var newSetup = new ScriptRuntimeSetup();
newSetup.AddRubySetup((s) => {
s.Options["Compatibility"] = RubyCompatibility.Ruby19;
s.Options["LibraryPaths"] = ls.Options["LibraryPaths"];
});
ScriptRuntime runtime = ScriptRuntime.CreateRemote(domain, newSetup);
ScriptEngine engine = runtime.GetRubyEngine();
Assert(engine.RequireFile("fcntl") == true);
Assert(engine.Execute<bool>("Object.constants.include?(:Fcntl)") == true);
}
示例8: CompileSass
public string CompileSass(string input, SassMode mode)
{
var srs = new ScriptRuntimeSetup() { HostType = typeof(ResourceAwareScriptHost) };
srs.AddRubySetup();
var runtime = Ruby.CreateRuntime(srs);
var engine = runtime.GetRubyEngine();
engine.SetSearchPaths(new List<string> { @"R:\lib\ironruby", @"R:\lib\ruby\1.9.1" });
var source = engine.CreateScriptSourceFromString(Utility.ResourceAsString("SquishIt.Sass.lib.sass_in_one.rb"), SourceCodeKind.File);
var scope = engine.CreateScope();
source.Execute(scope);
dynamic sassMode = mode == SassMode.Sass
? engine.Execute("{:syntax => :sass}")
: engine.Execute("{:syntax => :scss}");
var sassEngine = scope.Engine.Runtime.Globals.GetVariable("Sass");
return (string) sassEngine.compile(input, sassMode);
}
示例9: Init
public void Init(HttpApplication context)
{
var srs = new ScriptRuntimeSetup() {HostType = typeof (ResourceAwareScriptHost)};
srs.AddRubySetup();
var runtime = Ruby.CreateRuntime(srs);
var engine = runtime.GetRubyEngine();
engine.SetSearchPaths(new List<string>() {@"R:\lib\ironruby", @"R:\lib\ruby\1.9.1"});
var source = engine.CreateScriptSourceFromString(Utility.ResourceAsString("SassAndCoffee.lib.sass_in_one.rb"), SourceCodeKind.File);
var scope = engine.CreateScope();
source.Execute(scope);
_scssOption = engine.Execute("{:syntax => :scss}");
_sassOption = engine.Execute("{:syntax => :sass}");
_sassModule = scope.Engine.Runtime.Globals.GetVariable("Sass");
}
示例10: SassFileCompiler
static SassFileCompiler()
{
_sassModule = new TrashStack<SassModule>(() => {
var srs = new ScriptRuntimeSetup() {HostType = typeof (ResourceAwareScriptHost)};
srs.AddRubySetup();
var runtime = Ruby.CreateRuntime(srs);
var engine = runtime.GetRubyEngine();
engine.SetSearchPaths(new List<string>() {@"R:\lib\ironruby", @"R:\lib\ruby\1.9.1"});
var source = engine.CreateScriptSourceFromString(Utility.ResourceAsString("SassAndCoffee.lib.sass_in_one.rb"), SourceCodeKind.File);
var scope = engine.CreateScope();
source.Execute(scope);
return new SassModule() {
Engine = scope.Engine.Runtime.Globals.GetVariable("Sass"),
SassOption = engine.Execute("{:syntax => :sass}"),
ScssOption = engine.Execute("{:syntax => :scss}"),
ExecuteRubyCode = code => engine.Execute(code, scope),
};
});
}
示例11: CreateRuntime
/*!*/
protected override ScriptRuntime CreateRuntime()
{
var setup = new ScriptRuntimeSetup();
setup.AddRubySetup();
return _factory.CreateRuntime(setup);
}
示例12: CreateRuntime
/*!*/
protected virtual ScriptRuntime CreateRuntime()
{
ScriptRuntimeSetup setup = new ScriptRuntimeSetup();
setup.AddRubySetup();
setup.DebugMode = true;
return Ruby.CreateRuntime(setup);
}