示例#1
0
        /// <summary>
        /// Initializes the Ruby engine.
        /// </summary>
        private void Initialize()
        {
            if (initialized)
            {
                return;
            }

            ResourceAwarePlatformAdaptationLayer resourceAwarePlatform = new ResourceAwarePlatformAdaptationLayer();

            ScriptRuntimeSetup srs = new ScriptRuntimeSetup
            {
                HostType      = typeof(ResourceAwareScriptHost),
                HostArguments = new List <object> {
                    resourceAwarePlatform
                }
            };

            srs.AddRubySetup();
            ScriptRuntime runtime = Ruby.CreateRuntime(srs);

            engine = runtime.GetRubyEngine();

            engine.SetSearchPaths(new List <string> {
                @"R:\Resources\ironruby", @"R:\Resources\ruby\1.9.1"
            });

            string       resouce = Utils.ResourceAsString("Cruncher.Preprocessors.Sass.Resources.sass_in_one.rb");
            ScriptSource source  = engine.CreateScriptSourceFromString(resouce, SourceCodeKind.File);

            scope = engine.CreateScope();

            source.Execute(scope);

            sassEngine = scope.Engine.Runtime.Globals.GetVariable("Sass");

            initialized = true;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ResourceAwareScriptHost"/> class.
 /// </summary>
 /// <param name="adaptationLayer">
 /// The adaptation layer.
 /// </param>
 public ResourceAwareScriptHost(ResourceAwarePlatformAdaptationLayer adaptationLayer)
 {
     this.adaptionLayer = adaptationLayer;
 }