Esempio n. 1
0
 public void LoadTargetAssociations()
 {
     if (SelectedBaseClass != null)
     {
         TargetAssociations.Clear();
         foreach (ModelAssociation ma in ModelAssociations.
                  Where(a => a.Members.FirstOrDefault(m => m.ClassName.Equals(SelectedBaseClass.Name)) != null))
         {
             TargetAssociations.Add(ma);
         }
     }
 }
Esempio n. 2
0
        private void LoadModelAssociations(XElement classModel)
        {
            ModelAssociations.Clear();
            IEnumerable <XElement> modelAssociations = classModel.Elements("Association");

            foreach (XElement modelAssociation in modelAssociations)
            {
                var ma = new ModelAssociation();

                var    name = modelAssociation.Attribute("name");
                string modelAssociationName = name != null ? name.Value : "";
                ma.Name = modelAssociationName;

                var    desc        = modelAssociation.Attribute("description");
                string description = desc != null ? desc.Value : "";
                ma.Description = description;

                XElement endA = modelAssociation.Element("EndA");
                if (endA != null)
                {
                    XAttribute xEndATarget       = endA.Attribute("target");
                    string     endATarget        = xEndATarget != null ? xEndATarget.Value : "";
                    XAttribute xEndAMultiplicity = endA.Attribute("multiplicity");
                    string     endAMultiplicity  = xEndAMultiplicity != null ? xEndAMultiplicity.Value : "";
                    XAttribute xEndARole         = endA.Attribute("role");
                    string     endARole          = xEndARole != null ? xEndARole.Value : "";

                    ma.Members.Add(new AssociationMember {
                        ClassName = endATarget, Multiplicity = endAMultiplicity, Role = endARole
                    });
                }

                XElement endB = modelAssociation.Element("EndB");
                if (endB != null)
                {
                    XAttribute xEndBTarget       = endB.Attribute("target");
                    string     endBTarget        = xEndBTarget != null ? xEndBTarget.Value : "";
                    XAttribute xEndBMultiplicity = endB.Attribute("multiplicity");
                    string     endBMultiplicity  = xEndBMultiplicity != null ? xEndBMultiplicity.Value : "";
                    XAttribute xEndBRole         = endB.Attribute("role");
                    string     endBRole          = xEndBRole != null ? xEndBRole.Value : "";

                    ma.Members.Add(new AssociationMember {
                        ClassName = endBTarget, Multiplicity = endBMultiplicity, Role = endBRole
                    });
                }

                ModelAssociations.Add(ma);
            }
        }