Ejemplo n.º 1
0
    public StatMan(StatManConfig config)
    {
        try
        {
            // this.Config = config._CloneDeep(); DO NOT CLONE THIE OBJECT!! delegate をクローンすると不具合が発生します。
            this.Config = config;

            this.Config.Callback = config.Callback;

            this.Config.Normalize();

            this.FileNameFullPath = this.Config.StatFileName;
            if (PP.IsAbsolutePath(this.Config.StatFileName) == false)
            {
                this.FileNameFullPath = Env.AppLocalDir._CombinePath("Config", "Statistics", this.Config.StatFileName);
            }

            this.FileNameFullPath = PP.NormalizeDirectorySeparator(this.FileNameFullPath, true);

            this.Database = Lfs.ReadJsonFromFileEncrypted <StatManDatabase>(this.FileNameFullPath, Consts.Strings.StatManEncryptKey, nullIfError: true);
            if (this.Database == null)
            {
                this.Database = new StatManDatabase();
            }

            this.Database.Normalize();

            NormalizeAndPollAsync(noPoll: true)._GetResult();

            this.SaveTask = SaveTaskProcAsync(this.GrandCancel)._LeakCheck();
            this.PostTask = PostTaskProcAsync(this.GrandCancel)._LeakCheck();
        }
        catch (Exception ex)
        {
            this._DisposeSafe(ex);
            throw;
        }
    }