예제 #1
0
 public SMarty(string name, SMartyBindingTimeTypes bindingTime, IUmlObject parent)
 {
     this.Name         = name;
     this.bindingTime  = bindingTime;
     this.Parent       = parent;
     this.minSelection = 0;
     this.maxSelection = int.MaxValue;
 }
예제 #2
0
        /// <summary>
        /// Adds Interface to Danu. Adds its name, minVar, maxVar and bindingTime.
        /// </summary>
        public void AddInterface(InterfaceObject io)
        {
            SMartyBindingTimeTypes bindingTime    = default(SMartyBindingTimeTypes);
            DanuBindingTime        newBindingTime = default(DanuBindingTime);
            SMarty attach = null;

            foreach (IAttachment attachment in io.Attachments)
            {
                if (attachment.GetType().Equals(typeof(SMarty)))
                {
                    attach = (SMarty)attachment;
                }
            }

            int minVar = attach.MinSelection;
            int maxVar = attach.MaxSelection;

            foreach (IAttachment attachment in io.Attachments)
            {
                if (attachment.GetType().Equals(typeof(SMarty)))
                {
                    SMarty smarty = (SMarty)attachment;
                    bindingTime = smarty.BindingTime;
                    minVar      = smarty.MinSelection;
                    maxVar      = smarty.MaxSelection;
                    break;
                }
            }

            if (!bindingTime.Equals(default(SMartyBindingTimeTypes)))
            {
                switch (bindingTime)
                {
                case SMartyBindingTimeTypes.CompileTime:
                    newBindingTime = DanuBindingTime.CompileTime;
                    break;

                case SMartyBindingTimeTypes.LinkingTime:
                    newBindingTime = DanuBindingTime.LinkingTime;
                    break;

                case SMartyBindingTimeTypes.Runtime:
                    newBindingTime = DanuBindingTime.Runtime;
                    break;

                case SMartyBindingTimeTypes.UpdateTime:
                    newBindingTime = DanuBindingTime.UpdateTime;
                    break;
                }
            }

            DanuInterfaceObject newInterface = new DanuInterfaceObject(io.Name, newBindingTime, minVar, maxVar);

            interfaces.Add(newInterface.Name, newInterface);
        }
예제 #3
0
        public void ReadXml(XmlReader reader)
        {
            while (reader.Read())
            {
                if (reader.IsStartElement())
                {
                    switch (reader.Name)
                    {
                    case "Stereotype":
                        Stereotype type = new Stereotype(reader["Name"]);
                        AddStereotype(type);
                        break;

                    case "Socket":
                        Socket so = new Socket((Component)GetUmlObject(reader["Parent"]),
                                               (InterfaceObject)GetUmlObject(reader["AttachedInterface"]), reader["Name"]);

                        if (reader["Stereotype"] != null)
                        {
                            so.Type = types[reader["Stereotype"]];
                        }
                        AddSocket(so);
                        break;

                    case "SMarty":
                        SMartyBindingTimeTypes btype = default(SMartyBindingTimeTypes);

                        switch (reader["BindingTime"])
                        {
                        case "Runtime":
                            btype = SMartyBindingTimeTypes.Runtime;
                            break;

                        case "LinkingTime":
                            btype = SMartyBindingTimeTypes.LinkingTime;
                            break;

                        case "CompileTime":
                            btype = SMartyBindingTimeTypes.CompileTime;
                            break;

                        case "UpdateTime":
                            btype = SMartyBindingTimeTypes.UpdateTime;
                            break;
                        }

                        SMarty smar = new SMarty(reader["Name"], btype, GetUmlObject(reader["Parent"]));
                        smar.MinSelection = int.Parse(reader["MinSelection"]);
                        smar.MaxSelection = int.Parse(reader["MaxSelection"]);
                        AddAttachment(smar);
                        break;

                    case "InterfaceObject":
                        InterfaceObject io = new InterfaceObject(reader["Name"],
                                                                 (Component)umlObjects[reader["Parent"]]);
                        if (reader["Stereotype"] != null)
                        {
                            io.Type = types[reader["Stereotype"]];
                        }
                        AddInterface(io);
                        break;

                    case "Component":
                        Component comp = new Component(reader["Name"]);
                        if (reader["Stereotype"] != null)
                        {
                            comp.Type = types[reader["Stereotype"]];
                        }
                        AddComponent(comp);
                        break;

                    case "Comment":
                        Comment com = new Comment(reader["Name"], GetUmlObject(reader["Parent"]));
                        reader.Read();
                        com.Content = reader.Value;
                        AddAttachment(com);
                        break;

                    case "Association":
                        Association link = new Association(GetUmlObject(reader["Source"]),
                                                           GetUmlObject(reader["Target"]));
                        if (reader["Stereotype"] != null)
                        {
                            link.Type = types[reader["Stereotype"]];
                        }
                        if (reader["Type"] != null)
                        {
                            link.Type = types[reader["Type"]];
                        }
                        AddAssociation(link);
                        break;
                    }
                }
            }
        }