public override int GetOrCreateId(string name) { int?id = TokenRegistry.getId(name); if (id != null) { return(id.Value); } // Let's create it try { return(CreateToken(name)); } catch (ReadOnlyDbException e) { throw new TransactionFailureException(e.Message, e); } catch (Exception e) { throw new TransactionFailureException("Could not create token.", e); } }
/// <summary> /// Create and put new token in cache. /// </summary> /// <param name="name"> token name </param> /// <returns> newly created token id </returns> /// <exception cref="KernelException"> </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: protected synchronized int createToken(String name) throws org.neo4j.internal.kernel.api.exceptions.KernelException protected internal override int CreateToken(string name) { lock (this) { int?id = TokenRegistry.getId(name); if (id != null) { return(id.Value); } id = _tokenCreator.createToken(name); try { TokenRegistry.put(new NamedToken(name, id.Value)); } catch (NonUniqueTokenException e) { throw new System.InvalidOperationException("Newly created token should be unique.", e); } return(id.Value); } }