Пример #1
0
        private static void Main(string[] args)
        {
            Stopwatch sw1 = new Stopwatch();

            sw1.Start();
            Console.WriteLine("Connecting to server...\n");
            var stream = new NamedPipeClientStream(".", "datakit",
                                                   PipeDirection.InOut, PipeOptions.None, TokenImpersonationLevel.None);

            stream.Connect();

            // You can also use a TCP Connection, for example
            // var tcpClient = new TcpClient();
            // tcpClient.Connect("10.0.75.2", 5640);
            // var stream = tcpClient.GetStream();

            Console.WriteLine("Creating new client...\n");
            _client = Client.FromStream(stream);
            Console.WriteLine("Checking Version...\n");
            _client.Version(Constants.DefaultMsize, Constants.DefaultVersion);
            Console.WriteLine("Attaching...\n");
            _client.Attach(Constants.RootFid, Constants.NoFid, "anybody", "/");
            sw1.Stop();
            Console.WriteLine($"Connection took ${sw1.Elapsed}");

            Mkdir(new[] { "branch", "master", "transactions", "test", "rw", "foo" });
            for (var i = 0; i < 200; i++)
            {
                Stopwatch sw = new Stopwatch();
                sw.Start();
                Console.WriteLine($"Writing {i}...");
                Create(new[] { "branch", "master", "transactions", "test", "rw", "foo", "{i}" });
                sw.Stop();
                Console.WriteLine($"Write took={sw.Elapsed}");
            }
            Commit(new[] { "branch", "master", "transactions", "test", "ctl" });
        }