예제 #1
0
        public osuTrackUser(int UserId, Mode Mode, osuApi API, osuAPI.User?User)
        {
            this.UserId   = UserId;
            this.Mode     = Mode;
            LastScoreTime = DateTime.UtcNow;
            var user = User ?? API.GetUser(UserId, true, Mode).Result;

            PP            = user.PP;
            UsernameAtReg = user.UserName;
        }
예제 #2
0
        public static void GetBitmap(string savepath, ImageFormat iform, string name)
        {
            osuApi osuapi = new osuApi(BotMain.osuToken);

            Score[] scores = osuapi.GetTopPlaysByNameAsync(name, 20).Result;
            User    user   = osuapi.GetUserInfoByNameAsync(name).Result;

            using (WebClient wc = new WebClient())
            {
                wc.DownloadFile($"http://s.ppy.sh/a/{user.user_id}", @"E:\profile.jpg");
            }
            double accuracy = 0, aim = 0, speed = 0;

            foreach (var item in scores)
            {
                double  acc     = (50 * double.Parse(item.count50) + 100 * double.Parse(item.count100) + 300 * double.Parse(item.count300)) / (300 * (double.Parse(item.countmiss) + double.Parse(item.count50) + double.Parse(item.count100) + double.Parse(item.count300))) * 100;
                Beatmap beatmap = osuapi.GetBeatmapByBeatmapIdAsync(int.Parse(item.beatmap_id), int.Parse(item.enabled_mods)).Result;
                //Console.WriteLine($"{beatmap.title} {beatmap.difficultyrating}");
                aim   += double.Parse(beatmap.difficultyrating);
                speed += double.Parse(beatmap.bpm);
            }
            aim      = aim / 20;
            speed    = speed / 20;
            accuracy = double.Parse(user.accuracy);

            using (Bitmap bitmap = new Bitmap(400, 600))
            {
                using (Graphics graphics = Graphics.FromImage(bitmap))
                {
                    using (Image image = Image.FromFile(@"E:\poly.jpg"))
                        graphics.DrawImage(image, 0, 0, 400, 600);
                    using (Image image = Image.FromFile(@"E:\logo.png"))
                        graphics.DrawImage(image, 5, -10, 120, 120);
                    using (Image image = Image.FromFile(@"E:\profile.jpg"))
                        graphics.DrawImage(image, 40, 100, 320, 320);
                    graphics.DrawRectangle(new Pen(new SolidBrush(Color.Black))
                    {
                        Width = 5
                    }, new Rectangle()
                    {
                        Location = new Point(40, 100), Size = new Size(320, 320)
                    });
                    graphics.DrawString($"{name.ToUpper()}", new Font("Arial", 25), new SolidBrush(Color.Black), new PointF(105, 30));
                    graphics.DrawString($"Aim: {aim: 0.00}✩", new Font("Arial", 20), new SolidBrush(Color.White), new PointF(50, 450));
                    graphics.DrawString($"Speed: {speed: 0} BPM", new Font("Arial", 20), new SolidBrush(Color.White), new PointF(50, 490));
                    graphics.DrawString($"Accuracy: {accuracy: 0.00}%", new Font("Arial", 20), new SolidBrush(Color.White), new PointF(50, 530));
                }
                bitmap.Save(savepath, iform);
            }
        }
예제 #3
0
        public static async void osu(Message mess)
        {
            try
            {
                osuApi osuApi = new osuApi(BotMain.osuToken);
                string name   = string.Join(' ', mess.Text.Split(' ').Skip(1));
                if (name == "")
                {
                    await BotMain.bot.SendTextMessageAsync(mess.Chat.Id, "а ты кто?\n!osu [name]");

                    return;
                }
                User user = await osuApi.GetUserInfoByNameAsync(name);

                string text = $"<b>{name}'s profile!\n\nMain Information:</b>\n<code>join_date: {user.join_date:G}\ncountry: {user.country}" +
                              $"\npp: {Convert.ToDouble(user.pp_raw):N0}pp\naccuracy: {double.Parse(user.accuracy):N2}%\nglobal_rank: #{user.pp_rank}" +
                              $"\ncountry_rank: #{user.pp_country_rank}\nplaycount: {user.playcount}\nlevel: {double.Parse(user.level):N0}</code>";
                int count = 0;
                text += $"\n\n<b>Top Plays:</b>\n<code>";
                Score[] topscores = await osuApi.GetTopPlaysByNameAsync(name);

                foreach (var item in topscores)
                {
                    count++;
                    Mods    mods       = (Mods)osuApi.CalculateModsMods(int.Parse(item.enabled_mods));
                    double  accuracy   = (50 * double.Parse(item.count50) + 100 * double.Parse(item.count100) + 300 * double.Parse(item.count300)) / (300 * (double.Parse(item.countmiss) + double.Parse(item.count50) + double.Parse(item.count100) + double.Parse(item.count300))) * 100;
                    Beatmap curBeatmap = await osuApi.GetBeatmapByBeatmapIdAsync(int.Parse(item.beatmap_id));

                    text += $"{count}. </code><b>({item.rank})</b><a href=\"https://osu.ppy.sh/beatmaps/{curBeatmap.beatmap_id}\">{curBeatmap.title} [{curBeatmap.version}]</a><code>\n {item.count300}-{item.count100}-{item.count50}-{item.countmiss}❌ - {accuracy:N2}%" +
                            $"\n <b>{mods}</b> <i>{item.maxcombo}/{curBeatmap.max_combo}</i> <b><u>{item.pp:N0}pp</u></b>\n{DateTimeOffset.Parse(item.date).AddHours(5):dd.MM.yyyy HH:mm}\n\n";
                    if (count == 5)
                    {
                        break;
                    }
                }
                text += "</code>";

                await BotMain.bot.SendTextMessageAsync(mess.Chat.Id, text, ParseMode.Html);
            }
            catch (Exception e)
            {
                Other.OnReceivedError(e, mess);
            }
        }
예제 #4
0
        public static async void scores(Message mess)
        {
            try
            {
                osuApi osuapi     = new osuApi(BotMain.osuToken);
                string beatmap_id = "";
                for (int i = mess.Text.Length - 1; i >= 0; i--)
                {
                    if (mess.Text[i] != '/')
                    {
                        beatmap_id = beatmap_id.Insert(0, mess.Text[i].ToString());
                    }
                    else
                    {
                        break;
                    }
                }
                string  name   = string.Join(" ", mess.Text.Split(" ").Skip(1).SkipLast(1));
                Score[] scores = await osuapi.GetScoresOnMapByName(name, long.Parse(beatmap_id));

                string text = "";
                foreach (var item in scores)
                {
                    Mods    mods     = (Mods)osuapi.CalculateModsMods(int.Parse(item.enabled_mods));
                    double  accuracy = (50 * double.Parse(item.count50) + 100 * double.Parse(item.count100) + 300 * double.Parse(item.count300)) / (300 * (double.Parse(item.countmiss) + double.Parse(item.count50) + double.Parse(item.count100) + double.Parse(item.count300))) * 100;
                    Beatmap beatmap  = await osuapi.GetBeatmapByBeatmapIdAsync(int.Parse(beatmap_id));

                    double curpp  = Other.ppCalc(beatmap, accuracy, mods, int.Parse(item.countmiss), int.Parse(item.maxcombo));
                    double IfFCpp = Other.ppCalc(beatmap, accuracy, mods, 0, int.Parse(beatmap.max_combo));
                    text += $"<b>({item.rank})</b> <a href=\"https://osu.ppy.sh/beatmaps/{item.beatmap_id}\">{beatmap.title} [{beatmap.version}]</a> <b>({beatmap.GetApproved()})</b>\n" +
                            $"{item.count300}-{item.count100}-{item.count50}-{item.countmiss}❌ - <b><i>{accuracy:N2}</i></b>%\n" +
                            $"<b>{mods}</b> <i>{item.maxcombo}/{beatmap.max_combo}</i> <b><u>{curpp:N0}pp</u></b> (<b><u>~{IfFCpp:N0}pp</u></b> if FC)\n({DateTimeOffset.Parse(item.date).AddHours(5):dd.MM.yyyy HH:mm})\n\n";
                }
                await BotMain.bot.SendTextMessageAsync(mess.Chat.Id, text, ParseMode.Html);
            }
            catch (Exception e)
            {
                Other.OnReceivedError(e, mess, "Нет скоров");
            }
        }
예제 #5
0
        public static async void rs(Message mess)
        {
            try
            {
                string text   = "";
                osuApi osuApi = new osuApi(BotMain.osuToken);
                string name   = string.Join(' ', mess.Text.Split(' ').Skip(1));
                if (name == "")
                {
                    await BotMain.bot.SendTextMessageAsync(mess.Chat.Id, "а ты кто?\n!rs [name]");

                    return;
                }
                Score recentScore = (await osuApi.GetRecentScoresByNameAsync(name))[0];
                if (recentScore == default)
                {
                    throw new FormatException();
                }
                Beatmap beatmap = await osuApi.GetBeatmapByBeatmapIdAsync(long.Parse(recentScore.beatmap_id));

                Mods   mods     = (Mods)osuApi.CalculateModsMods(int.Parse(recentScore.enabled_mods));
                double accuracy = (50 * double.Parse(recentScore.count50) + 100 * double.Parse(recentScore.count100) + 300 * double.Parse(recentScore.count300)) / (300 * (double.Parse(recentScore.countmiss) + double.Parse(recentScore.count50) + double.Parse(recentScore.count100) + double.Parse(recentScore.count300))) * 100;
                double curpp    = Other.ppCalc(beatmap, accuracy, mods, int.Parse(recentScore.countmiss), int.Parse(recentScore.maxcombo));
                double ppIFfc   = Other.ppCalc(beatmap, accuracy, mods, 0, int.Parse(beatmap.max_combo));
                text += $"<b>({recentScore.rank})</b> <a href=\"https://osu.ppy.sh/beatmaps/{beatmap.beatmap_id}\">{beatmap.title} [{beatmap.version}]</a> <b>({beatmap.GetApproved()})</b>\n" +
                        $"{recentScore.count300}-{recentScore.count100}-{recentScore.count50}-{recentScore.countmiss}❌ - <b><i>{accuracy:N2}</i></b>%\n" +
                        $"<b>{mods}</b> <i>{recentScore.maxcombo}/{beatmap.max_combo}</i> <b><u>{curpp:N0}pp</u></b> (<b><u>~{ppIFfc:N0}pp</u></b> if FC)\n({DateTimeOffset.Parse(recentScore.date).AddHours(5):dd.MM.yyyy HH:mm})\n\n";
                await BotMain.bot.SendTextMessageAsync(mess.Chat.Id, text, ParseMode.Html);
            }
            catch (FormatException e)
            {
                Other.OnReceivedError(e, mess, "Он ничего не играл последние 24 часа.");
            }
            catch (Exception e)
            {
                Other.OnReceivedError(e, mess, "Чет не получилось :(");
            }
        }
예제 #6
0
 public static async void notifyFunc()
 {
     while (true)
     {
         await Task.Run(() =>
         {
             try
             {
                 for (int i = 0; i <= BotMain.osuUserTGs.Count - 1; i++)
                 {
                     osuApi osuApi        = new osuApi(BotMain.osuToken);
                     Score[] recentScores = osuApi.GetRecentScoresByNameAsync(BotMain.osuUserTGs[i].name, 100).Result;
                     if (recentScores == null)
                     {
                         continue;
                     }
                     int start     = recentScores.Length - 1;
                     bool startgot = false;
                     for (int q = recentScores.Length - 1; q >= 0; q--)
                     {
                         if (DateTimeOffset.Parse(recentScores[q].date) > BotMain.osuUserTGs[i].lastCheckedScore)
                         {
                             start    = q;
                             startgot = true;
                             break;
                         }
                     }
                     if (!startgot)
                     {
                         continue;
                     }
                     for (int j = start; j >= 0; j--)
                     {
                         double accuracy = (50 * double.Parse(recentScores[j].count50) + 100 * double.Parse(recentScores[j].count100) + 300 * double.Parse(recentScores[j].count300)) / (300 * (double.Parse(recentScores[j].countmiss) + double.Parse(recentScores[j].count50) + double.Parse(recentScores[j].count100) + double.Parse(recentScores[j].count300))) * 100;
                         Beatmap beatmap = osuApi.GetBeatmapByBeatmapIdAsync(int.Parse(recentScores[j].beatmap_id)).Result;
                         if (beatmap == null)
                         {
                             continue;
                         }
                         double curpp  = Other.ppCalc(beatmap, accuracy, (Mods)osuApi.CalculateModsMods(int.Parse(recentScores[j].enabled_mods)), int.Parse(recentScores[j].countmiss), int.Parse(recentScores[j].maxcombo));
                         double ifFCpp = Other.ppCalc(beatmap, accuracy, (Mods)osuApi.CalculateModsMods(int.Parse(recentScores[j].enabled_mods)), 0, int.Parse(beatmap.max_combo));
                         Mods mods     = (Mods)osuApi.CalculateModsMods(int.Parse(recentScores[j].enabled_mods));
                         if (curpp > 200 && recentScores[j].rank != "F")
                         {
                             foreach (var item in BotMain.groups)
                             {
                                 if (item.notifyOsu)
                                 {
                                     BotMain.bot.SendTextMessageAsync(item.id, $"<b><u>{BotMain.osuUserTGs[i].name}</u></b> недавно прошел данную карту, набрав <i>{curpp:N0}pp</i>!\n" +
                                                                      $"<b>({recentScores[j].rank})</b> <a href=\"https://osu.ppy.sh/beatmaps/{beatmap.beatmap_id}\">{beatmap.title} [{beatmap.version}]</a> <b>{osuApi.GetBeatmapByBeatmapIdAsync(int.Parse(beatmap.beatmap_id)).Result.GetApproved()}</b>\n" +
                                                                      $"{recentScores[j].count300}-{recentScores[j].count100}-{recentScores[j].count50}-{recentScores[j].countmiss}x❌ - <b><i>{accuracy:N2}%</i></b>\n" +
                                                                      $"<b>{mods}</b> <i>{recentScores[j].maxcombo}/{beatmap.max_combo}</i> <b><u>{curpp:N0}pp</u></b> (<b><u>{ifFCpp:N0}pp</u></b> if FC)\n" +
                                                                      $"{DateTimeOffset.Parse(recentScores[j].date).AddHours(5):dd.MM.yyyy HH:mm}", ParseMode.Html, disableNotification: true).Wait();
                                 }
                             }
                         }
                         BotMain.osuUserTGs[i].lastCheckedScore = DateTimeOffset.Parse(recentScores[j].date);
                     }
                 }
             }
             catch (Exception ex)
             {
                 Other.OnReceivedError(ex, null, "");
             }
         });
     }
 }
예제 #7
0
        public static void Setup()
        {
            StartedTime = new TimeSpan(DateTime.Now.Ticks);
            Random      = new TRandom(new NR3Generator(TMath.Seed()));
            Logger      = new BaseLogger();
            Logger.Log(ConsoleColor.Cyan, LogType.NoDisplay, "Info", "Welcome to Chino-chan!");

            CheckExternalLibs();

            LoadSettings();

            Gelbooru = new Gelbooru();
            Danbooru = new Danbooru();
            Yandere  = new Yandere();

            if (!Settings.Credentials.IsEmpty(CredentialType.Sankaku))
            {
                Sankaku = new Sankaku(Settings.Credentials.Sankaku.Username, Settings.Credentials.Sankaku.Password);
            }

            if (!Settings.Credentials.IsEmpty(CredentialType.Imgur))
            {
                Imgur = new Image.Imgur();
            }

            if (!string.IsNullOrWhiteSpace(Settings.Credentials.Google.ClientSecret) &&
                !string.IsNullOrWhiteSpace(Settings.Credentials.Google.ClientId))
            {
                Logger.Log(ConsoleColor.Green, LogType.GoogleDrive, null, "Logging into GoogleDrive...");
                var Credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets()
                {
                    ClientId     = Settings.Credentials.Google.ClientId,
                    ClientSecret = Settings.Credentials.Google.ClientSecret
                }, new string[] { DriveService.Scope.Drive }, "user", CancellationToken.None).Result;

                GoogleDrive = new DriveService(new BaseClientService.Initializer()
                {
                    HttpClientInitializer = Credential,
                    ApplicationName       = "Chino-chan"
                });
                Logger.Log(ConsoleColor.Green, LogType.GoogleDrive, null, "Logged in!");
            }

            if (!string.IsNullOrWhiteSpace(Settings.Credentials.Google.Token))
            {
                Logger.Log(ConsoleColor.Red, LogType.YouTubeAPI, null, "Creating YouTube service...");

                YouTube = new YouTubeService(new BaseClientService.Initializer()
                {
                    ApiKey          = Settings.Credentials.Google.Token,
                    ApplicationName = "Chino-chan"
                });

                Logger.Log(ConsoleColor.Red, LogType.YouTubeAPI, null, "Done!");
            }

            LanguageHandler = new LanguageHandler();
            GuildSettings   = new GuildSettings();

            Updater = new Updater();

            Client = new DiscordSocketClient(new DiscordSocketConfig()
            {
                AlwaysDownloadUsers = true,
                DefaultRetryMode    = RetryMode.AlwaysRetry,
                LargeThreshold      = 250,
                LogLevel            = LogSeverity.Verbose
            });

            Client.Log += (Log) =>
            {
                Logger.Log(ConsoleColor.White, LogType.Discord, Log.Severity.ToString(), Log.Message);
                return(Task.CompletedTask);
            };
            Client.Ready += () =>
            {
                if (Sankaku != null)
                {
                    Logger.Log(ConsoleColor.DarkYellow, LogType.Sankaku, "Login", "Logging in...");

                    var LoggedIn = Sankaku.Login(out bool TooManyRequests);
                    if (LoggedIn)
                    {
                        Logger.Log(ConsoleColor.DarkYellow, LogType.Sankaku, "Login", "Logged in!");
                    }
                    else
                    {
                        Logger.Log(ConsoleColor.Red, LogType.Sankaku, "Login", "Couldn't log in due to " + (TooManyRequests ? "rate limitation!" : "wrong credentials!"));
                    }
                }

                return(Task.CompletedTask);
            };

            if (osuAPIEnabled)
            {
                osuAPI = new osuApi();
            }

            CommandService = new CommandService(new CommandServiceConfig()
            {
                CaseSensitiveCommands = false,
                LogLevel       = LogSeverity.Verbose,
                DefaultRunMode = RunMode.Async
            });
            Logger.Log(ConsoleColor.Cyan, LogType.Commands, null, "Loading Commands...");

            Services = new ServiceCollection().BuildServiceProvider();

            CommandService.AddModulesAsync(Assembly.GetEntryAssembly(), Services).ContinueWith((ModuleInfo) =>
            {
                Logger.Log(ConsoleColor.Cyan, LogType.Commands, null, "Loaded Commands!");
                var Modules      = ModuleInfo.Result;
                var Text         = "";
                var HelpNotFound = new List <string>();

                var English = LanguageHandler.GetLanguage("en");

                foreach (var Module in Modules)
                {
                    Text += Environment.NewLine + "- " + Module.Name + Environment.NewLine;
                    foreach (var Command in Module.Commands)
                    {
                        Text += "-- " + Command.Name + Environment.NewLine;
                        if (!English.Help.ContainsKey(Command.Name))
                        {
                            HelpNotFound.Add(Command.Name);
                        }
                    }
                }
                Logger.Log(ConsoleColor.Cyan, LogType.Commands, null, "Available modules and commands: " + Text);
                if (HelpNotFound.Count != 0)
                {
                    Logger.Log(ConsoleColor.Cyan, LogType.Commands, "Warning", "Help not found for these commands: " + string.Join(", ", HelpNotFound));
                }
            });

            Client.MessageReceived += async(ReceivedMessage) =>
            {
                var Message = ReceivedMessage as SocketUserMessage;
                if (Message == null)
                {
                    return;
                }

                var Context = new CommandContext(Client, Message);

                var Settings = GuildSettings.GetSettings(Context.Guild != null ? Context.Guild.Id : Context.User.Id);

                if (Global.Settings.SayPreferences.ContainsKey(Context.User.Id) && !Message.Content.StartsWith(Settings.Prefix + "say"))
                {
                    var Prefs = Global.Settings.SayPreferences[Context.User.Id];
                    if (Prefs.Listening.ContainsKey(Context.Channel.Id))
                    {
                        if (Client.GetChannel(Prefs.Listening[Context.Channel.Id]) is ITextChannel Channel)
                        {
                            await Channel.SendMessageAsync(Message.Content);

                            if (Prefs.AutoDel)
                            {
                                var Dm = await Context.User.GetOrCreateDMChannelAsync();

                                if (Dm.Id != Context.Channel.Id)
                                {
                                    await Message.DeleteAsync();
                                }
                            }
                        }
                        else
                        {
                            Global.Settings.SayPreferences[Context.User.Id].Listening.Remove(Context.Channel.Id);
                            SaveSettings();
                        }
                    }
                }


                if (Message.Content == "/gamerescape")
                {
                    var Name = Message.Author.Username;
                    if (!Context.IsPrivate)
                    {
                        await Message.DeleteAsync();

                        Name = (await Context.Guild.GetUserAsync(Message.Author.Id)).Nickname ?? Name;
                    }
                    await Message.Channel.SendMessageAsync($"{ Name } ¯\\_(ツ)_/¯");

                    return;
                }
                else if (Message.Content == "/lenny")
                {
                    var Name = Message.Author.Username;
                    if (!Context.IsPrivate)
                    {
                        await Message.DeleteAsync();

                        Name = (await Context.Guild.GetUserAsync(Message.Author.Id)).Nickname ?? Name;
                    }
                    await Message.Channel.SendMessageAsync($"{ Name } ( ͡° ͜ʖ ͡°)");

                    return;
                }

                int Position = 0;

                if (!(Message.HasStringPrefix(Settings.Prefix, ref Position) ||
                      Message.HasMentionPrefix(Client.CurrentUser, ref Position)))
                {
                    return;
                }

                var MessageCommand = Message.Content.Substring(Position).ToLower();

                if (Images.Images.ContainsKey(MessageCommand))
                {
                    new Task(async() =>
                    {
                        var Pair = Images.Images[MessageCommand];
                        if (Pair.IsNsfw && !(Context.IsPrivate || IsNsfwChannel(Settings, Message.Channel.Id)))
                        {
                            await Message.Channel.SendMessageAsync(LanguageHandler.GetLanguage(Settings.LanguageId).OnlyNsfw);
                            return;
                        }
                        bool Success = false;
                        var File     = "";
                        do
                        {
                            if (!string.IsNullOrWhiteSpace(File))
                            {
                                Images.Images[MessageCommand].Files.Remove(File);

                                if (Images.Images[MessageCommand].Files.Count == 0)
                                {
                                    await Message.Channel.SendMessageAsync(LanguageHandler.GetLanguage(Settings.LanguageId).CantUploadImage);
                                    break;
                                }
                            }
                            File    = Pair.RandomFile();
                            Success = await SendImageAsync(File, Context.Channel, Pair.TitleIncludeName ? Pair.Name : null);
                        }while (!Success);
                    }).Start();
                    return;
                }

                var Result = await CommandService.ExecuteAsync(Context, Position, Services);

                if (!Result.IsSuccess)
                {
                    switch (Result.Error)
                    {
                    case CommandError.BadArgCount:
                        break;

                    case CommandError.ParseFailed:
                        break;

                    case CommandError.UnmetPrecondition:
                        if (Result.ErrorReason == "Owner")
                        {
                            await Context.Channel.SendMessageAsync(Context.GetLanguage().NoOwnerPermission);
                        }
                        else if (Result.ErrorReason == "ServerSide")
                        {
                            await Context.Channel.SendMessageAsync(Context.GetLanguage().OnlyServer);
                        }
                        else
                        {
                            await Context.Channel.SendMessageAsync(Context.GetLanguage().NoPermission);
                        }
                        break;

                    case CommandError.UnknownCommand:
                        if (IsOwner(Context.User.Id))
                        {
                            var Command = Tools.ConvertHighlightsBack(Message.Content.Substring(Position));

                            new Thread(() => Entrance.HandleCommand(Command, Context.Channel as ITextChannel)).Start();
                        }
                        break;

                    default:
                        await Context.Channel.SendMessageAsync($"```css\nAn error happened! Please report this to { Global.Settings.OwnerName }!\n\nError type: { Result.Error }\nReason: { Result.ErrorReason }```");

                        break;
                    }
                }
                else
                {
                    Logger.Log(ConsoleColor.DarkYellow, LogType.Commands, Context.Guild != null ? Context.Guild.Name : Context.Channel.Name, $"#{ Context.Channel.Name } { Context.User.Username } executed { Context.Message.Content }");
                }
            };

            MusicClients = new Dictionary <ulong, Modules.Music>();

            SysInfo = new SysInfo();
            SysInfo.Load();

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }