Ejemplo n.º 1
0
        public IList <PersistentCollectionChangeData> MapCollectionChanges(String referencingPropertyName,
                                                                           IPersistentCollection newColl,
                                                                           object oldColl,
                                                                           object id)
        {
            // Name of the property, to which we will delegate the mapping.
            String delegatePropertyName;

            // Checking if the property name doesn't reference a collection in a component - then the name will containa a .
            int dotIndex = referencingPropertyName.IndexOf('.');

            if (dotIndex != -1)
            {
                // Computing the name of the component
                String componentName = referencingPropertyName.Substring(0, dotIndex);
                // And the name of the property in the component
                String propertyInComponentName = MappingTools.createComponentPrefix(componentName)
                                                 + referencingPropertyName.Substring(dotIndex + 1);

                // We need to get the mapper for the component.
                referencingPropertyName = componentName;
                // As this is a component, we delegate to the property in the component.
                delegatePropertyName = propertyInComponentName;
            }
            else
            {
                // If this is not a component, we delegate to the same property.
                delegatePropertyName = referencingPropertyName;
            }

            IPropertyMapper mapper = Properties[propertyDatas[referencingPropertyName]];

            if (mapper != null)
            {
                return(mapper.MapCollectionChanges(delegatePropertyName, newColl, oldColl, id));
            }
            else
            {
                return(null);
            }
        }