// Create a ZkDataContext object for connecting to ZooKeeper var zk = new ZkDataContext("localhost:2181"); // Create a node in ZooKeeper with data zk.CreateIfNotExists("/my/node", "some data"); // Read the data from the node var data = zk.GetData("/my/node"); // Update the data in the node zk.SetData("/my/node", "new data"); // Delete the node zk.DeleteIfExists("/my/node");
// Create a ZkDataContext object for connecting to ZooKeeper var zk = new ZkDataContext("localhost:2181"); // Subscribe to changes on a node zk.Subscribe("/my/other/node", (path, data) => { // Handle the data update Console.WriteLine($"Node {path} updated to {data}"); }); // Modify the data on the node zk.SetData("/my/other/node", "newer data"); // Unsubscribe from the node zk.Unsubscribe("/my/other/node");The ZkData library is part of the NuGet package manager and can be installed by searching for "ZkData" in the NuGet package manager.