KAOSTools.MetaModel.Attribute GetOrCreateAttribute(ParsedAttributeReferenceExpression pref, KAOSTools.MetaModel.Entity entity) { Console.WriteLine (">> " + pref.AttributeSignature.Value + " <<"); if (entity != null) { if (pref.AttributeSignature is NameExpression) { var attribute = entity.Attributes().SingleOrDefault (x => x.Name == pref.AttributeSignature.Value); if (attribute == null) { attribute = new KAOSTools.MetaModel.Attribute (model) { Name = pref.AttributeSignature.Value, Implicit = true } ; attribute.SetEntity (entity); model.Add (attribute); Declarations.Add (attribute, new List<Declaration> () { new Declaration (pref.Line, pref.Col, pref.Filename, relativePath, DeclarationType.Reference) }); } else { Declarations[attribute].Add ( new Declaration (pref.Line, pref.Col, pref.Filename, relativePath, DeclarationType.Reference) ); } return attribute; } else if (pref.AttributeSignature is IdentifierExpression) { var attribute = entity.model.Attributes().SingleOrDefault (x => x.Identifier == entity.Identifier + "." +pref.AttributeSignature.Value); if (attribute == null) { attribute = new KAOSTools.MetaModel.Attribute (model) { Identifier = entity.Identifier + "." + pref.AttributeSignature.Value, Implicit = true } ; attribute.SetEntity (entity); model.Add (attribute); Declarations.Add (attribute, new List<Declaration> () { new Declaration (pref.Line, pref.Col, pref.Filename, relativePath, DeclarationType.Reference) }); } else { Declarations[attribute].Add ( new Declaration (pref.Line, pref.Col, pref.Filename, relativePath, DeclarationType.Reference) ); } return attribute; } else throw new NotImplementedException (pref.AttributeSignature.GetType() + " is not yet supported"); } else { throw new Exception (string.Format("Entity '{0}' not found", pref.Variable)); } }
public Formula BuildPredicateFormula(KAOSTools.MetaModel.Predicate p, ParsedElement value) { var dict = new Dictionary<string, KAOSTools.MetaModel.Entity> (); foreach (var attr in p.Arguments) { dict.Add (attr.Name, attr.Type); } return BuildFormula (value, dict); }
public void TestTypeOfAgent(string input, KAOSTools.MetaModel.AgentType type) { var model = parser.Parse (input); model.Agents() .Where (x => x.Type == type) .ShallBeSingle (); }
private static IPListElement ExportLayer(KAOSTools.OmnigraffleExport.Omnigraffle.Layer layer) { var layer_dict = new PListDict (); layer_dict.Add ("Name", new PListString (layer.Name)); layer_dict.Add ("Lock", new PListString (layer.Lock ? "YES" : "NO")); layer_dict.Add ("View", new PListString (layer.View ? "YES" : "NO")); layer_dict.Add ("Print", new PListString (layer.Print ? "YES" : "NO")); return layer_dict; }
protected void Render(KAOSTools.MetaModel.Attribute attribute) { if (!shapes.ContainsKey (attribute.EntityIdentifier)) return; foreach (var entity in shapes[attribute.EntityIdentifier].Cast<Group>()) { var text = @""; if ((entity.Graphics[1] as ShapedGraphic).Text.Text.Length > 4) text+= @"\ql\par "; text += GetRtfUnicodeEscapedString((attribute.Derived ? "/ " : "- ")); text += GetRtfUnicodeEscapedString(attribute.FriendlyName); Console.WriteLine ("***" + string.IsNullOrEmpty(attribute.TypeIdentifier) + "***"); if (!string.IsNullOrEmpty(attribute.TypeIdentifier)) text += " : " + attribute.Type().FriendlyName; Console.WriteLine ("*" + entity.Graphics[1].GetType() + "*"); (entity.Graphics[1] as ShapedGraphic).Text.Text += text; Console.WriteLine (text + "**"); } }