Beispiel #1
0
 public MsKqlKernel(
     string name,
     KqlConnectionDetails connectionDetails,
     ToolsServiceClient client) : base(name, client)
 {
     _connectionDetails = connectionDetails ?? throw new ArgumentException("Value cannot be null or whitespace.", nameof(connectionDetails));
 }
        public void Should_parse_doc_change_correctly_with_different_line_endings(string lineEnding)
        {
            string oldText                 = string.Join(lineEnding, "abc", "def", "", "abc", "abcdef");
            int    oldTextLineCount        = 5;
            int    oldTextLastCharacterNum = 6;
            string newText                 = string.Join(lineEnding, "abc", "def");
            var    testUri                 = new Uri("untitled://test");

            var docChange = ToolsServiceClient.GetDocumentChangeForText(testUri, newText, oldText);

            docChange.ContentChanges.Length
            .Should()
            .Be(1);
            docChange.ContentChanges[0].Range.End.Line
            .Should()
            .Be(oldTextLineCount - 1);
            docChange.ContentChanges[0].Range.End.Character
            .Should()
            .Be(oldTextLastCharacterNum);
            docChange.ContentChanges[0].Range.Start.Line
            .Should()
            .Be(0);
            docChange.ContentChanges[0].Range.Start.Character
            .Should()
            .Be(0);
            docChange.ContentChanges[0].Text
            .Should()
            .Be(newText);
            docChange.TextDocument.Uri
            .Should()
            .Be(testUri.AbsolutePath);
            docChange.TextDocument.Version
            .Should()
            .Be(1);
        }
        internal static async Task <bool> ConnectAsync(this ToolsServiceClient serviceClient, Uri ownerUri, KqlConnectionDetails kqlDetails)
        {
            var connectionOptions = new Dictionary <string, string>
            {
                { "server", kqlDetails.Cluster },
                { "database", kqlDetails.Database },
                { "azureAccountToken", kqlDetails.Token },
                { "authenticationType", kqlDetails.AuthenticationType }
            };

            var connectionParams = new ConnectParams
            {
                OwnerUri   = ownerUri.AbsolutePath,
                Connection = new ConnectionDetails
                {
                    Options = connectionOptions
                }
            };

            return(await serviceClient.ConnectAsync(connectionParams));
        }
Beispiel #4
0
        public async Task <Kernel> ConnectKernelAsync(KernelInfo kernelInfo)
        {
            if (string.IsNullOrWhiteSpace(PathToService))
            {
                throw new InvalidOperationException($"{nameof(PathToService)} cannot be null or whitespace.");
            }

            var connectionDetails = await BuildConnectionDetailsAsync();

            var sqlClient = new ToolsServiceClient(PathToService);

            var kernel = new MsKqlKernel(
                $"kql-{kernelInfo}",
                connectionDetails,
                sqlClient)
                         .UseValueSharing();

            await kernel.ConnectAsync();

            return(kernel);
        }
    public override async Task <Kernel> ConnectKernelAsync(KernelInfo kernelInfo)
    {
        if (string.IsNullOrWhiteSpace(PathToService))
        {
            throw new InvalidOperationException($"{nameof(PathToService)} cannot be null or whitespace.");
        }

        var sqlClient = new ToolsServiceClient(PathToService, $"--parent-pid {Environment.ProcessId}");

        var kernel = new MsSqlKernel(
            $"sql-{kernelInfo}",
            ConnectionString,
            sqlClient)
                     .UseValueSharing();

        kernel.RegisterForDisposal(sqlClient);

        await kernel.ConnectAsync();

        return(kernel);
    }