private void TypeInfotagsChanged(GraphElementType type) { TypeInfotagsChangedHandler handler = OnTypeInfotagsChanged; if (handler != null) { handler(type); } }
/// <summary> /// Returns the label of the given element type or null for the default case. /// </summary> /// <param name="type">The element type.</param> /// <returns>The label or null.</returns> public String GetElemTypeLabel(GraphElementType type) { String res; if (!elemTypeLabel.TryGetValue(type, out res)) { return(null); } return(res); }
/// <summary> /// Associates an InfoTag to a GrGenType. /// </summary> /// <param name="type">The element type to given an InfoTag</param> /// <param name="infotag">The InfoTag</param> public void AddTypeInfoTag(GraphElementType type, InfoTag infoTag) { List <InfoTag> typeInfoTags; if (!infoTags.TryGetValue(type, out typeInfoTags)) { infoTags[type] = typeInfoTags = new List <InfoTag>(); } typeInfoTags.Add(infoTag); TypeInfotagsChanged(type); }
/// <summary> /// Returns a list of InfoTag objects for the given type or null. /// </summary> /// <param name="type">The element type to be examined.</param> /// <returns>A list of associated InfoTag objects or null.</returns> public List <InfoTag> GetTypeInfoTags(GraphElementType type) { List <InfoTag> typeInfoTags; if (!infoTags.TryGetValue(type, out typeInfoTags)) { return(null); } else { return(typeInfoTags); } }
/// <summary> /// Returns an info tag with the given AttributeType registered for the given element type or null. /// </summary> /// <param name="type">The element type.</param> /// <param name="attrType">The attribute type.</param> /// <returns>The info tag or null.</returns> public InfoTag GetTypeInfoTag(GraphElementType type, AttributeType attrType) { List <InfoTag> typeInfoTags; if (infoTags.TryGetValue(type, out typeInfoTags)) { foreach (InfoTag infotag in typeInfoTags) { if (infotag.AttributeType == attrType) { return(infotag); } } } return(null); }
public override void Check(SequenceCheckingEnvironment env) { base.Check(env); GraphElementType graphElementType = TypesHelper.GetGraphElementType(GraphElementVar.Type, env.Model); if (GraphElementVar.Type != "" && graphElementType == null) { throw new SequenceParserException(Symbol, "node or edge type", GraphElementVar.Type); } if (VisitedFlagExpression != null) { if (!TypesHelper.IsSameOrSubtype(VisitedFlagExpression.Type(env), "int", env.Model)) { throw new SequenceParserException(Symbol, "int", VisitedFlagExpression.Type(env)); } } }
/// <summary> /// Sets the labels of the given element type. /// null is the default case, which is "<elemname>:<type>". /// </summary> /// <param name="type">The element type.</param> /// <param name="label">The label or null for the default case.</param> public void SetElemTypeLabel(GraphElementType type, String label) { elemTypeLabel[type] = label; }
private static void ReadAttributes(IGraphElement elem, XmlElement xmlelem) { GraphElementType type = elem.Type; foreach (XmlElement attrelem in xmlelem.GetElementsByTagName("attr")) { String attrname = attrelem.GetAttribute("name"); String attrval = attrelem.InnerText; AttributeType attrType = type.GetAttributeType(attrname); object value = null; switch (attrType.Kind) { case AttributeKind.BooleanAttr: if (attrval.Equals("true", StringComparison.OrdinalIgnoreCase)) { value = true; } else if (attrval.Equals("false", StringComparison.OrdinalIgnoreCase)) { value = false; } else { throw new Exception("Attribute \"" + attrname + "\" must be either \"true\" or \"false\"!"); } break; case AttributeKind.EnumAttr: { int val; if (Int32.TryParse(attrval, out val)) { value = val; } else { foreach (EnumMember member in attrType.EnumType.Members) { if (attrval == member.Name) { value = member.Value; break; } } if (value == null) { String errorText = "Attribute \"" + attrname + "\" must be one of the following values:"; foreach (EnumMember member in attrType.EnumType.Members) { errorText += " - " + member.Name + " = " + member.Value; } throw new Exception(errorText); } } break; } case AttributeKind.ByteAttr: { sbyte val; if (!SByte.TryParse(attrval, out val)) { throw new Exception("Attribute \"" + attrname + "\" must be a byte (signed)!"); } value = val; break; } case AttributeKind.ShortAttr: { short val; if (!Int16.TryParse(attrval, out val)) { throw new Exception("Attribute \"" + attrname + "\" must be a short!"); } value = val; break; } case AttributeKind.IntegerAttr: { int val; if (!Int32.TryParse(attrval, out val)) { throw new Exception("Attribute \"" + attrname + "\" must be an integer!"); } value = val; break; } case AttributeKind.LongAttr: { long val; if (!Int64.TryParse(attrval, out val)) { throw new Exception("Attribute \"" + attrname + "\" must be a long!"); } value = val; break; } case AttributeKind.StringAttr: value = attrval; break; case AttributeKind.FloatAttr: { float val; if (!Single.TryParse(attrval, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out val)) { throw new Exception("Attribute \"" + attrname + "\" must be a floating point number!"); } value = val; break; } case AttributeKind.DoubleAttr: { double val; if (!Double.TryParse(attrval, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out val)) { throw new Exception("Attribute \"" + attrname + "\" must be a floating point number!"); } value = val; break; } case AttributeKind.ObjectAttr: { throw new Exception("Attribute \"" + attrname + "\" is an object type attribute!\n" + "It is not possible to assign a value to an object type attribute!"); } case AttributeKind.SetAttr: case AttributeKind.MapAttr: case AttributeKind.ArrayAttr: case AttributeKind.DequeAttr: default: throw new Exception("Unsupported attribute value type: \"" + attrType.Kind + "\""); // TODO: support set=SetAttr and seq=ArrayAttr, here and in export } elem.SetAttribute(attrname, value); } }