コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void before() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void Before()
        {
            _db             = ( GraphDatabaseAPI )(new TestGraphDatabaseFactory()).newImpermanentDatabaseBuilder().setConfig(GraphDatabaseSettings.record_id_batch_size, "1").newGraphDatabase();
            _kernel         = _db.DependencyResolver.resolveDependency(typeof(Kernel));
            _stateHolder    = new DatabaseSchemaState(NullLogProvider.Instance);
            _indexStoreView = _indexStoreView();

            using (Transaction tx = _kernel.beginTransaction(@implicit, AUTH_DISABLED))
            {
                _labelId = tx.TokenWrite().labelGetOrCreateForName(_first.name());
                tx.TokenWrite().labelGetOrCreateForName(_second.name());
                tx.Success();
            }
        }
コード例 #2
0
        DatabaseSchemaState IDatabaseSchemaChecker.CheckDatabaseSchemaCompatibility(out Exception exception)
        {
            DatabaseSchemaState result = DatabaseSchemaState.SchemaRequiresUpdate;

            exception = null;
            if (DataStoreProvider != null)
            {
                try {
                    IDataStore dataStore = DataStoreProvider.CreateSchemaCheckingStore(out var disposableObjects);
                    if (dataStore != null)
                    {
                        if (dataStore is InMemoryDataStore)
                        {
                            var explorer = dataStore as IDataStoreSchemaExplorer; {
                                string[] tablesList = explorer.GetStorageTablesList(true);
                                if (tablesList.Length > 0)
                                {
                                    result = DatabaseSchemaState.SchemaExists;
                                }
                            }
                        }
                        else
                        {
                            using (UnitOfWork unitOfWork = CreateUnitOfWork(dataStore, disposableObjects)) {
                                if (UpdateSchemaResult.SchemaExists == unitOfWork.UpdateSchema(true, GetPersistentClasses()))
                                {
                                    result = DatabaseSchemaState.SchemaExists;
                                }
                            }
                        }
                    }
                }
                catch (UnableToOpenDatabaseException e) {
                    exception = e;
                    result    = DatabaseSchemaState.DatabaseMissing;
                }
                catch (SchemaCorrectionNeededException e) {
                    exception = e;
                    result    = DatabaseSchemaState.SchemaRequiresUpdate;
                }
                catch (Exception e) {
                    exception = e;
                }
            }
            return(result);
        }