コード例 #1
0
 public IOrientServerConnection CreateServerConnection(IOrientDBRecordSerializer <byte[]> serializer, ILogger logger)
 {
     _logger = logger;
     if (_serverConnection == null)
     {
         _serverConnection = new OrientDBBinaryServerConnection(_options, serializer, _logger);
     }
     _logger.LogInformation("OrientDB.Net.ConnectionProtocols.Binary Initialized.");
     return(_serverConnection);
 }
        public void ItShouldThrowAnExceptionWhenCallingDatabaseExistsWithANullOrZeroLengthDatabaseName()
        {
            var options = new DatabaseConnectionOptions
            {
            };
            Mock <IOrientDBRecordSerializer <byte[]> > mockSerializer = new Mock <IOrientDBRecordSerializer <byte[]> >();
            Mock <ILogger> mockLogger = new Mock <ILogger>();

            var conn = new OrientDBBinaryServerConnection(options, mockSerializer.Object, mockLogger.Object);

            Assert.Throws(typeof(ArgumentException), () => conn.DatabaseExists(null, StorageType.Memory));
        }
コード例 #3
0
        public static void CreateDatabase(ServerConnectionOptions serverConnectionOptions, string database, IOrientDBRecordSerializer <byte[]> serializer)
        {
            using (OrientDBBinaryServerConnection serverConnection = new OrientDBBinaryServerConnection(serverConnectionOptions, serializer))
            {
                serverConnection.Open();

                if (serverConnection.DatabaseExists(database, StorageType.PLocal))
                {
                    serverConnection.DropDatabase(database, StorageType.PLocal);
                }

                var databaseConnection = serverConnection.CreateDatabase(database, DatabaseType.Graph, StorageType.PLocal);
            }
        }
コード例 #4
0
        public static void DeleteDatabase(ServerConnectionOptions serverConnectionOptions, string database, IOrientDBRecordSerializer <byte[]> serializer)
        {
            using (OrientDBBinaryServerConnection serverConnection = new OrientDBBinaryServerConnection(serverConnectionOptions, serializer))
            {
                serverConnection.Open();

                if (!serverConnection.DatabaseExists(database, StorageType.PLocal))
                {
                    return;
                }

                serverConnection.DropDatabase(database, StorageType.PLocal);
            }
        }
コード例 #5
0
        static void Main(string[] args)
        {
            if (args.Length != 5)
            {
                throw new ArgumentException($"{args.Length} arguments present, only 5 are required: hostname username password port database");
            }

            // Create a new instance of an IOrientDBRecordSerializer of type byte[].
            IOrientDBRecordSerializer <byte[]> serializer = new OrientDBRecordCSVSerializer();

            // Instantiate and fill in the ServerConnectionOptions.
            ServerConnectionOptions options = new ServerConnectionOptions
            {
                HostName = args[0],
                UserName = args[1],
                Password = args[2],
                Port     = int.Parse(args[3]),
                PoolSize = 1
            };

            // Create a Server Connection.
            using (OrientDBBinaryServerConnection serverConnection = new OrientDBBinaryServerConnection(options, serializer))
            {
                // Check if the database exists.
                if (serverConnection.DatabaseExists(args[4], StorageType.PLocal))
                {
                    throw new Exception($"Database {args[4]} already exists!");
                }

                // Create a database.
                using (OrientDBBinaryConnection databaseConnection = serverConnection.CreateDatabase(args[4], DatabaseType.Graph, StorageType.PLocal))
                {
                    // Open database connection.
                    databaseConnection.Open();
                }

                // Drop the database.
                serverConnection.DropDatabase(args[4], StorageType.PLocal);
            }
        }