private bool HasExplicitTypeConvention(Member property) { // todo: clean this up! // What it's doing is finding if there are any IUserType conventions // that would be applied to this property, if there are then we should // definitely automap it. The nasty part is that right now we don't have // a model, so we're having to create a fake one so the convention will // apply to it. var conventions = conventionFinder .Find <IPropertyConvention>() .Where(c => { if (!typeof(IUserTypeConvention).IsAssignableFrom(c.GetType())) { return(false); } var criteria = new ConcreteAcceptanceCriteria <IPropertyInspector>(); var acceptance = c as IConventionAcceptance <IPropertyInspector>; if (acceptance != null) { acceptance.Accept(criteria); } return(criteria.Matches(new PropertyInspector(new PropertyMapping { Type = new TypeReference(property.PropertyType), Member = property }))); }); return(conventions.FirstOrDefault() != null); }
private bool HasExplicitTypeConvention(Member property) { // todo: clean this up! // What it's doing is finding if there are any IUserType conventions // that would be applied to this property, if there are then we should // definitely automap it. The nasty part is that right now we don't have // a model, so we're having to create a fake one so the convention will // apply to it. var conventions = conventionFinder .Find<IPropertyConvention>() .Where(c => { if (!typeof(IUserTypeConvention).IsAssignableFrom(c.GetType())) return false; var criteria = new ConcreteAcceptanceCriteria<IPropertyInspector>(); var acceptance = c as IConventionAcceptance<IPropertyInspector>; if (acceptance != null) acceptance.Accept(criteria); return criteria.Matches(new PropertyInspector(new PropertyMapping { Type = new TypeReference(property.PropertyType), Member = property })); }); return conventions.FirstOrDefault() != null; }
private void Apply <TInspector, TInstance>(IEnumerable conventions, TInstance instance) where TInspector : IInspector where TInstance : TInspector { foreach (IConvention <TInspector, TInstance> convention in conventions) { var criteria = new ConcreteAcceptanceCriteria <TInspector>(); var acceptance = convention as IConventionAcceptance <TInspector>; if (acceptance != null) { acceptance.Accept(criteria); } if (criteria.Matches(instance)) { convention.Apply(instance); } } }