[Ironruby-core] Reading files in Dynamic Silverlight

Tomas Matousek Tomas.Matousek at microsoft.com
Sat Apr 5 21:41:14 EDT 2008


It's not currently supported in IronRuby file IO, but here's a workaround (I haven't tried this code in real, so it may not work :).

include Microsoft::Scripting::Silverlight

runtime = DynamicApplication::Environment
stream = runtime.host.platform_adaptation_layer.open_input_file_stream("story_details_view.xaml")

stream is instance of the Stream class.

Tomas

-----Original Message-----
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Michael Foord
Sent: Saturday, April 05, 2008 4:09 PM
To: ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Reading files in Dynamic Silverlight

Ivan Porto Carrero wrote:
> Hi
>
> I can't work out how I can read external xaml files from Silverlight
> with IronRuby.
> I've tried to use System::IO::File and StreamReader but both give me a
> MethodAccessException.
>
> How would I accomplish reading a xaml file in the xap with IronRuby
> and Silverlight.
>
> I would like to create a user control and load that into my main app.
>
> System.IO.Stream s =
> this.GetType().Assembly.GetManifestResourceStream("story_details_view.xaml")
>
>
> _root = this.InitializeFromXaml(new
> System.IO.StreamReader(s).ReadToEnd()) as UserControl;
>
>
> I would also like to try to read an external xaml file for skinning
> purposes.
> Is that possible at this moment?
>

In IronPython you just use the ordinary 'file' type to open a file that
is in the 'xap' file as if it was a local resource. You may find that
something similar is available in IronRuby.

Michael Foord
http://www.ironpythoninaction.com

> Cheers
> Ivan
> ------------------------------------------------------------------------
>
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core
>

_______________________________________________
Ironruby-core mailing list
Ironruby-core at rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core


More information about the Ironruby-core mailing list