コード例 #1
0
ファイル: SharersHub.cs プロジェクト: tgckpg/wenku10
        public async Task<bool> Remove( HubScriptItem HSI, string AccessToken = null )
        {
            TaskCompletionSource<bool> TCS = new TaskCompletionSource<bool>();
            TokenManager TokMgr = new TokenManager();
            AESManager AESMgr = new AESManager();

            if ( AccessToken == null )
                AccessToken = ( string ) TokMgr.GetAuthById( HSI.Id )?.Value;

            RCache.POST(
                Shared.ShRequest.Server
                , Shared.ShRequest.ScriptRemove( AccessToken, HSI.Id )
                , ( e2, QId ) =>
                {
                    try
                    {
                        JsonStatus.Parse( e2.ResponseString );
                        TCS.TrySetResult( true );
                        Worker.UIInvoke( () => SearchSet.Remove( HSI ) );
                        TokMgr.UnassignId( HSI.Id );
                        AESMgr.UnassignId( HSI.Id );
                    }
                    catch ( Exception ex )
                    {
                        HSI.ErrorMessage = ex.Message;
                        TCS.TrySetResult( false );
                    }
                }
                , ( a, b, ex ) =>
                {
                    HSI.ErrorMessage = ex.Message;
                    TCS.TrySetResult( false );
                }
                , false
            );

            return await TCS.Task;
        }