private static IComparable GetValue(this IPropertyDefinition myProperty, IEdge myEdge)
        {
            if (myProperty.RelatedType == null)
                throw new ArgumentException("A property with nor related type is not allowed.");

            if (!myProperty.RelatedType.Name.Equals(GlobalConstants.Edge))
                return myEdge.GetProperty<IComparable>(myProperty.ID);

            switch (myProperty.Name)
            {
                case GlobalConstants.EdgeDotComment:
                    return myEdge.Comment;

                case GlobalConstants.EdgeDotCreationDate:
                    return myEdge.CreationDate;

                case GlobalConstants.EdgeDotModificationDate:
                    return myEdge.ModificationDate;

                case GlobalConstants.EdgeDotEdgeTypeID:
                    return myEdge.EdgeTypeID;

                case GlobalConstants.EdgeDotEdgeTypeName:
                    return myProperty.RelatedType.GetDescendantTypesAndSelf().Where(_ => _.ID == myEdge.EdgeTypeID).Select(__ => __.Name).FirstOrDefault();

                default:
                    throw new System.Exception(
                        "A new property was added to the edeg type Edge, but this switch stement was not changed.");

            }
        }
Пример #2
0
        public void Should_Handle_Edge_Id_As_Parameter()
        {
            using (var cluster = ClusterBuilder()
                                 .AddContactPoint(TestClusterManager.InitialContactPoint)
                                 .WithGraphOptions(new GraphOptions().SetName(GraphTests.GraphName))
                                 .Build())
            {
                var session = cluster.Connect();
                var rs      = session.ExecuteGraph(new SimpleGraphStatement("g.E().has('weight', 0.5)"));

                var markoKnowsVadasEdge = rs.To <IEdge>().First();

                var rsById = session.ExecuteGraph(new SimpleGraphStatement("g.E(edgeId)", new { edgeId = markoKnowsVadasEdge.Id }));
                Assert.NotNull(rsById);
                var byIdResultArray = rsById.ToArray();
                Assert.AreEqual(1, byIdResultArray.Length);

                IEdge byIdMarkoEdge = (Edge)byIdResultArray[0];
                Assert.NotNull(byIdMarkoEdge);
                Assert.AreEqual(markoKnowsVadasEdge.Id, byIdMarkoEdge.Id);
                Assert.AreEqual(markoKnowsVadasEdge.Label, byIdMarkoEdge.Label);
                Assert.AreEqual(markoKnowsVadasEdge.GetProperty("weight").Value.ToDouble(),
                                byIdMarkoEdge.GetProperty("weight").Value.ToDouble());
            }
        }
        private static IComparable GetValue(this IPropertyDefinition myProperty, IEdge myEdge)
        {
            if (myProperty.RelatedType == null)
            {
                throw new ArgumentException("A property with nor related type is not allowed.");
            }

            if (!myProperty.RelatedType.Name.Equals(GlobalConstants.Edge))
            {
                return(myEdge.GetProperty <IComparable>(myProperty.ID));
            }

            switch (myProperty.Name)
            {
            case GlobalConstants.EdgeDotComment:
                return(myEdge.Comment);

            case GlobalConstants.EdgeDotCreationDate:
                return(myEdge.CreationDate);

            case GlobalConstants.EdgeDotModificationDate:
                return(myEdge.ModificationDate);

            case GlobalConstants.EdgeDotEdgeTypeID:
                return(myEdge.EdgeTypeID);

            case GlobalConstants.EdgeDotEdgeTypeName:
                return(myProperty.RelatedType.GetDescendantTypesAndSelf().Where(_ => _.ID == myEdge.EdgeTypeID).Select(__ => __.Name).FirstOrDefault());

            default:
                throw new System.Exception(
                          "A new property was added to the edeg type Edge, but this switch stement was not changed.");
            }
        }
Пример #4
0
 private static IComparable GetValue(this IPropertyDefinition myProperty, IEdge myEdge)
 {
     return myEdge.GetProperty<IComparable>(myProperty.ID);
 }