private void LoadTypes(XElement parentNode, GraphObjectType kind)
        {
            IEnumerable <XElement> types = kind == GraphObjectType.Vertex ?
                                           parentNode.Elements(nameProvider.VertexTypeElement).Where(e => e.Attribute(nameProvider.TypeKindAttribute).Value == nameProvider.TypeKindAttributeValueVertex) :
                                           parentNode.Elements(nameProvider.EdgeTypeElement).Where(e => e.Attribute(nameProvider.TypeKindAttribute).Value == nameProvider.TypeKindAttributeValueEdge);

            if (types != null)
            {
                foreach (XElement typeElement in types)
                {
                    string id = typeElement.Attribute(nameProvider.TypeExternalIdAttribute)?.Value;
                    ThrowErrorIfNull(id, "Missing type external id.");

                    string internalId = typeElement.Attribute(nameProvider.TypeInternalIdAttribute)?.Value;
                    ThrowErrorIfNull(id, "Missing type internal id.");
                    int internalTypeId = 0;
                    if (!Int32.TryParse(internalId, out internalTypeId))
                    {
                        ThrowParseException("Internal id not convertible to integer.");
                    }

                    string name = typeElement.Element(nameProvider.TypeNameElement)?.Value;
                    ThrowErrorIfNull(id, "Missing type name.");

                    string description = typeElement.Element(nameProvider.TypeDescriptionElement)?.Value;
                    ThrowErrorIfNull(id, "Missing type description.");

                    string orientedString = typeElement.Attribute(nameProvider.TypeIsOrientedEdgeAttribute)?.Value;
                    bool   oriented       = false;
                    if (orientedString != null)
                    {
                        oriented = Boolean.Parse(orientedString);
                    }

                    string directContentString = typeElement.Attribute(nameProvider.TypeIsDirectContentAttribute)?.Value;
                    bool   directContent       = false;
                    if (directContentString != null)
                    {
                        directContent = Boolean.Parse(directContentString);
                    }

                    Guid guid = Guid.Parse(id);                                                                        // TODO checker les erreurs

                    GraphObjectTypeInfo typeInfo = new GraphObjectTypeInfo(guid, name, kind, oriented, directContent); // TODO fixer correctement direct_content
                    typeInfo.Description = description;

                    typeNumericAliasTable[internalTypeId] = typeInfo;
                }
            }
        }
        public static string ToLetter(this GraphObjectType gt)
        {
            switch (gt)
            {
            case GraphObjectType.Vertex:
                return("v");

            case GraphObjectType.Edge:
                return("e");

            default:
                return("!");
            }
        }
 public GraphObjectTypeInfo(Guid id, string name, GraphObjectType type, bool oriented_edge = false, bool direct_content = false)
 {
     if (type == GraphObjectType.Edge && direct_content == true)
     {
         throw new ArgumentException();
     }
     if (type == GraphObjectType.Vertex && oriented_edge == true)
     {
         throw new ArgumentException();
     }
     Id            = id;
     Name          = name;
     Type          = type;
     Oriented      = oriented_edge;
     DirectContent = direct_content;
 }
 public GraphObjectTypeInfo(string id, string name, GraphObjectType type, bool oriented_edge = false, bool direct_content = false)
     : this(Guid.Parse(id), name, type, oriented_edge, direct_content)
 {
 }
Exemplo n.º 5
0
 public bool isGraphObjectType(object tag, GraphObjectType got)
 {
     // Check graph object type
     return tag != null && (GraphObjectType)tag == got;
 }
Exemplo n.º 6
0
 public void makeGraphObjectType(ref object tag, GraphObjectType got)
 {
     // Create a graph object type
     tag = new GraphObjectType();
     tag = got;
 }
Exemplo n.º 7
0
 public bool isGraphObjectType(object tag, GraphObjectType got)
 {
     // Check graph object type
     return(tag != null && (GraphObjectType)tag == got);
 }
Exemplo n.º 8
0
 public void makeGraphObjectType(ref object tag, GraphObjectType got)
 {
     // Create a graph object type
     tag = new GraphObjectType();
     tag = got;
 }