コード例 #1
0
ファイル: ModelLoader2.cs プロジェクト: FlorianPRN/Mascaret
        public void addSignal(XElement signalNode, Package pkg)
        {
            // Bouml preserved body begin 0001F5E7

            //  StreamWriter file = new StreamWriter("signal.txt");

            string type = "", className = "", id = "";

            XAttribute attr = (XAttribute)signalNode.Attribute("{http://schema.omg.org/spec/XMI/2.1}type");
            if (attr == null) attr = (XAttribute)signalNode.Attribute("{http://www.omg.org/spec/XMI/20131001}type");

            if (attr != null) type = attr.Value;

            attr = (XAttribute)signalNode.Attribute("name");
            if (attr != null) className = attr.Value;

            if (type.CompareTo("uml:Signal") != 0)
            {
                //Debug.Log( className + " is a " + type + " and must be a signal");
                return;
            }

            attr = (XAttribute)signalNode.Attribute("{http://schema.omg.org/spec/XMI/2.1}id");
            if (attr == null) attr = (XAttribute)signalNode.Attribute("{http://www.omg.org/spec/XMI/20131001}id");

            if (attr != null) id = attr.Value;

            //Debug.Log( " ############## Add Signal : " + className );

            Signal signal = new Signal(className);

            //    file.WriteLine("Signal : " + className); file.Flush();
            //    file.Close();
            if (_signals.ContainsKey(id)) return;
            _signals.Add(id, signal);

            if (pkg != null)
                pkg.addSignals(signal);
            signal.Description = getComment(signalNode);
            signal.Summary = getSummary(signalNode);
            signal.Tags = getTags(signalNode);

            foreach (XElement child in signalNode.Elements())
            {
                string childName = child.Name.LocalName;

                if (childName.CompareTo("ownedOperation") == 0)
                    addOperation(child, signal);
                else if (childName.CompareTo("ownedAttribute") == 0)
                {
                    //Debug.Log( "AddAttribute SIGNAL" );
                    addAttribute(child, signal);
                }
            }

            foreach (XElement child in signalNode.Elements())
            {
                string childName = child.Name.LocalName;

                XAttribute attr2 = (XAttribute)child.Attribute("{http://schema.omg.org/spec/XMI/2.1}type");
                if (attr == null) attr = (XAttribute)child.Attribute("{http://www.omg.org/spec/XMI/20131001}type");

                if (attr2 != null)
                {
                    if (childName.CompareTo("ownedBehavior") == 0)
                    {
                        if (attr2.Value.CompareTo("uml:StateMachine") == 0)
                            addStateMachineToClass(child, signal);
                    }
                    else if (childName.CompareTo("nestedClassifier") == 0)
                    {
                        if (attr2.Value.CompareTo("uml:StateMachine") == 0)
                            addStateMachineToClass(child, signal);
                    }
                }
            }
            // Bouml preserved body end 0001F5E7
        }