public void SaveTo(AtlasFeatureModel atlas, string filename) { using (TextWriter writer = new StreamWriter(filename)){ XmlSerializer serializer = new XmlSerializer(typeof(AtlasFeatureModel)); serializer.Serialize(writer, atlas); } }
public AtlasFeatureModel LoadFrom(string filename) { TextReader reader = new StreamReader(filename); XmlSerializer serializer = new XmlSerializer(typeof(AtlasFeatureModel)); AtlasFeatureModel atlas = (AtlasFeatureModel)serializer.Deserialize(reader); reader.Close(); return(atlas); }
public AtlasFeatureModel LoadFrom(string filename) { TextReader reader = new StreamReader(filename); ClaferParserCoeus coeus = new ClaferParserCoeus(reader.ReadToEnd()); AtlasFeatureModel atlas = coeus.Atlas; reader.Close(); return(atlas); }
private void BuildAtlas(ClaferClassNode lex) { atlas = new AtlasFeatureModel(); if (lex.Type == ClaferClasses.Module) { lex = lex.Derivations.First(); if (lex.Type == ClaferClasses.ListDeclaration) { ReadDeclaration(lex.Derivations[0]); } } }
/// <summary> /// Insert current constraints into given feature model. /// </summary> public AtlasFeatureModel UpdateConstraintEditor(AtlasFeatureModel atlas) { foreach (ConstraintGrid grid in this.listViewContraints.Items.OfType <ConstraintGrid>()) { try { atlas.AddConstraint(grid.GetContraintAsString()); TextBlock tb = new TextBlock(); tb.Text = grid.GetContraintAsString(); } catch (Exception) { } } return(atlas); }
public void SaveTo(AtlasFeatureModel atlas, string filename) { this.model = atlas; this.bragi = new ComponentDiagramBragi(); AtlasFeature rootFeature = atlas.GetFeature(atlas.RootFeatureName); this.ParseComponent(null, rootFeature); this.bragi.AddStereotype(new Stereotype("Mutex")); this.bragi.AddStereotype(new Stereotype("Requires")); XmlSerializer serializer = new XmlSerializer(typeof(ComponentDiagramBragi)); using (TextWriter writer = new StreamWriter(filename)){ serializer.Serialize(writer, this.bragi); } }
private AtlasFeature buildFeature(Node node, AtlasFeature parent, ref AtlasFeatureModel atlas) { AtlasFeature f = new AtlasFeature(node.Name); atlas.AddFeature(f); //children foreach (Node n in node.Children) { AtlasFeature ff = buildFeature(n, f, ref atlas); AtlasConnection con = null; switch (n.Type) { case NodeType.Mandatory: case NodeType.Root: con = new AtlasConnection(f, ff, AtlasConnectionType.Mandatory); break; case NodeType.Optional: con = new AtlasConnection(f, ff, AtlasConnectionType.Optional); break; case NodeType.Or: con = new AtlasConnection(f, ff, AtlasConnectionType.OrRelation); break; case NodeType.Xor: con = new AtlasConnection(f, ff, AtlasConnectionType.Alternative); break; } atlas.AddConnection(con); } return(f); }
public void SaveTo(AtlasFeatureModel atlas, string filename) { MessageBox.Show("Save function for Clafer language was not implemented."); }
/// <summary> /// Parses an Atlas from an existing SPLOT xml format. /// </summary> /// <returns></returns> public AtlasFeatureModel LoadFrom(string filename) { //loads XML document. XmlDocument document = new XmlDocument(); document.Load(filename); //select tree node. XmlNodeList foundNodes = document.SelectNodes("//feature_tree"); if (foundNodes.Count != 1) { throw new Exception("Unable to parse document."); } //tree content String treeInfo = foundNodes[0].InnerText; String[] rawNodes = treeInfo.Split('\n'); //remove dummy windows line-break characters if (rawNodes[0].StartsWith("\r")) { for (int i = 0; i < rawNodes[i].Count(); i++) { rawNodes[i] = rawNodes[i].Replace("\r", ""); } } //convert strings to nodes (tree) Stack <Node> nodeStack = new Stack <Node>(); foreach (String stringNode in rawNodes) { if (stringNode.Trim() == string.Empty) { continue; } Node n = stringNode.ToNode(); //root node if (nodeStack.Count == 0) { nodeStack.Push(n); continue; } if (nodeStack.Peek().Depth < n.Depth) //is subnode { nodeStack.Peek().Children.Add(n); nodeStack.Push(n); } else if (nodeStack.Peek().Depth == n.Depth) // same-level node { nodeStack.Pop(); nodeStack.Peek().Children.Add(n); nodeStack.Push(n); } else //uncle-node -> pops it { while (nodeStack.Peek().Depth > n.Depth) { nodeStack.Pop(); } nodeStack.Peek().Children.Add(n); nodeStack.Push(n); } } AtlasFeatureModel atlas = new AtlasFeatureModel(); AtlasFeature root = this.buildFeature(nodeStack.LastOrDefault(), null, ref atlas); return(atlas); }
public void SaveTo(AtlasFeatureModel atlas, string filename) { MessageBox.Show("Save function for SPLOT format was not implemented."); }
/// <summary> /// Sets current FeatureModelAtlas. /// </summary> public void SetFeatureModel(AtlasFeatureModel model) { this.atlas = model; }