Esempio n. 1
0
        /// <summary>
        /// Generates a single vertex type predefinition
        /// </summary>
        /// <param name="aDefinition">The definition that has been created by the gql</param>
        /// <returns>The corresponding vertex type predefinition</returns>
        private VertexTypePredefinition GenerateAVertexTypePredefinition(GraphDBTypeDefinition aDefinition)
        {
            var result = new VertexTypePredefinition(aDefinition.Name);

            #region extends

            if (aDefinition.ParentType != null && aDefinition.ParentType.Length > 0)
            {
                result.SetSuperTypeName(aDefinition.ParentType);
            }

            #endregion

            #region abstract

            if (aDefinition.IsAbstract)
            {
                result.MarkAsAbstract();
            }

            #endregion

            #region comment

            if (aDefinition.Comment != null && aDefinition.Comment.Length > 0)
            {
                result.SetComment(aDefinition.Comment);
            }

            #endregion

            #region attributes

            if (aDefinition.Attributes != null)
            {
                foreach (var aAttribute in aDefinition.Attributes)
                {
                    result.AddUnknownAttribute(GenerateUnknownAttribute(aAttribute));
                }
            }

            #endregion

            #region incoming edges

            if (aDefinition.BackwardEdgeNodes != null)
            {
                foreach (var aIncomingEdge in aDefinition.BackwardEdgeNodes)
                {
                    result.AddIncomingEdge(GenerateAIncomingEdge(aIncomingEdge));
                }
            }

            #endregion

            #region indices

            if (aDefinition.Indices != null)
            {
                foreach (var aIndex in aDefinition.Indices)
                {
                    result.AddIndex(GenerateIndex(aIndex, aDefinition.Name));
                }
            }

            #endregion

            return result;
        }
        public VertexTypePredefinition ToVertexTypePredefinition()
        {
            VertexTypePredefinition VertexTypePreDef = new VertexTypePredefinition(this.VertexTypeName);

            if (this.IsAbstract)
                VertexTypePreDef.MarkAsAbstract();
            if (this.IsSealed)
                VertexTypePreDef.MarkAsSealed();

            VertexTypePreDef.SetComment(this.Comment);
            VertexTypePreDef.SetSuperTypeName(this.SuperVertexTypeName);

            if (this.Properties != null)
            {
                foreach (var Property in this.Properties)
                {
                    VertexTypePreDef.AddProperty(Property.ToPropertyPredefinition());
                }
            }

            if (this.BinaryProperties != null)
            {
                foreach (var BinaryProperty in this.BinaryProperties)
                {
                    VertexTypePreDef.AddBinaryProperty(BinaryProperty.ToBinaryPropertyPredefinition());
                }
            }

            if (this.Uniques != null)
            {
                foreach (var Unique in this.Uniques)
                {
                    VertexTypePreDef.AddUnique(Unique.ToUniquePredefinition());
                }
            }

            if (this.IncomingEdges != null)
            {
                foreach (var IncomingEdge in this.IncomingEdges)
                {
                    VertexTypePreDef.AddIncomingEdge(IncomingEdge.ToIncomingEdgePredefinition());
                }
            }

            if (this.OutgoingEdges != null)
            {
                foreach (var OutgoingEdge in this.OutgoingEdges)
                {
                    VertexTypePreDef.AddOutgoingEdge(OutgoingEdge.ToOutgoingEdgePredefinition());
                }
            }

            if (this.Indices != null)
            {
                foreach (var Index in this.Indices)
                {
                    VertexTypePreDef.AddIndex(Index.ToIndexPredefinition());
                }
            }
            return VertexTypePreDef;
        }