Beispiel #1
0
        /// <summary>
        /// Creates the ddl of a type.
        /// </summary>
        /// <param name="myVertexType">The vertex type.</param>
        private String CreateGraphDDL_EdgeType(IEdgeType myEdgeType)
        {
            var stringBuilder = new StringBuilder();
            var delimiter = ", ";
            stringBuilder.AppendFormat("{0} ", myEdgeType.Name);

            #region parent type

            //EXTENDS ...
            if (myEdgeType.HasParentType)
            {
                stringBuilder.AppendFormat("{0} {1} ", S_EXTENDS.ToUpperString(), myEdgeType.ParentEdgeType.Name);
            }

            #endregion

            #region attributes
            //are there attributes
            if (myEdgeType.HasAttributes(false))
            {
                //so, there are attributes that are no incoming edges
                stringBuilder.Append(String.Concat(S_ATTRIBUTES.ToUpperString(), " ", S_BRACKET_LEFT));

                #region properties

                if (myEdgeType.GetAttributeDefinitions(false).Any(aAttribute => aAttribute.Kind == AttributeType.Property))
                    stringBuilder.Append(String.Concat(CreateGraphDDLOfProperties(myEdgeType.GetPropertyDefinitions(false))));

                #endregion

                if (stringBuilder.ToString().EndsWith(delimiter))
                    stringBuilder.RemoveEnding(delimiter.Length);

                stringBuilder.Append(String.Concat(S_BRACKET_RIGHT));
            }

            #endregion

            return stringBuilder.ToString();
        }
        private void AddDefaultValues(ref EdgePredefinition edgeDef, IEdgeType myEdgeType)
        {
            var mandatoryProps = myEdgeType.GetPropertyDefinitions(true).Where(_ => _.IsMandatory);

            foreach (var propertyDefinition in mandatoryProps)
            {
                if (edgeDef.StructuredProperties == null || 
                    !edgeDef.StructuredProperties.ContainsKey(propertyDefinition.Name))
                    edgeDef.AddStructuredProperty(propertyDefinition.Name, propertyDefinition.DefaultValue);
            }
        }
Beispiel #3
0
        private IDictionary<string, object> GetEdgeProperties(ISingleEdge aSingleEdge, IEdgeType myInnerEdgeType)
        {
            Dictionary<String, Object> result = new Dictionary<string, object>();

            #region properties

            if (myInnerEdgeType != null)
            {
                foreach (var aProperty in myInnerEdgeType.GetPropertyDefinitions(true))
                {
                    if (aSingleEdge.HasProperty(aProperty.ID))
                    {
                        result.Add(aProperty.Name, aProperty.GetValue(aSingleEdge));
                    }
                    else
                    {
                        var tempResult = aProperty.GetValue(aSingleEdge);

                        if (tempResult != null)
                        {
                            result.Add(aProperty.Name, tempResult);
                        }
                    }
                }
            }

            #endregion

            #region unstructured data

            foreach (var aUnstructuredProperty in aSingleEdge.GetAllUnstructuredProperties())
            {
                result.Add(aUnstructuredProperty.PropertyName, aUnstructuredProperty.Property);
            }

            #endregion

            return result;
        }