public void Dispose() { if (_canvas != null) { if (_canvas.LayerContainer.VectorHost != null) { IMap map = (_canvas.LayerContainer.VectorHost as IVectorHostLayer).Map as IMap; if (map != null && map.LayerContainer != null) { map.LayerContainer.Remove(_layer); } } _canvas = null; } if (_mapRuntime != null) { _mapRuntime = null; } if (_datasource != null) { _datasource.Dispose(); _datasource = null; } if (_labeldef != null) { _labeldef.Dispose(); _labeldef = null; } if (_layer != null) { _layer.Dispose(); _layer = null; } OID = 0; }
public void Check_ALL_Match() { var filename = Path.Combine(AppContext.BaseDirectory, "ip.txt"); var dest = Path.Combine(AppContext.BaseDirectory, "ip2.dat"); var data = Helper.GetIPList(filename).ToArray(); using (var fs = File.Create(dest)) { IpSearcherFactory.Generate(Helper.GetIPList(filename).ToArray(), fs); } var dataSource = new MemoryDataSource(dest); var searcher = IpSearcherFactory.GetSearcher(dataSource); IpLocation result; foreach (var info in data) { result = searcher.Search(info.MinIP); if (info.Country != result.Country) { var a = 123; } Assert.Equal(info.Country, result.Country ?? string.Empty); //Assert.Equal(info.Province, result.Province ?? string.Empty); //Assert.Equal(info.City, result.City ?? string.Empty); //if (info.Isp == "内网IP") //{ // Assert.Equal("保留地址", result.Isp ?? string.Empty); //} //else //{ // Assert.Equal(info.Isp, result.Isp ?? string.Empty); //} } dataSource.Dispose(); }
public void Check_ALL_Match_V2() { var filename = Path.Combine(AppContext.BaseDirectory, "phones.txt"); var dest = Path.Combine(AppContext.BaseDirectory, "v2.dat"); var data = Helper.GetPhoneList(filename).ToArray(); using (var fs = File.Create(dest)) { MobilePhoneFactory.Generate(MobilePhoneRegion.Version.V2, data, fs); } var dataSource = new MemoryDataSource(dest); var searcher = MobilePhoneFactory.GetSearcher(dataSource); SearchResult result; foreach (var info in data) { result = searcher.Search(info.Phone); Assert.True(result.Success); } dataSource.Dispose(); }