Duck Library for Silverlight?

Is there a duck typing library for Silverlight? There are several for the full blown .NET framework, but I'm looking for something lighter.

+2


source to share


5 answers


When asking for "Silverlight Utility" are you referring to strongly typed automatic implementation of interfaces? Or dynamically creating object metadata using an object instance?

If it's the latter, Anthony's recommendation is in place. Strongly typed languages ​​that run on the CLR (C # and VB.NET) cannot support true dynamic duck typing. Thus, you can use IronRuby or IronPython, which are shipped as part of the Silverlight DLR project.

If you are looking for the former, then you are essentially looking for a mocking library. Silverlight supports many open source awkward frameworks.

Moq - http://code.google.com/p/moq/ (download: http://moq.googlecode.com/files/Moq.Silverlight.4.0.812.4-bin.zip )



RhinoMocks - http://ayende.com/projects/rhino-mocks.aspx (download: http://ayende.com/20/section.aspx/download/230 )

AutoFac - http://code.google.com/p/autofac/ (download: http://autofac.googlecode.com/files/Autofac-1.4.4.572-SL3.zip )

TypeMock / SilverUnit - http://cthru.codeplex.com (download: http://cthru.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=27748#DownloadId=69201 )

+3


source


You might want to use a DLR based language like Python in silverlight



+3


source


Depending on your interpretation of the duck input, I hope this arrives in C # 4.0 and dynamic

when it becomes available in Silverlight. Then you can pick and choose which bits will duck ( dynamic

) printed versus static type (everything else). Everything is within C #.

dynamic duck = /* pretty much anything */
duck.Quack();

      

+2


source


I recently created a utility that I call "DynamicWrapper" . It uses Reflection.Emit to create an on-the-fly wrapper class that implements the interface - a way to achieve duck typing in C #.

Unfortunately it doesn't work in Silverlight. It works fine in .NET 3.5 and my tests passed in my SL environment, but during SL runtime I get a security exception.

I didn't have time to figure it out, but the code is pretty straight forward. Maybe this code can point you in the right direction?

+1


source


ImpromptuInterface supports Silverlight 4. Not only does it print static duck implementations, but dynamic ones as well.

0


source







All Articles