Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close DBF and AfterBuild package #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/DynamoGIS/pkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"license":"",
"file_hash":null,
"name":"DynamoGIS",
"version":"0.2.2",
"description":"Shape file reader for Dyanmo",
"group":"GIS",
"keywords":["gis","shapefile"],
"dependencies":[],
"contents":"",
"engine_version":"0.8.3.2491",
"engine":"dynamo",
"engine_metadata":"",
"site_url":"",
"repository_url":"",
"contains_binaries":true,
"node_libraries":["EGIS.DynamoLib, Version=0.2.0.0, Culture=neutral, PublicKeyToken=null"]
}
14 changes: 13 additions & 1 deletion src/EGIS.DynamoLib/EGIS.DynamoLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,19 @@
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
-->
<Target Name="AfterBuild">
<ItemGroup>
<Dlls Include="$(OutDir)*.dll" />
<Pdbs Include="$(OutDir)*.pdb" />
<Xmls Include="$(OutDir)*.xml" />
<Configs Include="$(OutDir)*.config" />
</ItemGroup>
<Copy SourceFiles="@(Dlls)" DestinationFolder="$(SolutionDir)..\packages\DynamoGIS\bin\" />
<Copy SourceFiles="@(Pdbs)" DestinationFolder="$(SolutionDir)..\packages\DynamoGIS\bin\" />
<Copy SourceFiles="@(Xmls)" DestinationFolder="$(SolutionDir)..\packages\DynamoGIS\bin\" />
<Copy SourceFiles="@(Configs)" DestinationFolder="$(SolutionDir)..\packages\DynamoGIS\bin\" />
<MakeDir Directories="$(SolutionDir)..\packages\DynamoGIS\dyf" />
<MakeDir Directories="$(SolutionDir)..\packages\DynamoGIS\extra" />
</Target>
-->
</Project>
16 changes: 14 additions & 2 deletions src/EGIS.DynamoLib/ShapeFileReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Autodesk.DesignScript.Geometry;
using EGIS.ShapeFileLib;
using System.IO;
using System;

namespace EGIS.DynamoLib
{
Expand All @@ -16,7 +17,7 @@ internal struct PointXYZ
/// <summary>
/// Represents the shape read from ShapeFile
/// </summary>
public class Shape
public class Shape : IDisposable
{
/// <summary>
/// Represents raw shape data
Expand Down Expand Up @@ -48,6 +49,17 @@ private Shape(string shapeFilePath)
Database = new DbfReader(dbfFilePath);
}

/// <summary>
/// Closes the Database at the end of the execution
/// </summary>
public void Dispose()
{
if (Database != null)
{
Database.Close();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can call dispose on Database if it is IDisposable.

}
}

/// <summary>
/// Loads the shape file(*.shp) from the given path
/// </summary>
Expand Down Expand Up @@ -81,7 +93,7 @@ public IEnumerable<Curve> GetShapeAtRecord(int index)
{
item.Dispose();
}

return polygon;
});
}
Expand Down