tags:

views:

36

answers:

0

Hi,

I am trying to create a Dsl which will have instances that live in individual Dsl .rb files and then run them from the CLR.

I want to create and set the values of the Clr object in IronRuby and then somehow have access to the CLR object after the .rb Dsl instance file has run.

Here is my Clr object which is very simple at the moment:

namespace Horn.Core.Dsl
{
    public class BuildMetaData : IBuildMetaData
    {
        public string Description { get; set; }
    }
}

I have the following module which I am using to specify my Dsl and which will create an instance of the BuildMetaData specified above:

module MetaBuilder
  module Dsl
    module Main
      attr_accessor :metadata
      def install(name, &block)
        @metadata = Horn::Core::Dsl::BuildMetaData.new
        yield self if block_given?
      end

      def description(desc)
         @metadata.Description = desc
      end

      def get_metadata
          @metadata
      end

    end
  end
end

include MetaBuilder::Dsl::Main

I somehow want to be able to get the @metadata property from the Clr code after an instance of the Dsl has ran.

An instance of the Dsl looks like this currently:

install :horn do
  description "A .NET build and dependency manager"
end

My C# code looks like this currently:

var engine = Ruby.CreateEngine();
engine.Runtime.LoadAssembly(typeof(BuildMetaData).Assembly);
engine.ExecuteFile(buildFile);
var klass = engine.Runtime.Globals.GetVariable("get_metadata");

Is there anyway I can get at the @metadata property without having to pollute the Dsl instance?

Thanks in advance

Paul