Exemple #1
0
        public override Task <Kernel> CreateKernelAsync(
            SqlConnectionOptions options,
            KernelInvocationContext context)
        {
            var kernel = new MsSqlKernel(
                options.KernelName,
                options.ConnectionString);

            return(Task.FromResult <Kernel>(kernel));
        }
Exemple #2
0
        public override async Task <Kernel> CreateKernelAsync(
            MsSqlConnectionOptions options,
            KernelInvocationContext context)
        {
            var resolvedPackageReferences = ((ISupportNuget)context.HandlingKernel).ResolvedPackageReferences;
            // Walk through the packages looking for the package that endswith the name "Microsoft.SqlToolsService"
            // and grab the packageroot
            var    runtimePackageIdSuffix = "native.Microsoft.SqlToolsService";
            var    root          = resolvedPackageReferences.FirstOrDefault(p => p.PackageName.EndsWith(runtimePackageIdSuffix, StringComparison.OrdinalIgnoreCase));
            string pathToService = "";

            if (root != null)
            {
                // Extract the platform 'osx-x64' from the package name 'runtime.osx-x64.native.microsoft.sqltoolsservice'
                string[] packageNameSegments = root.PackageName.Split(".");
                if (packageNameSegments.Length > 2)
                {
                    string platform = packageNameSegments[1];

                    // Build the path to the MicrosoftSqlToolsServiceLayer executable by reaching into the resolve nuget package
                    // assuming a convention for native binaries.
                    pathToService = Path.Combine(
                        root.PackageRoot,
                        "runtimes",
                        platform,
                        "native",
                        "MicrosoftSqlToolsServiceLayer");

                    if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                    {
                        pathToService += ".exe";
                    }
                }
            }

            var kernel = new MsSqlKernel(
                pathToService,
                options.KernelName,
                options.ConnectionString);

            await kernel.ConnectAsync();

            if (options.CreateDbContext)
            {
                await InitializeDbContextAsync(options, context);
            }

            return(kernel);
        }
        public override async Task <Kernel> CreateKernelAsync(
            MsSqlConnectionOptions options,
            KernelInvocationContext context)
        {
            var kernel = new MsSqlKernel(
                options.KernelName,
                options.ConnectionString);

            if (options.CreateDbContext)
            {
                await InitializeDbContextAsync(options, context);
            }

            return(kernel);
        }