コード例 #1
0
        public void SetBlock(int x, int y, int z, Block block)
        {
            x = NumericsHelper.Modulo(x, 16);
            z = NumericsHelper.Modulo(z, 16);
            var sectionIndex = y >> 4;

            var success = Sections[sectionIndex].SetBlock(x, y & 15, z, block);

            // Palette dynamic sizing
            if (!success)
            {
                var oldSection = Sections[sectionIndex];
                var bpb        = oldSection.BitsPerBlock;
                bpb += 1;
                var newSection = new ChunkSection(bpb, sectionIndex);
                for (int sx = 0; sx < 16; sx++)
                {
                    for (int sy = 0; sy < 16; sy++)
                    {
                        for (int sz = 0; sz < 16; sz++)
                        {
                            // Seems to be the safest way to do this. A bit expensive, though...
                            newSection.SetBlock(sx, sy, sz, oldSection.GetBlock(sx, sy, sz));
                        }
                    }
                }

                Sections[sectionIndex] = newSection;
                SetBlock(x, y, z, block);
            }
        }
コード例 #2
0
        public void Load(string regionFile)
        {
            var regionNbt = new NbtFile();

            try
            {
                regionNbt.LoadFromFile(regionFile);
            }
            catch (Exception)
            {
                File.Delete(regionFile);
                File.Move(regionFile + ".bak", regionFile);
                regionNbt.LoadFromFile(regionFile);
            }
            finally
            {
                File.Delete(regionFile + ".bak");
            }

            NbtCompound regionCompound = regionNbt.RootTag;
            var         chunksNbt      = regionCompound["Chunks"] as NbtList;

            foreach (var chunkNbt in chunksNbt)
            {
                var chunk = GetChunkFromNbt((NbtCompound)chunkNbt);
                var index = (NumericsHelper.Modulo(chunk.X, cubicRegionSize), NumericsHelper.Modulo(chunk.Z, cubicRegionSize));
                LoadedChunks[index.Item1, index.Item2] = chunk;
            }
            regionNbt      = null;
            regionCompound = null;
            GC.Collect();
            IsDirty = false;
        }
コード例 #3
0
        public Block GetBlock(int x, int y, int z)
        {
            x = NumericsHelper.Modulo(x, 16);
            z = NumericsHelper.Modulo(z, 16);

            return(Sections[y >> 4].GetBlock(x, y & 15, z));
        }
コード例 #4
0
ファイル: TestTransaction.cs プロジェクト: arkoc/IconSDK.Net
        public void TestMessageTransactionBuilder()
        {
            var builder = new MessageTransactionBuilder();

            builder.NID        = 2;
            builder.PrivateKey = PrivateKey.Random();
            builder.To         = "hx54f7853dc6481b670caf69c5a27c7c8fe5be8269";
            builder.StepLimit  = NumericsHelper.ICX2Loop("0.1");
            builder.Value      = NumericsHelper.ICX2Loop("1");
            builder.Timestamp  = 100000000000;
            builder.Message    = "testMessage";

            var tx = builder.Build();

            Assert.True(Signer.Verify(tx.Signature, tx.Hash, tx.From));

            var hashSource = new Dictionary <string, object>()
            {
                ["version"]   = "0x3",
                ["nid"]       = "0x2",
                ["from"]      = Addresser.Create(builder.PrivateKey).ToString(),
                ["to"]        = "hx54f7853dc6481b670caf69c5a27c7c8fe5be8269",
                ["stepLimit"] = "0x16345785d8a0000",
                ["value"]     = "0xde0b6b3a7640000",
                ["timestamp"] = "0x174876e800",
                ["dataType"]  = "message",
                ["data"]      = new Bytes(Encoding.UTF8.GetBytes(builder.Message)).ToString()
            };

            var hash = Hasher.Digest(hashSource);

            Assert.AreEqual(tx.Hash, hash);
        }
コード例 #5
0
ファイル: Chunk.cs プロジェクト: ObsidianMC/Obsidian
    public void SetBlockEntity(int x, int y, int z, NbtCompound tileEntityData)
    {
        x = NumericsHelper.Modulo(x, 16);
        z = NumericsHelper.Modulo(z, 16);
        var value = (short)((x << 8) | (z << 4) | y);

        this.BlockEntities[value] = tileEntityData;
    }
コード例 #6
0
ファイル: Chunk.cs プロジェクト: roxxel/Obsidian
        public void SetBlockMeta(int x, int y, int z, BlockMeta meta)
        {
            x = NumericsHelper.Modulo(x, 16);
            z = NumericsHelper.Modulo(z, 16);
            var value = (short)((x << 8) | (z << 4) | y);

            this.BlockMetaStore[value] = meta;
        }
コード例 #7
0
ファイル: Chunk.cs プロジェクト: ObsidianMC/Obsidian
    public NbtCompound GetBlockEntity(int x, int y, int z)
    {
        x = NumericsHelper.Modulo(x, 16);
        z = NumericsHelper.Modulo(z, 16);
        var value = (short)((x << 8) | (z << 4) | y);

        return(this.BlockEntities.GetValueOrDefault(value));
    }
コード例 #8
0
ファイル: Chunk.cs プロジェクト: roxxel/Obsidian
        public BlockMeta GetBlockMeta(int x, int y, int z)
        {
            x = NumericsHelper.Modulo(x, 16);
            z = NumericsHelper.Modulo(z, 16);
            var value = (short)((x << 8) | (z << 4) | y);

            return(this.BlockMetaStore.GetValueOrDefault(value));
        }
コード例 #9
0
ファイル: Chunk.cs プロジェクト: roxxel/Obsidian
        public void SetBlock(int x, int y, int z, Block block)
        {
            SetBlockStateId(x, y, z, block.StateId);

            x = NumericsHelper.Modulo(x, 16);
            z = NumericsHelper.Modulo(z, 16);

            Sections[y >> 4].SetBlock(x, y & 15, z, block);
        }
コード例 #10
0
ファイル: Chunk.cs プロジェクト: ObsidianMC/Obsidian
    public void SetBiome(int x, int y, int z, Biomes biome)
    {
        int i = SectionIndex(y);

        x = NumericsHelper.Modulo(x, 16);
        y = (y + 64) % 16 / 4;
        z = NumericsHelper.Modulo(z, 16);

        Sections[i].SetBiome(x, y, z, biome);
    }
コード例 #11
0
ファイル: Chunk.cs プロジェクト: ObsidianMC/Obsidian
    public void SetBlock(int x, int y, int z, Block block)
    {
        int i = SectionIndex(y);

        x = NumericsHelper.Modulo(x, 16);
        y = NumericsHelper.Modulo(y, 16);
        z = NumericsHelper.Modulo(z, 16);

        Sections[i].SetBlock(x, y, z, block);
    }
コード例 #12
0
ファイル: Chunk.cs プロジェクト: ObsidianMC/Obsidian
    public Block GetBlock(int x, int y, int z)
    {
        var i = SectionIndex(y);

        x = NumericsHelper.Modulo(x, 16);
        y = NumericsHelper.Modulo(y, 16);
        z = NumericsHelper.Modulo(z, 16);

        return(Sections[i].GetBlock(x, y, z));
    }
コード例 #13
0
ファイル: Chunk.cs プロジェクト: ObsidianMC/Obsidian
    public Biomes GetBiome(int x, int y, int z)
    {
        var i = SectionIndex(y);

        x = NumericsHelper.Modulo(x, 16);
        z = NumericsHelper.Modulo(z, 16);
        y = (y + 64) % 16 / 4;

        return(Sections[i].GetBiome(x, y, z));
    }
コード例 #14
0
        public ShapeFile(BinaryReader br)
        {
            Initialize();

            FileCode = NumericsHelper.ReverseInt(br.ReadInt32());             // Big, Reverse for actual value

            for (var i = 0; i < 5; i++)
            {
                br.ReadInt32();                                      // Skip 5 empty Integer (4-byte) slots
            }
            FileLength  = NumericsHelper.ReverseInt(br.ReadInt32()); // Big, Reverse for actual value
            Version     = br.ReadInt32();
            ShapeType   = (ShapeTypeEnum)br.ReadInt32();
            BoundingBox = new BoundingBoxZ(br);
        }
コード例 #15
0
        public static void SendICX()
        {
            var wallet = WalletHelper.LoadWallet();

            Console.WriteLine();
            Console.WriteLine("How much ICX do you want to send?");
            var        amount       = BigInteger.Parse(Console.ReadLine());
            BigInteger amountToSend = amount * Consts.ICX2Loop;

            Console.WriteLine($"Enter the public address to send {amount}");
            var toAddress = Console.ReadLine();

            BigInteger stepLimit = NumericsHelper.ICX2Loop("0.000000001");
            Hash32     result    = WalletHelper.Transfer(toAddress, wallet.PrivateKey, amountToSend, stepLimit, WalletHelper.TestNetUrl);

            Console.WriteLine($"Transfer successful tx: {result}");
        }
コード例 #16
0
        private Transaction CreateTransaction(double price)
        {
            var builder = new CallTransactionBuilder
            {
                NID        = 1,
                PrivateKey = GetPrivateKey(),
                To         = _appsetting.Daedric_Address,
                StepLimit  = NumericsHelper.ICX2Loop("0.000000001"),
                Method     = "post"
            };

            //For a general purpose solution to remove scientific notation on a double to string value you need to preserve 339 places
            //https://stackoverflow.com/questions/1546113/double-to-string-conversion-without-scientific-notation
            builder.Params["value"] = price.ToString("0." + new string('#', 339));

            var tax = builder.Build();

            return(builder.Build());
        }
コード例 #17
0
ファイル: TestTransaction.cs プロジェクト: arkoc/IconSDK.Net
        public void TestCallTransactionBuilder()
        {
            var builder = new CallTransactionBuilder();

            builder.NID             = 2;
            builder.PrivateKey      = PrivateKey.Random();
            builder.To              = "cx54f7853dc6481b670caf69c5a27c7c8fe5be8269";
            builder.StepLimit       = NumericsHelper.ICX2Loop("0.10000000000");
            builder.Value           = NumericsHelper.ICX2Loop("1.00000");
            builder.Timestamp       = 100000000000;
            builder.Method          = "transfer";
            builder.Params["to"]    = new ExternalAddress("hx54f7853dc6481b670caf69c5a27c7c8fe5be8269");
            builder.Params["value"] = new BigInteger(10);

            var tx = builder.Build();

            Assert.True(Signer.Verify(tx.Signature, tx.Hash, tx.From));

            var hashSource = new Dictionary <string, object>()
            {
                ["version"]   = "0x3",
                ["nid"]       = "0x2",
                ["from"]      = Addresser.Create(builder.PrivateKey).ToString(),
                ["to"]        = "cx54f7853dc6481b670caf69c5a27c7c8fe5be8269",
                ["stepLimit"] = "0x16345785d8a0000",
                ["value"]     = "0xde0b6b3a7640000",
                ["timestamp"] = "0x174876e800",
                ["dataType"]  = "call",
                ["data"]      = new Dictionary <string, object>()
                {
                    ["method"] = "transfer",
                    ["params"] = new Dictionary <string, object>()
                    {
                        ["to"]    = "hx54f7853dc6481b670caf69c5a27c7c8fe5be8269",
                        ["value"] = "0xa"
                    }
                }
            };

            var hash = Hasher.Digest(hashSource);

            Assert.AreEqual(tx.Hash, hash);
        }
コード例 #18
0
ファイル: TestTransaction.cs プロジェクト: arkoc/IconSDK.Net
        public void TestDelopyTransaction()
        {
            var builder = new DeployTransactionBuilder();

            builder.NID             = 2;
            builder.PrivateKey      = PrivateKey.Random();
            builder.To              = "cx0000000000000000000000000000000000000000";
            builder.StepLimit       = NumericsHelper.ICX2Loop("0.1");
            builder.Timestamp       = 100000000000;
            builder.ContentType     = "application/zip";
            builder.Content         = new Bytes("0x1212121212");
            builder.Params["to"]    = new ExternalAddress("hx54f7853dc6481b670caf69c5a27c7c8fe5be8269");
            builder.Params["value"] = new BigInteger(10);

            var tx = builder.Build();

            Assert.True(Signer.Verify(tx.Signature, tx.Hash, tx.From));

            var hashSource = new Dictionary <string, object>()
            {
                ["version"]   = "0x3",
                ["nid"]       = "0x2",
                ["from"]      = Addresser.Create(builder.PrivateKey).ToString(),
                ["to"]        = "cx0000000000000000000000000000000000000000",
                ["stepLimit"] = "0x16345785d8a0000",
                ["timestamp"] = "0x174876e800",
                ["dataType"]  = "deploy",
                ["data"]      = new Dictionary <string, object>()
                {
                    ["contentType"] = "application/zip",
                    ["content"]     = "0x1212121212",
                    ["params"]      = new Dictionary <string, object>()
                    {
                        ["to"]    = "hx54f7853dc6481b670caf69c5a27c7c8fe5be8269",
                        ["value"] = "0xa"
                    }
                }
            };

            var hash = Hasher.Digest(hashSource);

            Assert.AreEqual(tx.Hash, hash);
        }
コード例 #19
0
        public void ImportFromBinaryReader(ShapeType shapeType, BinaryReader br)
        {
            try
            {
                long streamLength = br.BaseStream.Length;
                RecordNumber  = NumericsHelper.ReverseInt(br.ReadInt32());                // Big, Reverse for actual value
                ContentLength = NumericsHelper.ReverseInt(br.ReadInt32());                // Big, Reverse for actual value
                ShapeType     = (ShapeType)br.ReadInt32();

                if (ShapeType == ShapeType.Null ||
                    shapeType == ShapeType.Null)
                {
                    return;
                }

                if (ShapeType != shapeType)
                {
                    // Shape Type doesn't match type specified in file header. According to specs, this is invalid. Throw exception
                    throw new Exception(
                              $"Unable to process shape! File shape of {shapeType} does not match record shape of {ShapeType} which violates ESRI specifications for shape files!");
                }

                ShapeClass shapeClass        = ShapeClass.Coordinate;
                bool       hasMultiplePoints = true;
                bool       hasParts          = true;
                bool       hasPartTypes      = false;

                switch (shapeType)
                {
                case ShapeType.MultiPatch:
                    shapeClass   = ShapeClass.Depth;
                    hasPartTypes = true;
                    break;

                case ShapeType.MultiPoint:
                    hasParts = false;
                    break;

                case ShapeType.MultiPointM:
                    shapeClass = ShapeClass.Measurement;
                    hasParts   = false;
                    break;

                case ShapeType.MultiPointZ:
                    shapeClass = ShapeClass.Depth;
                    hasParts   = false;
                    break;

                case ShapeType.Null:
                    throw new Exception(
                              "The application should have never gotten to this point.\r\nSomething is wrong with the code!\r\nLYNCH THE DEVELOPER!");

                case ShapeType.Point:
                    hasMultiplePoints = false;
                    hasParts          = false;
                    break;

                case ShapeType.PointM:
                    shapeClass        = ShapeClass.Measurement;
                    hasMultiplePoints = false;
                    hasParts          = false;
                    break;

                case ShapeType.PointZ:
                    shapeClass        = ShapeClass.Depth;
                    hasMultiplePoints = false;
                    hasParts          = false;
                    break;

                case ShapeType.Polygon:
                case ShapeType.Polyline:
                    break;

                case ShapeType.PolygonM:
                    shapeClass = ShapeClass.Measurement;
                    break;

                case ShapeType.PolygonZ:
                    shapeClass = ShapeClass.Depth;
                    break;

                case ShapeType.PolylineM:
                    shapeClass = ShapeClass.Measurement;
                    break;

                case ShapeType.PolylineZ:
                    shapeClass = ShapeClass.Depth;
                    break;

                default:
                    throw new Exception($"Unable to process shape! Record Shape of {ShapeType} is unknown!");
                }

                if (hasMultiplePoints)
                {
                    XMin = br.ReadDouble();
                    YMin = br.ReadDouble();
                    XMax = br.ReadDouble();
                    YMax = br.ReadDouble();
                }

                NumberOfParts  = hasParts ? br.ReadInt32() : 1;
                NumberOfPoints = hasMultiplePoints ? br.ReadInt32() : 1;

                //Console.Write(StringHelper.GetProgressString(br.BaseStream.Position, streamLength, "Shape"));

                List <Part> parts = new List <Part>();

                for (int i = 0; i < NumberOfParts; i++)                 // Grab the parts
                {
                    Part part = new Part
                    {
                        ShapeId    = Id,
                        SortIndex  = i,
                        PartTypeId = -1,                           // TODO: Find out what the appropriate part types are (if necessary)
                        StartIndex = hasParts ? br.ReadInt32() : 0 // Get the start index
                    };

                    parts.Add(part);

                    if (i > 0)                     // If this isn't the first element
                    {
                        parts[i - 1].EndIndex = parts[i].StartIndex - 1;
                    }
                    // Set the last element's end index to this element's start index minus one

                    if (i + 1 == NumberOfParts)                     // If this is the last element
                    {
                        parts[i].EndIndex = NumberOfPoints - 1;
                    }
                    // Set the ending index to the number of points minus one (to account for 0 based index)

                    //Console.Write(StringHelper.GetProgressString(br.BaseStream.Position, streamLength, $"Part {i}"));
                }

                for (int i = 0; i < NumberOfParts; i++)
                // Set the number of points. This is done after initial grab to account for first/last elements
                {
                    if (hasParts && hasPartTypes)
                    {
                        parts[i].PartTypeId = br.ReadInt32();
                    }

                    parts[i].NumberOfPoints = parts[i].EndIndex - parts[i].StartIndex + 1;

                    //Console.Write(StringHelper.GetProgressString(br.BaseStream.Position, streamLength, $"Part {i}"));
                }

                for (int i = 0; i < NumberOfParts; i++)                 // For each part
                {
                    for (int j = 0; j < parts[i].NumberOfPoints; j++)   // For each point in each part
                    {
                        parts[i].Points.Add(new Point
                        {
                            SortIndex = j,
                            X         = br.ReadDouble(),
                            Y         = br.ReadDouble()
                        });                         // Grab the point
                        //Console.Write(StringHelper.GetProgressString(br.BaseStream.Position, streamLength, $"Part {i} | Point {j}"));
                    }
                }

                if (shapeClass == ShapeClass.Depth)
                {
                    if (hasMultiplePoints)
                    {
                        ZMin = br.ReadDouble();
                        ZMax = br.ReadDouble();
                    }

                    for (int i = 0; i < NumberOfParts; i++)
                    {
                        for (int j = 0; j < parts[i].NumberOfPoints; j++)
                        {
                            //Console.Write(StringHelper.GetProgressString(br.BaseStream.Position,
                            //	streamLength,
                            //	$"Part {i} | Point {j} | Setting Z Value"));
                            parts[i].Points.ToArray()[j].Z = br.ReadDouble();
                        }
                    }
                }

                if (shapeClass == ShapeClass.Depth
                    ||
                    shapeClass == ShapeClass.Measurement)
                {
                    if (hasMultiplePoints)
                    {
                        MMin = br.ReadDouble();
                        MMax = br.ReadDouble();
                    }

                    for (int i = 0; i < NumberOfParts; i++)
                    {
                        for (int j = 0; j < parts[i].NumberOfPoints; j++)
                        {
                            //Console.Write(StringHelper.GetProgressString(br.BaseStream.Position,
                            //	streamLength,
                            //	$"Part {i} | Point {j} | Setting M Value"));
                            parts[i].Points.ToArray()[j].M = br.ReadDouble();
                        }
                    }
                }

                try
                {
                    string wktTemplate   = "{0}({1})";
                    string shapeTypeName = ShapeType.ToString().ToUpperInvariant().Replace("POLYLINE", "MULTILINESTRING");
                    IReadOnlyCollection <string> coordinateStrings = parts.Select(s => s.CoordinateString).ToArray();

                    if (ShapeType == ShapeType.Point ||
                        ShapeType == ShapeType.PointZ ||
                        ShapeType == ShapeType.PointM)
                    {
                        coordinateStrings = coordinateStrings.Select(s => s.Trim('(').Trim(')').Trim()).ToArray();
                    }

                    string coordinateString = string.Join(",", coordinateStrings);
                    string wktString        = string.Format(wktTemplate, shapeTypeName, coordinateString);
                    //Debug.WriteLine(wktString);
                    Geometry = DbGeometry.FromText(wktString, SRID);
                }
                catch (Exception e)
                {
                    Console.WriteLine($"\r\n{e.Message}\r\n{e}");
                    throw;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine($"\r\n{e.Message}\r\n{e}");
                throw;
            }
        }
コード例 #20
0
 public RecordHeader(BinaryReader br)
 {
     RecordNumber  = NumericsHelper.ReverseInt(br.ReadInt32());            // Big, Reverse for actual value
     ContentLength = NumericsHelper.ReverseInt(br.ReadInt32());            // Big, Reverse for actual value
 }
コード例 #21
0
        public void ImportFromFile(FileInfo file)
        {
            try
            {
                using (BinaryReader br = new BinaryReader(file.OpenRead()))
                {
                    long streamLength = br.BaseStream.Length;
                    FileCode = NumericsHelper.ReverseInt(br.ReadInt32());

                    for (int i = 0; i < 5; i++)
                    {
                        br.ReadInt32();                                        // Skip 5 empty Integer (4-byte) slots
                    }
                    ContentLength = NumericsHelper.ReverseInt(br.ReadInt32()); // Big Endian, Reverse for actual value
                    FileVersion   = br.ReadInt32();
                    ShapeType     = (ShapeType)br.ReadInt32();
                    XMin          = br.ReadDouble();
                    YMin          = br.ReadDouble();
                    XMax          = br.ReadDouble();
                    YMax          = br.ReadDouble();
                    ZMin          = br.ReadDouble();
                    ZMax          = br.ReadDouble();
                    MMin          = br.ReadDouble();
                    MMax          = br.ReadDouble();

                    int rowsAffected;
                    using (ShapefileEntities db = new ShapefileEntities())
                    {
                        db.Entry(this).State = EntityState.Added;
                        rowsAffected         = db.SaveChanges();
                    }

                    if (!(rowsAffected > 0) ||
                        !(Id > 0))
                    {
                        throw new Exception(
                                  "The index file was not added to the database properly. No ID is present to assign to the child index records. Unable to proceed!");
                    }

                    List <ShapeIndex> shapeIndices = new List <ShapeIndex>();
                    int counter = 0;
                    while (br.PeekChar() > -1)
                    {
                        LH.Write(StringHelper.GetProgressString(br.BaseStream.Position, streamLength, file.Name));
                        shapeIndices.Add(new ShapeIndex
                        {
                            IndexFileId   = Id,
                            RecordNumber  = ++counter,
                            Offset        = NumericsHelper.ReverseInt(br.ReadInt32()),
                            ContentLength = NumericsHelper.ReverseInt(br.ReadInt32())
                        });
                    }

                    LH.Write(StringHelper.GetProgressString(br.BaseStream.Position, streamLength, file.Name));

                    using (SqlBulkCopy sbc = new SqlBulkCopy(DataHelper.DefaultConnectionString))
                    {
                        sbc.BatchSize            = DataHelper.DefaultBatchSize;
                        sbc.BulkCopyTimeout      = DataHelper.DefaultTimeoutSeconds;
                        sbc.DestinationTableName = "ShapeIndex";
                        sbc.EnableStreaming      = true;
                        sbc.SqlRowsCopied       += DataHelper.SqlBulkCopy_SqlRowsCopied;
                        sbc.NotifyAfter          = DataHelper.DefaultBatchSize;

                        sbc.ColumnMappings.Add("Id", "Id");
                        sbc.ColumnMappings.Add("IndexFileId", "IndexFileId");
                        sbc.ColumnMappings.Add("RecordNumber", "RecordNumber");
                        sbc.ColumnMappings.Add("Offset", "Offset");
                        sbc.ColumnMappings.Add("ContentLength", "ContentLength");

                        try
                        {
                            DataTable shapeIndicesData = DataHelper.CreateDataTable(shapeIndices);
                            sbc.WriteToServerAsync(shapeIndicesData);
                        }
                        catch (Exception e)
                        {
                            LH.Error($"\r\n{e.Message}\r\n{e}");
                            throw;
                        }
                        finally
                        {
                            sbc.Close();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                LH.Error($"\r\n{e.Message}\r\n{e}");
                throw;
            }
        }
コード例 #22
0
        public void ImportFromFile(FileInfo file)
        {
            try
            {
                using (BinaryReader br = new BinaryReader(file.OpenRead()))
                {
                    long streamLength = br.BaseStream.Length;
                    Console.Write(StringHelper.GetProgressString(br.BaseStream.Position, streamLength, file.Name));
                    FileCode = NumericsHelper.ReverseInt(br.ReadInt32());

                    for (int i = 0; i < 5; i++)
                    {
                        br.ReadInt32();                                        // Skip 5 empty Integer (4-byte) slots
                    }
                    ContentLength = NumericsHelper.ReverseInt(br.ReadInt32()); // Big Endian, Reverse for actual value
                    FileVersion   = br.ReadInt32();
                    ShapeType     = (ShapeType)br.ReadInt32();
                    XMin          = br.ReadDouble();
                    YMin          = br.ReadDouble();
                    XMax          = br.ReadDouble();
                    YMax          = br.ReadDouble();
                    ZMin          = br.ReadDouble();
                    ZMax          = br.ReadDouble();
                    MMin          = br.ReadDouble();
                    MMax          = br.ReadDouble();

                    //int rowsAffected;
                    //using (ShapefileEntities db = new ShapefileEntities())
                    //{
                    //	db.Entry(this).State = EntityState.Added;
                    //	rowsAffected = db.SaveChanges();
                    //}

                    //if (rowsAffected > 0
                    //	&& Id > 0)
                    //{
                    //List<Shape> shapes = new List<Shape>();
                    while (br.PeekChar() > -1)
                    {
                        Console.Write(StringHelper.GetProgressString(br.BaseStream.Position, streamLength, file.Name));
                        Shapes.Add(new Shape(SRID, ShapeType, br));
                    }

                    Console.Write(StringHelper.GetProgressString(br.BaseStream.Position, streamLength, file.Name));

                    //	using (SqlBulkCopy sbc = new SqlBulkCopy(DataHelper.DefaultConnectionString))
                    //	{
                    //		sbc.BatchSize = DataHelper.DefaultBatchSize;
                    //		sbc.BulkCopyTimeout = DataHelper.DefaultTimeoutSeconds;
                    //		sbc.DestinationTableName = "Shape";
                    //		sbc.EnableStreaming = true;
                    //		sbc.SqlRowsCopied += DataHelper.SqlBulkCopy_SqlRowsCopied;
                    //		sbc.NotifyAfter = 250;

                    //		sbc.ColumnMappings.Add("ShapeFileId", "ShapeFileId");
                    //		sbc.ColumnMappings.Add("ShapeType", "ShapeType");
                    //		sbc.ColumnMappings.Add("RecordNumber", "RecordNumber");
                    //		sbc.ColumnMappings.Add("ContentLength", "ContentLength");
                    //		sbc.ColumnMappings.Add("XMin", "XMin");
                    //		sbc.ColumnMappings.Add("YMin", "YMin");
                    //		sbc.ColumnMappings.Add("XMax", "XMax");
                    //		sbc.ColumnMappings.Add("YMax", "YMax");
                    //		sbc.ColumnMappings.Add("ZMin", "ZMin");
                    //		sbc.ColumnMappings.Add("ZMax", "ZMax");
                    //		sbc.ColumnMappings.Add("MMin", "MMin");
                    //		sbc.ColumnMappings.Add("MMax", "MMax");
                    //		sbc.ColumnMappings.Add("NumberOfParts", "NumberOfParts");
                    //		sbc.ColumnMappings.Add("NumberOfPoints", "NumberOfPoints");
                    //		sbc.ColumnMappings.Add("DTGeometry", "Geometry");

                    //		try
                    //		{
                    //			DataTable shapesData = DataHelper.CreateDataTable(shapes);
                    //			sbc.WriteToServerAsync(shapesData);
                    //		}
                    //		catch (Exception e)
                    //		{
                    //			Console.WriteLine($"\r\n{e.Message}\r\n{e}");
                    //			throw;
                    //		}
                    //		finally
                    //		{
                    //			sbc.Close();
                    //		}
                    //	}
                    //}
                    //else
                    //	throw new FileLoadException("The ShapeFile record failed to save properly or doesn't have a valid ID");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine($"\r\n{e.Message}\r\n{e}");
                throw;
            }
        }