In my solution, use WCF communicate between client and server. and host in IIS.
my problem is how to create MEF Container in server side and import repository instance to ObjectFactory?
Follow this link http://cslacontrib.codeplex.com/SourceControl/list/changesets and download the latest source.
In the folder $\samples\MEFSamples\ObjectFactory you will find a sample application with ObjectFactory that use MEF.
And in the $\trunk\CslaContrib.MEF you will find baseclasses and an ObjectFactoryLoader that use MEF.
Basically:
Thanks.
I will have to combine diffgrah、customField MEF MefBusinessBase into one Bussinessbase
When you use ObjectFactory you have no need for MefBusinessBase and the other Mef intermediate base classes.
MefFactoryLoader is the key component and the usage of interfaces for the "root" and "child" object factories.
They MefXYX base classes are only required for repository pattern and just my laziness to use the same business library with a minimum of changes for the 2 samples.
According to what I understand, if need to sepreate BO and DataAccess,such as Fetch,Create, into two assembly, will use ObjectFactory. If I no sepeate them. How to Create Container?
for example in ProjectTracker, if i need to create MEF, should create static class and examine it in DALFactory
public static IDALManager GetManager()
{
_container = Container.Current;
if (dalManager == null)
{
var dalTypeName = ConfigurationManager.AppSettings["DalManagerType"];
if (!string.IsNullOrEmpty(dalTypeName))
// _dalType = Type.GetType(dalTypeName);
dalManager = ServiceLocator.Current.GetInstance<IDALManager>(dalTypeName);
else
throw new NullReferenceException("DalManagerType");
if (dalManager == null)
throw new ArgumentException(string.Format("Type {0} could not be found", dalTypeName));
}
return dalManager;
}
Look at MefFactoryLoader.
You want to use MEF to have a separate DAL layer for unit testing and another for production - right?
That would typically require that you have the implementation in separate asseblies to be loaded into the container.
CSLA - when using ObjectFactory requires an ObjectFactoryLoader to return
The ObjectFactoryLoader gets the text string from ObjectFactoryAttribute - and the ObjectFactoryAttribute constructor that accepts typeof(interface) will actually use the fully qualified name of the interface. So this name is sent to the ObjectFactoryLoader to return an instance of the actual class that the DataPortal will call.
This is implemented in the MefFactoryLoader - that may be altered to use another container - my implementation just loads the available types from the bin folder - assuming that only the relevant assemblies is present at the given time.
So - anything that needs MEF container must be handled inside the implementation of ObjectFactoryLoader and must also "build" the imports of the actual class before it is returned to the data portal.
Copyright (c) Marimer LLC