When using Spring.Net you end up editing xml files to wire everything together. While something like fluent Spring.Net would be very nice to have, some of the xml authoring can be solved by using attributes. As sample I’ll use a real life example where I implemented it.
I had to add reporting to an application which consists of different modules. Depending on the license of the user he’d have a contacts module, a document management module, tasks, etc. The user would select the contents of his report and then fire up the designers to choose fields, order or group them, etc.
The end-user components we use are quite powerful so I only had to find a way to get the content into the report component as a dataset. Normally I keep away from using datasets but in this case it’s allowed. Note that I’m not using data adapters and other stuff, I just transform my rich object model into a flat dataset.
Each module writes an entitymapper for all of the entities that can be used as reporting source.
[EntityMapper(EntityType = typeof(ContactDto))] public class ContactMapper : EntityMapper { public override DataSet MapToDataSet(IEnumerable<ContactDto> entities) { DataSet dataSet = new DataSet(); //fill with data return dataSet; } }
I only wanted to add the object definition to the configuration specific for this module. I didn’t want to edit the config for reporting module. It should just pick all the mappers up and use them when entities of that type are handed to it.
The solution for this is using an IObjectPostProcessor to inspect everything that is configured in your container and do some additional logic.
public class MapperPostProcessor : IObjectPostProcessor { private readonly Type attributeType; public MapperPostProcessor() { attributeType = typeof (EntityMapperAttribute); } public DataSetMapper Mapper { get; set; } #region IObjectPostProcessor Members public object PostProcessAfterInitialization(object instance, string objectName) { object[] o = instance.GetType().GetCustomAttributes(attributeType, true); if(o.Length == 1) { var attribute = o[0] as EntityMapperAttribute; var entityMapper = instance as IEntityReportMapper; Mapper.RegisterMapper(entityMapper, attribute.EntityType); } return instance; } public object PostProcessBeforeInitialization(object instance, string name) { return instance; } #endregion }
Any postprocessor in your Spring context is automatically picked up by Spring and the methods will be called on the appropriate time. In this implementation I check every instance that is handed to the PostProcessAfterInitialization method for my own attribute, if it’s present I register it to my mapper manager for the specified type. For more info about this you should check out the documentation.
Out of the box Spring.NET has some of these already for you. For instance you can put the [Required] attribute on the properties that need to have a value after they have been constructed. If at that time they haven’t been initialized you’ll get an exception.
Tags: attribute, configuration

Get@Advair.Online” rel=”nofollow”>.…
Buygeneric drugs hwi…
Buy@Generic.Advair” rel=”nofollow”>.…
Buygeneric drugs ouw…
Buy@Generic.Advair.Without.Prescription” rel=”nofollow”>..…
Buyno prescription jwi…
Purchase@Albenza.Online” rel=”nofollow”>……
Buydrugs without prescription ttp…
Purchase@Cheap.Albenza” rel=”nofollow”>……
Buyit now knc…
arava@adverse.events” rel=”nofollow”>……
Buygeneric meds…
accutane@verdict.buy” rel=”nofollow”>..…
Buydrugs without prescription…
aciphex@muscle.pain” rel=”nofollow”>..…
Buygeneric pills…
actos@side.effects.edema” rel=”nofollow”>..…
Buygeneric drugs…
adalat@asus.buy” rel=”nofollow”>.…
Buydrugs without prescription…
allopurinol@atrial.fibrillation” rel=”nofollow”>.…
Buygeneric pills…
norvasc and theophylline…
Buy_drugs without prescription…
c-section scar pain symptoms pregnancy…
Buy_generic drugs…
alberta alcohol and drug abuse commission…
Buy_generic meds…
recipes for gastric bypass patients…
Buy_now…
birth control pills for pms symptoms…
Buy_drugs without prescription…
citalopram length of use…
Buy_drugs without prescription…
otc proton pump inhibitors…
Buy_no prescription…
rapid weight loss…
Buy_generic drugs…
weight gain stories feeders…
Buy_drugs without prescription…
cheap travel nebulizer…
Buy_generic drugs…
accutane birth defects…
Buy_it now…
how strength training effects osteoporosis…
Buy_generic drugs…
xanax and pregnancy…
Buy_generic pills…
menstrual patterns in menopause…
Buy_no prescription…
dependent disorder anxiety…
Buy_generic pills…
waldestrom bird flu…
Buy_it now…
herbal flee collars for dogs…
Buy_generic pills…
statistics on pregnancy in high school…
Buy_generic meds…
dhea treatment of depression…
Buy_drugs without prescription…
pregnancy issues with men…
Buy_no prescription…
high calorie diet for babies…
Buy_generic drugs…
cures for fingernail fungi…
Buy_generic meds…
bacterial staphylococcus aureus meningitis symptoms…
Buy_without prescription…
st joseph aspirin coupon…
Buy_generic pills…
sandwich elisa for hepatitis b…
Buy_generic meds…
colon cancer lymph node…
Buy_without prescription…
cipro for sinus infection…
Buy_generic meds…
hot spots or cancer…
Buy_without prescription…
symtons of canine gall bladder disease…
Buy_generic meds…
south beach diet foods to avoid…
Buy_no prescription…
seed implant for prostate cancer…
Buy_drugs without prescription…
altitude and pregnancy…
Buy_it now…
glucophage powered by vbulletin version 2.2.1…
Buy_generic pills…
adult male wheezing new onset…
Buy_drugs without prescription…
medical nebulizer…
Buy_generic meds…
hepatitis and liver cancer…
Buy_generic meds…
drug citalopram side effects…
Buy_generic drugs…
prozac overdose and tardive dyskinesia…
Buy_generic meds…
air purifiers for allergies…
Buy_generic meds…