示例#1
0
        /// <summary>We need to distribute all "common" mappings to every applicable "type-based" mappings</summary>
        /// <param name="mapping"></param>
        /// <param name="beanProperty"></param>
        private void AddDuplicates(Mapping mapping, BeanProperty beanProperty)
        {
            IList <RelationshipMap.Key> allTypeBased = this.map.GetAllTypeBased(mapping.First());

            foreach (RelationshipMap.Key key in allTypeBased)
            {
                object @object = this.map.Get(key);
                if (@object is Ca.Infoway.Messagebuilder.Marshalling.RelationshipSorter)
                {
                    Mapping rest = mapping.Rest();
                    Ca.Infoway.Messagebuilder.Marshalling.RelationshipSorter innerRelationshipSorter = (Ca.Infoway.Messagebuilder.Marshalling.RelationshipSorter
                                                                                                        )@object;
                    if (rest.IsCompound())
                    {
                        innerRelationshipSorter.properties[beanProperty.Name] = beanProperty;
                        // TM - Redmine 10965 - this "if" check fixes bug, might not be sufficient in the long run
                        if (innerRelationshipSorter.map.GetAllTypeBased(rest.First()).IsEmpty())
                        {
                            innerRelationshipSorter.Add(rest, beanProperty);
                        }
                        else
                        {
                            innerRelationshipSorter.AddDuplicates(rest, beanProperty);
                        }
                    }
                    else
                    {
                        // we are at the "bottom" of the chain - now we can add the "duplicate" property to its correct location
                        innerRelationshipSorter.Add(rest, beanProperty);
                    }
                }
            }
        }
示例#2
0
 private void Add(Mapping mapping, BeanProperty beanProperty)
 {
     this.properties[beanProperty.Name] = beanProperty;
     if (!mapping.IsCompound())
     {
         this.map.Put(mapping, beanProperty);
     }
     else
     {
         if (!this.map.ContainsMapping(mapping.FirstPart()))
         {
             Ca.Infoway.Messagebuilder.Marshalling.RelationshipSorter sorter = new Ca.Infoway.Messagebuilder.Marshalling.RelationshipSorter
                                                                                   (beanProperty.Name, GetBeanType(), GetBean(), true);
             this.map.Put(mapping.FirstPart(), sorter);
         }
         GetAsRelationshipSorter(mapping.FirstPart()).Add(mapping.Rest(), beanProperty);
     }
 }