private async static Task ReadChannelData() { AuthenticationConfig config = AuthenticationConfig.ReadFromJsonFile("appsettings.json"); var channelInfoFile = config.ChannelsConfig; ChannelStore channelInfo = ChannelStore.ReadFromJsonFile(channelInfoFile); if (channelInfo != null && channelInfo.Channels.Any()) { Channels.AddRange(channelInfo.Channels); } else { Console.WriteLine("No Channels to List"); } }
public static ChannelStore ReadFromJsonFile(string path) { ChannelStore channelStore = new ChannelStore(); try { IConfigurationRoot Configuration; var builder = new ConfigurationBuilder() .AddJsonFile(path, true, true); Configuration = builder.Build(); return(Configuration.Get <ChannelStore>()); } catch (Exception ex) { Console.WriteLine(ex.Message); } return(channelStore); }