예제 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void dumpFile(System.Func<java.io.File, org.neo4j.kernel.impl.store.StoreFactory> createStoreFactory, String fileName) throws Exception
        private static void DumpFile(System.Func <File, StoreFactory> createStoreFactory, string fileName)
        {
            File file = new File(fileName);

            IdRange[] ids = null;               // null means all possible ids

            if (file.File)
            {
                /* If file exists, even with : in its path, then accept it straight off. */
            }
            else if (!file.Directory && file.Name.IndexOf(':') != -1)
            {
                /* Now we know that it is not a directory either, and that the last component
                 * of the path contains a colon, thus it is very likely an attempt to use the
                 * id-specifying syntax. */

                int idStart = fileName.LastIndexOf(':');

                string[] idStrings = fileName.Substring(idStart + 1).Split(",", true);
                ids = new IdRange[idStrings.Length];
                for (int i = 0; i < ids.Length; i++)
                {
                    ids[i] = IdRange.Parse(idStrings[i]);
                }
                file = new File(fileName.Substring(0, idStart));

                if (!file.File)
                {
                    throw new System.ArgumentException("No such file: " + fileName);
                }
            }
            DatabaseFile databaseFile = DatabaseFile.fileOf(file.Name).orElseThrow(IllegalArgumentExceptionSupplier(fileName));
            StoreType    storeType    = StoreType.typeOf(databaseFile).orElseThrow(IllegalArgumentExceptionSupplier(fileName));

            using (NeoStores neoStores = createStoreFactory(file).openNeoStores(storeType))
            {
                switch (storeType.innerEnumValue)
                {
                case StoreType.InnerEnum.META_DATA:
                    DumpMetaDataStore(neoStores);
                    break;

                case StoreType.InnerEnum.NODE:
                    DumpNodeStore(neoStores, ids);
                    break;

                case StoreType.InnerEnum.RELATIONSHIP:
                    DumpRelationshipStore(neoStores, ids);
                    break;

                case StoreType.InnerEnum.PROPERTY:
                    DumpPropertyStore(neoStores, ids);
                    break;

                case StoreType.InnerEnum.SCHEMA:
                    DumpSchemaStore(neoStores, ids);
                    break;

                case StoreType.InnerEnum.PROPERTY_KEY_TOKEN:
                    DumpPropertyKeys(neoStores, ids);
                    break;

                case StoreType.InnerEnum.LABEL_TOKEN:
                    DumpLabels(neoStores, ids);
                    break;

                case StoreType.InnerEnum.RELATIONSHIP_TYPE_TOKEN:
                    DumpRelationshipTypes(neoStores, ids);
                    break;

                case StoreType.InnerEnum.RELATIONSHIP_GROUP:
                    DumpRelationshipGroups(neoStores, ids);
                    break;

                default:
                    throw new System.ArgumentException("Unsupported store type: " + storeType);
                }
            }
        }