public async Task Serialize(string filePath, IEnumerable <ServiceDescriptorDescription> descriptions) { var descriptionsInOrderArray = descriptions .OrderBy(x => x.ServiceType) .ToArray(); var json = JsonConvert.SerializeObject(descriptionsInOrderArray); using (var streamWriter = StreamWriterHelper.NewWrite(filePath)) { await streamWriter.WriteAsync(json); } }
public async Task Describe(IServiceCollection services) { var servicesInOrder = services.OrderBy(x => x.ServiceType.FullName); var serviceCollectionDescriptionFilePath = await this.ServiceCollectionDescriptionFilePathProvider.GetServiceCollectionDescriptionFilePath(); using (var fileWriter = StreamWriterHelper.NewWrite(serviceCollectionDescriptionFilePath)) { var serviceCount = services.Count; await fileWriter.WriteLineAsync($"Services count: {serviceCount}\n\n"); foreach (var serviceDescriptor in servicesInOrder) { var description = await this.ServiceDescriptorDescriber.Describe(serviceDescriptor); await fileWriter.WriteLineAsync(description); } } }