Source

Neo4jClient / Test / ApiUsageIdeas.cs

Full commit
using System;
using Neo4jClient.Test.Domain;
using Neo4jClient.Test.Relationships;

namespace Neo4jClient.Test
{
    // This class just documents how the API could be consumed. It was an
    // initial scratching ground before any of the original signatures,
    // interfaces, or functionality was put in place. Right now it has no
    // other requirements than just compiling (so as to assert backwards
    // compatibility with consumers). It is mainly kept for historical
    // purposes.
    class ApiUsageIdeas
    {
        void Foo()
        {
            IGraphClient graph = new GraphClient(new Uri(""));

            // Based on http://wiki.neo4j.org/content/Image:Warehouse.png

            // Can create nodes from POCOs
            var frameStore = graph.Create(
                new StorageLocation { Name = "Frame Store" });
            var mainStore = graph.Create(
                new StorageLocation { Name = "Main Store" });

            // Can create a node with outgoing relationships
            var frame = graph.Create(
                new Part { Name = "Frame" },
                new StoredIn(frameStore));

            // Can create multiple outgoing relationships and relationships with payloads
            graph.Create(
                new Product { Name = "Trike", Weight = 2 },
                new StoredIn(mainStore),
                new Requires(frame, new Requires.Payload { Count = 1 }));

            // Can create relationships in both directions
            graph.Create(
                new Part { Name = "Pedal" },
                new StoredIn(frameStore),
                new Requires(frame, new Requires.Payload { Count = 2 })
                    { Direction = RelationshipDirection.Incoming });

            var wheel = graph.Create(
                 new Part { Name = "Wheel" },
                 new Requires(frame, new Requires.Payload { Count = 2 })
                    { Direction = RelationshipDirection.Incoming });

            // Can create implicit incoming relationships
            graph.Create(
                new StorageLocation { Name = "Wheel Store" },
                new StoredIn(wheel));

            // Can create relationships against the root node
            graph.Create(
                new StorageLocation {Name = "Auxillary Store"},
                new StoredIn(wheel),
                new OwnedBy(NodeReference.RootNode));
        }
    }
}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.