Even though Silverlight has fallen out of grace with the powers that be, there are still some companies using it today for entertainment or line of business applications. Particularly for that last category, modularity can be a powerful tool in creating a flexible solution.
Over the past few years, I've worked with modular Silverlight applications based on Microsoft Prism. Every module is it's own XAP file, which is loaded on demand by the framework. Over the years, people have also rolled their own lightweight modular applications, also making use of XAP files. This article is about a specific problem with building these types of applications: optimization of the total application download size.
More...
Note: This article was edited after a Gonçalo Lopes presented me with a better solution. Thanks!
Every now and then you run into a situation where you wish your programming language of choice was just a tad more flexible than it actually is.
For example, constructors in C# always have to directly call one of the base type constructors as the first thing they do (or do they? keep reading).
Yesterday I ran into a situation where I would like my derived class to always use the same implementation* for a certain injectable dependency. No problem:
public class FooBase
{
public FooBase(IDependency dependency) { /* stuff here */ }
}
public class MyFoo : FooBase
{
public MyFoo() : base(new MyDependency()) { }
}
The dependency is created on the fly and my base class constructor is happy. However, my derived class also needed to make use of this dependency and my base class does not expose any property or field for me to access it. So before calling the base constructor, I would have liked to store a reference to this newly created MyDependency object.
More...