maxmind / MaxMind-DB-Reader-dotnet

.NET Reader for the MaxMind DB Database Format

Home Page:https://www.nuget.org/packages/MaxMind.Db

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No close method in Reader

chr1sk0n opened this issue · comments

Hi guys,
in your example you use the following code:
var reader = new Reader("GeoIP2-City.mmdb");
var response = reader.Find("24.24.24.24");
Console.WriteLine(response.ToString());
reader.close();
But your class Reader provides no method 'close'. I have changed the example a bit to help the developers to better understand the usage of your lib.
Here is my code:

        using (var reader = new Reader("DB/GeoLite2-City.mmdb"))
        {
            JToken response = reader.Find("24.24.24.24");                
            var city_de =
                JObject.Parse(response.ToString())
                            .SelectToken("city")
                            .SelectToken("names")
                            .Select(l => (string) l).ToList();
            Console.WriteLine(city_de.FirstOrDefault());

            JObject cc = JObject.Parse(response.ToString());                
            var state = (string)cc.SelectToken("subdivisions[0].names.en");
            Console.WriteLine(state);

            string country = (string)cc.SelectToken("country.names.en");
            Console.WriteLine(country);

            string continent = (string)cc.SelectToken("continent.names.en");
            Console.WriteLine(continent);
        }

Regards
Christoph

Thanks for pointing that out. You are absolutely correct. The reader implements IDisposable.