internal string GetAuditNoteForComponent(AbstractEntityPersister persister, ComponentType componentType, string componentPropertyNameChain, IComponentAuditStrategy propertyAuditStrategy) { var noteBulder = new StringBuilder(); Type componentDotNetType = componentType.ReturnedClass; foreach (PropertyInfo propertyInfo in componentDotNetType.GetProperties()) { if (propertyAuditStrategy.IsExcludedFromAudit(propertyInfo)) { continue; } var ignoreMappingTypeAttributes = propertyInfo.GetCustomAttributes(typeof(IgnoreMappingAttribute), false); if (ignoreMappingTypeAttributes.Length != 0) { continue; } string propertyName = propertyInfo.Name; var wholeComponentPropertyNameChain = string.Format("{0}.{1}", componentPropertyNameChain, propertyName); var subComponentType = componentType.Subtypes.FirstOrDefault(p => p.ReturnedClass.FullName == propertyInfo.PropertyType.FullName && p.IsComponentType) as ComponentType; string note; if (subComponentType == null) { string columnName = string.Join(",", persister.GetPropertyColumnNames(wholeComponentPropertyNameChain)); note = propertyAuditStrategy.GetAuditNoteForNonComponentProperty(propertyInfo, columnName); } else { note = GetAuditNoteForComponent ( persister, subComponentType, wholeComponentPropertyNameChain, propertyAuditStrategy.GetComponentPropertyAuditStrategy ( propertyInfo ) ); } if (!string.IsNullOrWhiteSpace(note)) { noteBulder.AppendLine ( note ); } } return noteBulder.ToString().Trim(); }
// e.g. componentPropertyNameChain = "Name.First" for patient first name internal string GetAuditNoteForComponent(AbstractEntityPersister persister, ComponentType componentType, string componentPropertyNameChain, IComponentAuditStrategy propertyAuditStrategy) { var noteBulder = new StringBuilder(); Type componentDotNetType = componentType.ReturnedClass; foreach (PropertyInfo propertyInfo in componentDotNetType.GetProperties()) { if (propertyAuditStrategy.IsExcludedFromAudit(propertyInfo)) { continue; } var ignoreMappingTypeAttributes = propertyInfo.GetCustomAttributes(typeof(IgnoreMappingAttribute), false); if (ignoreMappingTypeAttributes.Length != 0) { continue; } string propertyName = propertyInfo.Name; var wholeComponentPropertyNameChain = string.Format("{0}.{1}", componentPropertyNameChain, propertyName); var subComponentType = componentType.Subtypes.FirstOrDefault(p => p.ReturnedClass.FullName == propertyInfo.PropertyType.FullName && p.IsComponentType) as ComponentType; string note; if (subComponentType == null) { string columnName = string.Join(",", persister.GetPropertyColumnNames(wholeComponentPropertyNameChain)); note = propertyAuditStrategy.GetAuditNoteForNonComponentProperty(propertyInfo, columnName); } else { note = GetAuditNoteForComponent( persister, subComponentType, wholeComponentPropertyNameChain, propertyAuditStrategy.GetComponentPropertyAuditStrategy(propertyInfo)); } if (!string.IsNullOrWhiteSpace(note)) { noteBulder.AppendLine(); } } return(noteBulder.ToString().Trim()); }