public TypeRepository LoadTypes() { //resource string resourceDataName = typeof(TypeRepository).GetProperty(nameof(TypeRepository.ResourceTypes)) !.GetCustomAttribute <TypeAttribute>() !.Name; var resources = LoadResources(resourceDataName); KeyedVectorFull <ResourceType> .InitializeKeys(resources.Values); //terrain string terrainDataName = typeof(TypeRepository).GetProperty(nameof(TypeRepository.TerrainTypes)) !.GetCustomAttribute <TypeAttribute>() !.Name; var terrains = LoadTerrains(terrainDataName, resources); //feautre string feautreDataName = typeof(TypeRepository).GetProperty(nameof(TypeRepository.MapFeautreTypes)) !.GetCustomAttribute <TypeAttribute>() !.Name; var feautres = LoadFeautres(feautreDataName, resources); //collector string collectorDataName = typeof(TypeRepository).GetProperty(nameof(TypeRepository.CollectorTypes)) !.GetCustomAttribute <TypeAttribute>() !.Name; var collectors = LoadCollectors(collectorDataName, resources, terrains, feautres); //building string buildingDataName = typeof(TypeRepository).GetProperty(nameof(TypeRepository.BuildingTypes)) !.GetCustomAttribute <TypeAttribute>() !.Name; var buildings = LoadBuildings(buildingDataName, resources); //pop demand string demandDataName = typeof(TypeRepository).GetProperty(nameof(TypeRepository.PopulationDemands)) !.GetCustomAttribute <TypeAttribute>() !.Name; var demands = LoadPopDemands(demandDataName, resources); return(new TypeRepository(resources, terrains, feautres, collectors, buildings, demands)); }
public static IEnumerable <object[]> CompareVector() { List <string> keys = new() { "a", "b", "c" }; KeyedVectorFull <string> .InitializeKeys(keys); return(new List <object[]> { new object[] { new KeyedVectorFull <string>() { ["a"] = 1, ["b"] = 2, ["c"] = 3 }, new KeyedVectorFull <string>() { ["a"] = 4, ["b"] = 5, ["c"] = 6 } }, new object[] { new KeyedVectorFull <string>() { ["a"] = 4, ["b"] = 5, ["c"] = 6 }, new KeyedVectorFull <string>() { ["a"] = 1, ["b"] = 2, ["c"] = 3 } }, new object[] { new KeyedVectorFull <string>() { ["a"] = 5, ["b"] = 4, ["c"] = 3 }, new KeyedVectorFull <string>() { ["a"] = 10, ["b"] = 2, ["c"] = 3 } }, new object[] { new KeyedVectorFull <string>() { ["a"] = 5, ["b"] = 4, ["c"] = 3 }, new KeyedVectorFull <string>() { ["a"] = 1, ["b"] = 2, ["c"] = 3 } }, new object[] { new KeyedVectorFull <string>() { ["a"] = 1, ["b"] = 10, ["c"] = 3 }, new KeyedVectorFull <string>() { ["a"] = 5, ["c"] = 5 } }, new object[] { new KeyedVectorFull <string>() { ["a"] = 5, ["b"] = 0, ["c"] = 3 }, new KeyedVectorFull <string>() { ["a"] = 1, ["c"] = 3 } }, }); } }
public static IEnumerable <object[]> DoubleVector() { List <string> keys = new() { "a", "b", "c" }; List <string> keysSmall = new() { "a", "c" }; KeyedVectorFull <string> .InitializeKeys(keys); return(new List <object[]> { new object[] { keys, new KeyedVectorFull <string>() { ["a"] = 1, ["b"] = 2, ["c"] = 3 }, new KeyedVectorFull <string>() { ["a"] = 4, ["b"] = 5, ["c"] = 6 } }, new object[] { keys, new KeyedVectorFull <string>() { ["a"] = 4, ["b"] = 5, ["c"] = 6 }, new KeyedVectorFull <string>() { ["a"] = 1, ["b"] = 2, ["c"] = 3 } }, new object[] { keys, new KeyedVectorFull <string>() { ["a"] = 5, ["b"] = 4, ["c"] = 3 }, (new KeyedVectorFull <string>() { ["a"] = 10, ["b"] = 2, ["c"] = 3 }).FilterSmaller(keysSmall) }, new object[] { keys, new KeyedVectorFull <string>() { ["a"] = 5, ["b"] = 4, ["c"] = 3 }, (new KeyedVectorFull <string>() { ["a"] = 1, ["b"] = 2, ["c"] = 3 }).FilterSmaller(keysSmall) } }); } public static IEnumerable <object[]> FilterVector()
public void KeyedVectorTest() { List <string> keys = new() { "a", "b", "c" }; KeyedVectorFull <string> .InitializeKeys(keys); KeyedVectorFull <string> vec = new(); Assert.Equal(0, vec["a"]); Assert.Equal(0, vec["b"]); Assert.Equal(0, vec["c"]); vec["b"] = 1; vec["a"] = 2; vec["c"] = 3; vec["b"] = 4; Assert.Equal(2, vec["a"]); Assert.Equal(4, vec["b"]); Assert.Equal(3, vec["c"]); Assert.Throws <KeyNotFoundException>(() => vec["d"] = 0); }
public static IEnumerable <object[]> FilterVector() { List <string> keys = new() { "a", "b", "c" }; KeyedVectorFull <string> .InitializeKeys(keys); return(new List <object[]> { new object[] { keys, new KeyedVectorFull <string>() { ["a"] = 1, ["b"] = 2, ["c"] = 3 }, new List <string>() { "a" } }, new object[] { keys, new KeyedVectorFull <string>() { ["a"] = 4, ["b"] = 5, ["c"] = 6 }, new List <string>() { "a", "b" } }, new object[] { keys, new KeyedVectorFull <string>() { ["a"] = 5, ["b"] = 4, ["c"] = 3 }, new List <string>() { "b" } }, new object[] { keys, new KeyedVectorFull <string>() { ["a"] = 5, ["b"] = 4, ["c"] = 3 }, new List <string>() { "c" } } }); }