public SlotDerived(InstanceSpecification instance, Property property) : base(instance, property) { if (DefiningProperty != null) { System.Console.WriteLine("Slot deriver : " + ((Expression)DefiningProperty.DefaultValue).ExpressionValue + " from" + instance.name); expression = (Expression)DefiningProperty.DefaultValue.clone(); if (expression == null) { expression = new Expression("No expression", DefiningProperty.Type); } } }
public void addChangeEvent(XElement changeNode, Package pkg) { string type = ""; if (changeNode.Attribute("{http://schema.omg.org/spec/XMI/2.1}type") != null) type = changeNode.Attribute("{http://schema.omg.org/spec/XMI/2.1}type").Value; else if (changeNode.Attribute("{http://www.omg.org/spec/XMI/20131001}type") != null) type = changeNode.Attribute("{http://www.omg.org/spec/XMI/20131001}type").Value; MascaretApplication.Instance.VRComponentFactory.Log("Type = " + type); if (type != "uml:ChangeEvent") { return; } string id = ""; if (changeNode.Attribute("{http://schema.omg.org/spec/XMI/2.1}id") != null) id = changeNode.Attribute("{http://schema.omg.org/spec/XMI/2.1}id").Value; else if (changeNode.Attribute("{http://www.omg.org/spec/XMI/20131001}id") != null) id = changeNode.Attribute("{http://www.omg.org/spec/XMI/20131001}id").Value; ChangeEvent changeEvent = new ChangeEvent(id); if (changeNode.Element("changeExpression") != null) { MascaretApplication.Instance.VRComponentFactory.Log("New Change Event : " + id); string changeExp = changeNode.Element("changeExpression").Attribute("value").Value; Expression exp = new Expression(changeExp, this.Model.BasicTypes["boolean"]); changeEvent.ChangeExpression = exp; } /* add in package*/ _events.Add(id, changeEvent); }
public Property _addAttribute(XElement attrNode, Class cl) { // StreamWriter file = new StreamWriter("attribute.txt"); string type = "", attrName = "", strVal = "", typeNodeType = ""; string id = ""; bool derived = false; Classifier attributeType = null; XElement typeNode = null, defaultNode = null; XAttribute attrid = (XAttribute)attrNode.Attribute("{http://schema.omg.org/spec/XMI/2.1}id"); if (attrid != null) id = attrid.Value; XAttribute attr = (XAttribute)attrNode.Attribute("{http://schema.omg.org/spec/XMI/2.1}type"); if (attr == null) attr = (XAttribute)attrNode.Attribute("{http://www.omg.org/spec/XMI/20131001}type"); if (attr == null) attr = (XAttribute)attrNode.Attribute("type"); if (attr != null) type = attr.Value; attr = (XAttribute)attrNode.Attribute("name"); if (attr != null) attrName = attr.Value; attr = (XAttribute)attrNode.Attribute("isDerived"); if (attr != null && attr.Value.CompareTo("true") == 0) { derived = true; } else if (attr != null && attr.Value.CompareTo("true") != 0) { derived = false; } foreach (XElement child in attrNode.Elements()) { if (child.Name.LocalName.CompareTo("type") == 0) typeNode = child; if (child.Name.LocalName.CompareTo("defaultValue") == 0) defaultNode = child; } if (defaultNode != null) { attr = (XAttribute)defaultNode.Attribute("value"); if (attr != null) { strVal = attr.Value; } } // file.WriteLine("Attribut : " + attrName); // file.Flush(); if (typeNode != null) { attr = (XAttribute)typeNode.Attribute("{http://schema.omg.org/spec/XMI/2.1}type"); if (attr == null) attr = (XAttribute)typeNode.Attribute("{http://www.omg.org/spec/XMI/20131001}type"); if (attr != null) typeNodeType = attr.Value; else { // file.WriteLine("Pas d'attribut type"); file.Flush(); typeNodeType = ((XAttribute)typeNode.Attribute("{http://schema.omg.org/spec/XMI/2.1}idref")).Value; if (typeNodeType == null) attr = (XAttribute)typeNode.Attribute("{http://www.omg.org/spec/XMI/20131001}idref"); attributeType = model.getBasicType(typeNodeType.ToLower()); // file.WriteLine(attributeType.name); file.Flush(); } if (typeNodeType.CompareTo("uml:Class") == 0) { attr = (XAttribute)typeNode.Attribute("idref"); if (attr != null && _classifiers.ContainsKey(attr.Value)) attributeType = _classifiers[attr.Value]; else if (attr != null) { attributeType = model.getBasicType(attr.Value.ToLower()); } } else if (typeNodeType.CompareTo("uml:PrimitiveType") == 0) { string strType = ""; attr = (XAttribute)typeNode.Attribute("href"); if (attr != null) strType = attr.Value.Substring(attr.Value.IndexOf("#") + 1); attributeType = model.getBasicType(strType.ToLower()); } } else { typeNode = attrNode; attr = (XAttribute)typeNode.Attribute("type"); if (attr != null) typeNodeType = attr.Value; if (_classifiers.ContainsKey(typeNodeType)) { attributeType = _classifiers[typeNodeType]; } else attributeType = model.getBasicType(typeNodeType.ToLower()); } ValueSpecification valueSpec = null; if (derived) { Expression curExpression = new Expression(strVal, attributeType); valueSpec = (ValueSpecification)curExpression; } else if (strVal.CompareTo("") == 0) { //value = attributeType.createValueFromString(strVal); } if (strVal != "") { MascaretApplication.Instance.VRComponentFactory.Log("HAS A DEFAULT VALUE : " + strVal); valueSpec = attributeType.createValueFromString(strVal); } Property attrProp = new Property(attrName, cl, attributeType, null, valueSpec, null); if (hasStereotype(id)) { attrProp.Stereotype = getStereotype(id); MascaretApplication.Instance.VRComponentFactory.Log("DEBUG /// STEREOTYPE : " + attrName + " : " + attrProp.Stereotype); } string mulStr = "1"; foreach (XElement child in attrNode.Elements()) { if (child.Name.LocalName.CompareTo("upperValue") == 0) { attr = (XAttribute)child.Attribute("value"); if (attr != null && attr.Value.CompareTo("*") == 0) mulStr = "-1"; if (attr != null && attr.Value.CompareTo("") == 0) mulStr = "1"; break; } } // file.Close(); attrProp.MaximumNumber = int.Parse(mulStr); mulStr = "1"; foreach (XElement child in attrNode.Elements()) { if (child.Name.LocalName.CompareTo("lowerValue") == 0) { attr = (XAttribute)child.Attribute("value"); if (attr != null && attr.Value.CompareTo("*") == 0) mulStr = "-1"; if (attr != null && attr.Value.CompareTo("") == 0) mulStr = "0"; break; } } attrProp.MinimumNumber = int.Parse(mulStr); //derived attrProp.IsDerived = derived; cl.addAttribute(attrProp); attrProp.Description = getComment(attrNode); attrProp.Summary = getSummary(attrNode); attrProp.Tags = getTags(attrNode); return attrProp; // Bouml preserved body end 0001FBE7 }
protected void onExpressionCHange(Expression exp) { //expression and callBacks }