Exemplo n.º 1
0
        public void EmbeddedSamples()
        {
            #region embedded_example
            EmbeddedServer.Instance.StartServer();
            using (var store = EmbeddedServer.Instance.GetDocumentStore("Embedded"))
            {
                using (var session = store.OpenSession())
                {
                    // Your code here
                }
            }
            #endregion

            #region start_server
            // Start RavenDB Embedded Server with default options
            EmbeddedServer.Instance.StartServer();
            #endregion

            #region start_server_with_options

            EmbeddedServer.Instance.StartServer(new ServerOptions
            {
                DataDirectory = "C:\\RavenData",
                ServerUrl     = "http://127.0.0.1:8080"
            });

            #endregion

            #region start_server_with_server_directory_option

            EmbeddedServer.Instance.StartServer(new ServerOptions
            {
                ServerDirectory = @"C:\RavenDB\Server"
            });

            #endregion

            #region get_document_store

            EmbeddedServer.Instance.GetDocumentStore("Embedded");

            #endregion

            #region get_document_store_with_database_options

            var databaseOptions = new DatabaseOptions(new DatabaseRecord
            {
                DatabaseName = "Embedded"
            });
            EmbeddedServer.Instance.GetDocumentStore(databaseOptions);
            #endregion

            #region open_in_browser
            EmbeddedServer.Instance.OpenStudioInBrowser();
            #endregion

            #region security
            var serverOptions = new ServerOptions();
            serverOptions.Secured(
                certificate: "PathToServerCertificate",
                certPassword: "******");
            #endregion

            #region security2
            var serverOptionsWithExec = new ServerOptions();
            var certificate           = new X509Certificate2();
            serverOptionsWithExec.Secured(
                certLoadExec: "powershell",
                certExecArgs: "C:\\secrets\\give_me_cert.ps1",
                serverCertThumbprint: certificate.Thumbprint,
                clientCert: certificate);
            #endregion

            #region run_with_dotnet_path
            EmbeddedServer.Instance.StartServer(new ServerOptions
            {
                FrameworkVersion = "2.1.2",
                DotNetPath       = "PATH_TO_DOTNET_EXEC"
            });
            #endregion
        }