Child pages
  • Of what class is the instance the object factory returns?
Skip to end of metadata
Go to start of metadata

This wiki page is part of the re-motion mixins tutorial.
If you've landed here for the first time and are interested in this subject you will enjoy best results if you start at the beginning: [RM:re-motion mixins]

Note that in this example, there is no mixed class DessertWax (derived from DessertTopping and FloorWaxMixin). The mixed class is created by the ObjectFactory as soon as needed, upon first instantiation of our mixed class for the dessert wax.

Looking at the type (GetType () of the instance from ObjectFactory will unearth a type name with a GUID, something like

DessertWax.Uses.DessertTopping_Mixed_9e0cada34a474c1082d01c8769d54e8b

This complicated name invented by the ObjectFactory is not important, however, because you are not supposed to ever use it in your source code. The class only gives the .NET run-time something to work with, something to instantiate.

This derived class is cached; if you instantiate the mixed dessert topping/floor wax again, the ObjectFactory will pull it from the cache. In other words, in

var myOtherDessertWax = ObjectFactory.Create<DessertTopping> (ParamList.Empty);

myOtherDessertWax will have the same type as myDessertWaxDessertWax.Uses.DessertTopping_Mixed_9e0cada34a474c1082d01c8769d54e8b for
this particular run of the program. (The GUID will change from run to run, however.)

Since the mixed class you will eventually use at run-time is derived (sub-classed) from the target class and the mixin classes, you can't extend a sealed class or primitive types like int with re-motion mixin.

  • No labels