//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private T getOrCreatePart(Offset key, org.neo4j.function.ThrowingSupplier<T,java.io.IOException> factory) throws java.io.UncheckedIOException private T GetOrCreatePart(Offset key, ThrowingSupplier <T, IOException> factory) { T existing = Cache[key]; if (existing != default(T)) { return(existing); } // Instantiate from factory. Do this under lock so that we coordinate with any concurrent call to close. // Concurrent calls to instantiating parts won't contend with each other since there's only // a single writer at a time anyway. InstantiateCloseLock.@lock(); try { AssertOpen(); return(Cache.computeIfAbsent(key, k => { try { return factory.Get(); } catch (IOException e) { throw new UncheckedIOException(e); } })); } finally { InstantiateCloseLock.unlock(); } }
/// <summary> /// Select the part corresponding to the given CoordinateReferenceSystem. Creates the part if needed, /// and rethrows any create time exception as a RuntimeException. /// </summary> /// <param name="crs"> target coordinate reference system </param> /// <returns> selected part </returns> internal virtual T UncheckedSelect(CoordinateReferenceSystem crs) { T existing = Cache[crs]; if (existing != default(T)) { return(existing); } // Instantiate from factory. Do this under lock so that we coordinate with any concurrent call to close. // Concurrent calls to instantiating parts won't contend with each other since there's only // a single writer at a time anyway. InstantiateCloseLock.@lock(); try { AssertOpen(); return(Cache.computeIfAbsent(crs, key => { try { return _factory.newSpatial(crs); } catch (IOException e) { throw new UncheckedIOException(e); } })); } finally { InstantiateCloseLock.unlock(); } }