I removed the hard-coded dependency on ActiveRecord from my marshaling code. I’m now using this marker module to flag that an object supports data binding:
module RubyClr
module Bindable
def get_binding_context
raise NotImplementedError("...")
end
end
end
To make a class data bindable you just have to mix in this module and implement get_binding_context. Here’s how I patch ActiveRecord:
class ActiveRecord::Base
include RubyClr::Bindable
def get_binding_context
@attributes
end
end
I also massively refactored the CLR shadow class generation code in RubyCLR to support two-way data binding. I also checked some unit tests to verify this behavior into the trunk.
Next up is implementing the data binding notification interfaces required to get a real editing experience in data bound controls.
3 archived reader comments
Mark (2006/05/05)
Hilarious. I only needed to remember the comments from the "first drop" post to get the answer. I’ll take a look and see what that might take to do it with P/Invoke and C#.
John Lam (2006/05/05)
It’s going to be a hard task. The IJW stuff in C++/CLI makes interop with C code a breeze - you’ll have to do all of that by hand in Mono C#. The main reason I haven’t really done anything here is that the C++ layer is still changing a lot - a port would be a lot easier when I’ve locked down the feature set of RubyCLR for release. It’s good to see you back here again, though.
Mark (2006/05/05)
Yeah, if I do look into it, I’ll just pick one of your revs and a feature subset (maybe the first drop) and use it as a feasability study just to see how deep the rabbit hole is.