Can you explain how exactly to Add the TypeProfiles configuration to slam.config?
Where are the TypeProfiles?
How to create them?
Jul 13, 2009 at 5:45 PM
Sorry I did not reply earlier, please check the
documentation for hierarchy for how to add a Type Profile to your configuration. Currently there is only the hierarchy profile available in addition to the defaults. But we, AW Systems, use profiles in SLAM for project specific needs somewhat
You should check out the code for Hierarchy to see just how that profile is built, but the key piece is the implementation of the ITypeProfile interface such as HierarchicalContentTypeTypeProfile. That class has a single method called CreateProfile
which takes a StructureMap Registry (note that ITypeProfile is from the AWS.SLAM.StructureMap namespace and really SLAM in this way is providing a hook to setup a Profile in StructureMap) object and a name. The name comes from the configuration where
you specific Name for a TypeProfiles item and the Registry is the Registry SLAM is using to setup StructureMap. When SLAM's context loads it actually adds all of the TypeProfiles in the configuration to StructureMap so as long as you have the class that
implements ITypeProfile specified in the TypeProfiles configuration section its CreateProfile method will be called by SLAM. So in HierarchicalContentTypeTypeProfile then you will see it simply calls registry.CreateProfile and specifies its own classes
for IItemCreator, IItemDeleter, IItemUpdater, and IDataSynchronizeTypeProcessor. As described in the hierarchy documentation to use this profile on a type you will add a TypeProfile attribute it. The result then is for a type configured to use
the HierarchicalContentTypeTypeProfile, on Create it will use the Creator set in HierarchicalContentTypeTypeProfile.CreateProfile, and its Deleter, Updater etc. SLAM is implementing these interfaces by default in AWS.SLAM.Events and the SLAM SharePoint
event receivers in turn are calling the Creator, Deleter, and Updater functionality via interfaces. So suppose you want something extra to happen on create: you create a class that extends ListItemCreator or ContentTypeCreator in AWS.SLAM.Events, override
Create, call the base Create then do extra processing after it, then implement ITypeProfile in another class that contains a CreatProfile method for adding a new Profile to StructureMap that uses your new Creator instead of the default. It's worth noting
you always need to specify at least these three interfaces in your CreateProfile method. So in my example in my CreateProfile method I would have something like:
And again whatever ContentType I assign to use this profile will use the Create method of MyContentTypeItemCreator when a new item of that content type is created and the default SLAM functionality on Delete and Update.
Hopefully some time soon I will be turning the above into general documentation for extending SLAM and profile creation but hopefully this helps. I think looking at the Hierarchy's TypeProfile classes and code will help in understanding the process.