Ability to share code between .NET and Silverlight?

After going through a short experimental session to try to figure out what kind of work it would take to bring our .NET class library, or at least parts of it, to Silverlight so that we can reuse business logic between the two worlds, I wonder if others experience this kind of thing.

What I noticed from the head:

  • Many attributes are missing (e.g. Browsable (false))
  • Many interfaces are missing or present, but empty (ICloneable is hidden, ITypedList is missing)
  • Differences in differences (all available must be publicly available)
  • Some differences of the base class (without a component?)

So, I am wondering, is it really possible for me to even see this as an opportunity?

I got the initial code, but I just needed to comment on all the functionality of the database, mainly around processing lists, since they are based on ITypedList and some base classes. Apparently, I need to change to ObservableCollection in Silverlight, so in order to deal with this, I need to change all the base code.

The actual business test class I created is 99.5% identical to the one I would have done for .NET, only some minor changes that could easily be used in .NET are just not the way I would have done before looking at Silverlight. In other words, it seems appropriate to use business logic if I can make the base classes compatible.

, , : .NET Silverlight, # , .

- ? ?

? , , .

+5
4

.

; Silverlight #, #IF, (, log4net), . , (, , ).

- :

, OR/M (LLBLGen) "" Silverlight; - , , . , DAL , Silverlight.

+4

, :

  • #if! SILVERLIGHT , Silverlight.
  • , . , T4, Silverlight (, DisplayAttribute DescriptionAttribute).
  • /, Silverlight (, IDeserializationCallback, ICloneable, INotifyPropertyChanging), Silverlight, , , , .
  • , , Silverlight 4 Silverlight .NET , , Silverlight .

- , , ObservableCollection Silverlight BindingList ( - , .NET), .

UPDATE .NET- Silverlight, API System.Diagnostics, TraceSource, SourceSwitch .., Silverlight. Silverlight Einstein.Diagnostics. , , , .NET Framework . -, @. . , @ #. , @SourceSwitch - Einstein.Diagnostics.SourceSwitch, , - . [SilverlightPlaceholder].

+4

protobuf-net, :

  • (, , )
  • ; - , ; , API Expression, .
  • ; -p

, ITypedList ( ), , ; , . , . , 4.0/dynamic ?

+2

One possible fix for your problem is to copy the missing code from the Mono project. On the same day, I did a small project with the Compact Framework, and it lacked the entire System.XLM namespace. I just copied it all from Mono into my project, compiled it, and it worked perfectly with minimal changes, iirc.

+2
source

All Articles