Exemplo n.º 1
0
    private static void Main(string[] args)
    {
        var s = new Social();

        s.Setup();

        var friendsOfFriends = s.FriendsOfAFriend(new Person {
            Name = "Joe"
        });

        Console.WriteLine($"Joe's friends (of friends)");
        foreach (var fof in friendsOfFriends)
        {
            Console.WriteLine($"\t{fof.Name}");
        }

        Console.WriteLine();

        var commonFriends = s.CommonFriends(new Person {
            Name = "Joe"
        }, new Person {
            Name = "Sally"
        });

        Console.WriteLine("Joe and Sally's common friends");
        foreach (var friend in commonFriends)
        {
            Console.WriteLine($"\t{friend.Name}");
        }

        Console.WriteLine();

        var connectingNames = s.ConnectingPaths(new Person {
            Name = "Joe"
        }, new Person {
            Name = "Billy"
        });

        Console.WriteLine("Path to Billy");
        foreach (var name in connectingNames)
        {
            Console.WriteLine($"\t{name}");
        }
    }
Exemplo n.º 2
0
    private static void SocialMain(string[] args)
    {
        using (var s = new Social())
        {
            s.Setup();

            var friendsOfFriends = s.FriendsOfAFriend("Joe");
            Console.WriteLine($"Joe's friends (of friends)");
            foreach (var fof in friendsOfFriends)
            {
                Console.WriteLine($"\t{fof["foaf"].As<INode>()["name"].As<string>()}");
            }

            Console.WriteLine();

            var commonFriends = s.CommonFriends("Joe", "Sally");
            Console.WriteLine("Joe and Sally's common friends");
            foreach (var friend in commonFriends)
            {
                Console.WriteLine($"\t{friend["friend"].As<string>()}");
            }

            Console.WriteLine();

            var connectingNames = s.ConnectingPaths("Joe", "Billy");
            Console.WriteLine("Path to Billy");
            foreach (var record in connectingNames)
            {
                var path = record["path"].As <IPath>();
                foreach (var friend in path.Nodes)
                {
                    Console.WriteLine($"\t{friend["name"].As<string>()}");
                }
            }
        }
    }