コード例 #1
0
        /// <summary>
        /// Checks if a property is audited and if yes, fills all of its data.
        /// </summary>
        /// <param name="property">Property to check.</param>
        /// <param name="mappedPropertyName">NH Property name</param>
        /// <param name="propertyData">Property data, on which to set this property's modification store.</param>
        /// <param name="accessType">Access type for the property.</param>
        /// <param name="allClassAudited">Is class fully audited</param>
        /// <returns>False if this property is not audited.</returns>
        private bool fillPropertyData(MemberInfo property,
                                      string mappedPropertyName,
                                      PropertyAuditingData propertyData,
                                      string accessType,
                                      AuditedAttribute allClassAudited)
        {
            // check if a property is declared as not audited to exclude it
            // useful if a class is audited but some properties should be excluded
            if ((_metaDataStore.MemberMeta <NotAuditedAttribute>(property) != null && !_overriddenAuditedProperties.Contains(mappedPropertyName)) ||
                _overriddenNotAuditedProperties.Contains(mappedPropertyName))
            {
                return(false);
            }
            // if the optimistic locking field has to be unversioned and the current property
            // is the optimistic locking field, don't audit it
            if (_globalCfg.DoNotAuditOptimisticLockingField &&
                _persistentPropertiesSource.VersionedProperty != null &&
                _persistentPropertiesSource.VersionedProperty.Name.Equals(mappedPropertyName))
            {
                return(false);
            }

            if (!CheckAudited(property, mappedPropertyName, propertyData, allClassAudited))
            {
                return(false);
            }

            var propertyName = _propertyNamePrefix + mappedPropertyName;

            propertyData.Name             = propertyName;
            propertyData.ModifiedFlagName = MetadataTools.ModifiedFlagPropertyName(propertyName, _globalCfg.ModifiedFlagSuffix);
            propertyData.BeanName         = mappedPropertyName;
            propertyData.AccessType       = accessType;

            addPropertyJoinTables(property, propertyData);
            addPropertyAuditingOverrides(property, propertyData);
            if (!processPropertyAuditingOverrides(property, propertyData))
            {
                return(false);                // not audited due to AuditOverride annotation
            }
            setPropertyAuditMappedBy(property, propertyData);
            setCustomMapper(property, propertyData);

            return(true);
        }
コード例 #2
0
 public string Get(AuditConfiguration auditCfg)
 {
     return(MetadataTools.ModifiedFlagPropertyName(_propertyNameGetter.Get(auditCfg), auditCfg.GlobalCfg.ModifiedFlagSuffix));
 }