public static void Main() { string filename = @"C:\Users\Vaiva\source\repos\NEW\AnimalsList.json"; FileReader fr = new FileReader(filename); List <AnimalContract> streamList = fr.ReadStream(); List <Animal> animalList = fr.ParseStream(streamList); List <Type> typeAll = new List <Type>() { typeof(Dog), typeof(Cat) }; List <Type> typeCat = new List <Type>() { typeof(Cat) }; List <Type> typeDog = new List <Type>() { typeof(Dog) }; double weightAll = WeightCounter.AverageWeightAll(animalList, typeAll); double weightCats = WeightCounter.AverageWeightAll(animalList, typeCat); double weightDogs = WeightCounter.AverageWeightAll(animalList, typeDog); AnimalWeights report = new AnimalWeights() { }; report.AllWeights = weightAll; report.CatsWeights = weightCats; report.DogsWeights = weightDogs; List <List <Type> > alllist = new List <List <Type> >() { new List <Type>() { typeof(Dog), typeof(Cat) }, new List <Type>() { typeof(Cat) }, new List <Type>() { typeof(Dog) } }; /*foreach (List<Type> types in List<List<Type>> alllist) * {} */ ReportMaker.GenerateReport(report); Console.ReadLine(); }
public static void GenerateReport(AnimalWeights reportdata) { string filename = @"C:\Users\Vaiva\source\repos\NEW\AnimalsReport.json"; using (FileStream fs = File.Create(filename)) { fs.Position = 0; DataContractJsonSerializer ser = new DataContractJsonSerializer( typeof(AnimalWeights)); ser.WriteObject(fs, reportdata); } }