示例#1
0
        private void AddChoiceAnnotation(PartBridge part, Relationship relationship)
        {
            NamedAndTyped choiceOptionRelationship = null;
            string        choiceType = relationship.Type;

            if (relationship.Choice)
            {
                choiceOptionRelationship = BeanBridgeChoiceRelationshipResolver.ResolveChoice(part, relationship);
            }
            else
            {
                if (relationship.TemplateRelationship)
                {
                    Argument argument = this.interaction.GetArgumentByTemplateParameterName(relationship.TemplateParameterName);
                    if (argument != null && argument.Choice)
                    {
                        Ca.Infoway.Messagebuilder.Xml.Predicate <Relationship> predicate = ChoiceSupport.ChoiceOptionTypePredicate(new string[] {
                            part.GetTypeName()
                        });
                        choiceOptionRelationship = argument.FindChoiceOption(predicate);
                        choiceType = argument.Name;
                    }
                }
            }
            if (choiceOptionRelationship != null)
            {
                CurrentBuffer().AddInfo("Selected option " + choiceOptionRelationship.Type + " (" + choiceOptionRelationship.Name + ") from choice "
                                        + choiceType);
            }
        }
示例#2
0
 private string DetermineXmlName(PartBridge tealBean, Relationship relationship)
 {
     if (!relationship.Choice && !relationship.TemplateRelationship)
     {
         return(relationship.Name);
     }
     else
     {
         if (relationship.TemplateRelationship)
         {
             Argument argument = this.interaction.GetArgumentByTemplateParameterName(relationship.TemplateParameterName);
             if (argument == null)
             {
                 throw new RenderingException("Cannot determine the template/choice parameter type : " + relationship.Name);
             }
             else
             {
                 if (argument.Choice)
                 {
                     Ca.Infoway.Messagebuilder.Xml.Predicate <Relationship> predicate = ChoiceSupport.ChoiceOptionTypePredicate(new string[] {
                         tealBean.GetTypeName()
                     });
                     Relationship option = argument.FindChoiceOption(predicate);
                     if (option == null)
                     {
                         throw new RenderingException("Cannot determine the choice type of template argument : " + argument.Name);
                     }
                     else
                     {
                         return(option.Name);
                     }
                 }
                 else
                 {
                     return(argument.TraversalName);
                 }
             }
         }
         else
         {
             if (tealBean.IsEmpty())
             {
                 return(relationship.Choices[0].Name);
             }
             else
             {
                 if (relationship.Cardinality.Multiple)
                 {
                     return(relationship.Name);
                 }
                 Relationship option = BeanBridgeChoiceRelationshipResolver.ResolveChoice(tealBean, relationship);
                 if (option == null)
                 {
                     // log an error instead?
                     throw new RenderingException("Cannot determine the choice type of relationship : " + relationship.Name);
                 }
                 else
                 {
                     return(option.Name);
                 }
             }
         }
     }
 }