示例#1
0
        public static async Task <BotProject> LoadAsync(BotFile botFile)
        {
            string file = string.Empty;

            if (botFile.provider == "localDisk")
            {
                file = botFile.path;
            }
            if (string.IsNullOrEmpty(file))
            {
                throw new ArgumentNullException(nameof(file));
            }
            string json = string.Empty;

            using (var stream = File.OpenText(file))
            {
                json = await stream.ReadToEndAsync().ConfigureAwait(false);
            }
            var bot   = JsonConvert.DeserializeObject <BotProject>(json);
            var index = file.LastIndexOf("/");

            if (index > 0)
            {
                bot.path = file.Substring(0, index + 1);
            }
            return(bot);
        }
示例#2
0
 public static BotProject Load(BotFile file)
 {
     return(BotProject.LoadAsync(file).GetAwaiter().GetResult());
 }