public CityRoadServiceDatabase( CityRoadService cityRoadServiceProvidingDataForPopulatingDatabaseIfEmpty ) { sessionFactory = PersistenceSessionFactory.CreateSessionFactory(); cityDataMapper = new CityDataMapper(sessionFactory); roadDataMapper = new RoadDataMapper(sessionFactory); this.cityRoadServiceProvidingDataForPopulatingDatabaseIfEmpty = cityRoadServiceProvidingDataForPopulatingDatabaseIfEmpty; }
public static void MainMethod(bool useDatabase) { Console.WriteLine("useDatabase : " + useDatabase); CityRoadService cityRoadService = CityRoadServiceFactory.CreateCityRoadService(useDatabase); try { IList <Road> roads = cityRoadService.GetAllRoads(); City startCity = cityRoadService.GetStartCity(); City endCity = cityRoadService.GetEndCity(); var pathFinderFactories = new List <PathFinderFactoryGenerics <PathFinderGenerics <PathGenerics <Road, City, WeightDeterminedByRoadLengthAndQuality>, Road, City, WeightDeterminedByRoadLengthAndQuality>, PathGenerics <Road, City, WeightDeterminedByRoadLengthAndQuality>, Road, City, WeightDeterminedByRoadLengthAndQuality> >(); pathFinderFactories.Add(new PathFinderFactoryYanQiGenerics <PathFinderGenerics <PathGenerics <Road, City, WeightDeterminedByRoadLengthAndQuality>, Road, City, WeightDeterminedByRoadLengthAndQuality>, PathGenerics <Road, City, WeightDeterminedByRoadLengthAndQuality>, Road, City, WeightDeterminedByRoadLengthAndQuality>()); pathFinderFactories.Add(new PathFinderFactoryBsmockGenerics <PathFinderGenerics <PathGenerics <Road, City, WeightDeterminedByRoadLengthAndQuality>, Road, City, WeightDeterminedByRoadLengthAndQuality>, PathGenerics <Road, City, WeightDeterminedByRoadLengthAndQuality>, Road, City, WeightDeterminedByRoadLengthAndQuality>()); PerformRoadRoutingForTheImplementations( roads, startCity, endCity, pathFinderFactories ); } finally { cityRoadService.ReleaseResourcesIfAny(); } }