public List <Tuple <string, string, bool> > RemovePages(List <Tuple <string, string> > pagesBeingRemoved, IProgress <Tuple <int, int, int, string> > progress, System.Threading.CancellationToken cancellationToken)
        {
            int countRemoved        = 0;
            int countFailedToRemove = 0;
            int countTotal          = pagesBeingRemoved.Count;
            List <Tuple <string, string, bool> > ret = new List <Tuple <string, string, bool> >();

            foreach (Tuple <string, string> elem in pagesBeingRemoved)
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    OnCancelled.Invoke();
                    break;
                }
                if (onenoteApplication.TryDeleteHierarchy(elem.Item1))
                {
                    countRemoved += 1;
                    ret.Add(Tuple.Create(elem.Item1, elem.Item2, true));
                }
                else
                {
                    countFailedToRemove += 1;
                    ret.Add(Tuple.Create(elem.Item1, elem.Item2, false));
                }
                progress.Report(Tuple.Create(countRemoved, countFailedToRemove, countTotal, elem.Item2));
            }
            return(ret);
        }
 public void UserDidCancelPayPalProfileSharingViewController(PayPalProfileSharingViewController profileSharingViewController)
 {
     Debug.WriteLine("PayPal Profile Sharing Authorization Canceled");
     profileSharingViewController?.DismissViewController(true, null);
     OnCancelled?.Invoke();
     OnCancelled = null;
 }
Exemple #3
0
        private IEnumerator Wrapper(IEnumerator target)
        {
            bool didComplete = false;

            try
            {
                while (target.MoveNext())
                {
                    if (target.Current is Cancelled)
                    {
                        OnCancelled?.Invoke();
                        yield break;
                    }

                    yield return(target.Current);
                }

                didComplete = true;
            }
            finally
            {
                if (didComplete)
                {
                    OnSuccessful?.Invoke();
                }
            }
            OnDone?.Invoke();
        }
 public void PayPalFuturePaymentDidCancel(PayPalFuturePaymentViewController futurePaymentViewController)
 {
     Debug.WriteLine("PayPal Future Payment Authorization Canceled");
     futurePaymentViewController?.DismissViewController(true, null);
     OnCancelled?.Invoke();
     OnCancelled = null;
 }
        private async void InteractWithClient(Socket client,
                                              Func <Socket, CancellationToken, Task> clientInteraction, CancellationToken token)
        {
            var socketInfo = new SocketEndpoints();

            try
            {
                using (client)
                {
                    socketInfo = new SocketEndpoints(client);

                    OnConnected?.Invoke(client);

                    await clientInteraction(client, token).ConfigureAwait(false);
                }
            }
            catch (OperationCanceledException ex)
            {
                OnCancelled?.Invoke(socketInfo, ex);
            }
            catch (Exception ex)
            {
                OnException?.Invoke(socketInfo, ex);
            }
            finally
            {
                OnDisconnected?.Invoke(socketInfo);
            }
        }
 void Awake()
 {
     currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory());
     items            = new List <Transform>();
     acceptButton.onClick.AddListener(() => OnAccepted?.Invoke(resultPath));
     cancelButton.onClick.AddListener(() => OnCancelled?.Invoke());
 }
Exemple #7
0
    protected IEnumerator Perform_Coroutine()
    {
        yield return(StartCoroutine(PreCast()));

        if (!string.IsNullOrEmpty(castTrigger))
        {
            animator.SetFloat("CastSpeed", 1f / castTime);
            animator.SetTrigger(castTrigger);
            yield return(new WaitForCast(animator));
        }

        if (cancelled)
        {
            if (OnCancelled != null)
            {
                OnCancelled.Invoke(this);
            }
            yield break;
        }

        if (OnPerformed != null)
        {
            OnPerformed.Invoke(this);
        }

        yield return(StartCoroutine(PerformAction()));

        actionInProgress = null;
    }
Exemple #8
0
 public override void CancelTargeting()
 {
     StopTargeting();
     if (OnCancelled != null)
     {
         OnCancelled.Invoke();
     }
 }
    public override void Awake()
    {
        base.Awake();

        acceptButton.onClick.AddListener(() => OnAccepted?.Invoke(this));
        rejectButton.onClick.AddListener(() => OnRejected?.Invoke(this));
        cancelButton.onClick.AddListener(() => OnCancelled?.Invoke(this));
    }
 public override void Stop()
 {
     StopAllCoroutines();
     if (OnCancelled != null)
     {
         OnCancelled.Invoke(this);
     }
 }
    void Start()
    {
        inputField.caretPosition = 0; // desired cursor position

        inputField.GetType().GetField("m_AllowInput", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(inputField, true);
        inputField.GetType().InvokeMember("SetCaretVisible", BindingFlags.NonPublic | BindingFlags.InvokeMethod | BindingFlags.Instance, null, inputField, null);

        acceptButton.onClick.AddListener(() => OnAccepted?.Invoke(inputField.text));
        cancelButton.onClick.AddListener(() => OnCancelled?.Invoke());
    }
Exemple #12
0
        public void Cancel(OnCancelled onCancelled = null)
        {
            Collider2D    closestInteractee = GetClosestInteractee();
            IInteractible interactible      = closestInteractee?.GetComponent <IInteractible>();

            if (interactible != null)
            {
                onCancelled?.Invoke(interactible.InteractibleType, interactible.Transform);
                interactible.Cancel(INTERACTIBLE_TYPE.USER, transform);
            }
        }
 /// <summary>
 /// Reset cancellation token source, which is originally only intended to be used once
 /// </summary>
 private void SetCancellationToken()
 {
     _cancellationTokenSource = new CancellationTokenSource();
     _cancellationTokenSource.Token.Register(() => {
         CleanTempData(true);
         OnCancelled?.Invoke(this, new EventArgs());
         _busy = false;
         _logger.LogInformation("Encoding cancelled");
         _cancellationTokenSource = new CancellationTokenSource();
         _cancellationTokenSource.Token.Register(() => SetCancellationToken());
     });
 }
Exemple #14
0
        protected void Finished()
        {
            State = StoryState.Stopped;
            Cleanup();

            if (!CancellationTokenSource.IsCancellationRequested)
            {
                OnFinished?.Invoke(this, EventArgs.Empty);
            }
            else
            {
                OnCancelled?.Invoke(this, EventArgs.Empty);
            }
        }
Exemple #15
0
        async void OnCancelReservation()
        {
            var proxy    = ProxyFactory.GetProxyInstace();
            var response = await proxy.ExecuteAsync(API.Endpoints.ReservationsEndpoints.CancelReservation(reservation.Id));

            if (response.Successful)
            {
                OnCancelled?.Invoke(this, reservation);
                Toast.MakeText(this, "Reservation cancelled successfully!", ToastLength.Short).Show();
                Finish();
            }
            else
            {
                Toast.MakeText(this, "Failed cancelling reservation", ToastLength.Short).Show();
            }
        }
 void DataCancelled(SDCancelledEventArgs args)
 {
     OnCancelled?.Invoke(args);
 }
        public bool TryFlattenSections(string targetSectionName, IProgress <Tuple <int, int, int, string> > progress, System.Threading.CancellationToken cancellationToken)
        {
            onenoteApplication.TryGetSectionHierarchyAsXML(out string rawXmlString);
            System.Xml.XmlDocument sectionHierarchyXml = new System.Xml.XmlDocument();
            try
            {
                sectionHierarchyXml.LoadXml(rawXmlString);
                string destinationSectionId            = null;
                System.Xml.XmlNodeList sectionNodeList = sectionHierarchyXml.GetElementsByTagName("one:Section");
                int countTotalSections        = sectionNodeList.Count;
                int countFlattenedSections    = 0;
                int countNotFlattenedSections = 0;
                foreach (System.Xml.XmlNode sectionNode in sectionNodeList)
                {
                    if (sectionNode.Attributes["name"].Value == targetSectionName)
                    {
                        destinationSectionId = sectionNode.Attributes["ID"].Value;
                        break;
                    }
                }
                if (destinationSectionId != null)
                {
                    foreach (System.Xml.XmlNode sectionNode in sectionNodeList)
                    {
                        if (cancellationToken.IsCancellationRequested)
                        {
                            OnCancelled.Invoke();
                            break;
                        }
                        string sourceSectionName = sectionNode.Attributes["name"].Value;
                        if (sourceSectionName != targetSectionName)
                        {
                            string sourceSectionId = sectionNode.Attributes["ID"].Value;

                            if ((sectionNode.Attributes["isInRecycleBin"] == null) || (sectionNode.Attributes["isInRecycleBin"].Value != "true") &&
                                (sectionNode.Attributes["isDeletedPages"] == null) || (sectionNode.Attributes["isDeletedPages"].Value != "true"))
                            {
                                if (onenoteApplication.TryMergeSection(sourceSectionId, destinationSectionId))
                                {
                                    countFlattenedSections += 1;
                                }
                                else
                                {
                                    countNotFlattenedSections += 1;
                                }
                            }
                        }
                        progress.Report(Tuple.Create(countFlattenedSections, countNotFlattenedSections, countTotalSections, sourceSectionName));
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (System.Exception exception)
            {
                etc.LoggerHelper.LogUnexpectedException(exception);
                return(false);
            }
        }
Exemple #18
0
 void onCancelPressed()
 {
     UserInput = "";
     OnCancelled?.Invoke(this, EventArgs.Empty);
 }
Exemple #19
0
 private void Dialog_DismissEvent(object sender, EventArgs e)
 {
     OnCancelled?.Invoke(sender, e);
 }
Exemple #20
0
        private void DoWork()
        {
            O2GSession      session        = null;
            O2GTableManager tableManager   = null;
            StatusListener  statusListener = null;
            TableListener   tableListener  = null;

            bool canUnsubscribeSessionStatus = false;

            try
            {
                session = O2GTransport.createSession();

                session.useTableManager(O2GTableManagerMode.Yes, null);

                var sessionId = Guid.NewGuid().ToString("N");

                statusListener = new StatusListener(session, sessionId);

                statusListener.OnStatus += (s, e) =>
                {
                    var status = e.Item.ToStatus();

                    OnStatus?.Invoke(this, new GenericArgs <Status>(status));

                    if (status == Status.Disconnected)
                    {
                        OnDisconnected?.Invoke(this, EventArgs.Empty);
                    }
                };

                session.subscribeSessionStatus(statusListener);

                session.login(userName, password, URL, connection.ToString());

                if (statusListener.WaitEvents() && statusListener.Connected)
                {
                    tableListener = new TableListener(testingMode);

                    tableListener.OnOffer += (s, e) =>
                                             OnOffer?.Invoke(this, new GenericArgs <Offer>(e.Item));

                    // improve this plus get rid of response listener
                    tableListener.OnOfferIds += (s, e) =>
                    {
                        //var request = GetSetSubscriptionStatusRequest(session, e.Item);

                        //if (request == null)
                        //    throw new Exception("Cannot create request");

                        //var responseListener = new ResponseListener();

                        //session.subscribeResponse(responseListener);

                        //responseListener.SetRequestID(request.RequestID);

                        //session.sendRequest(request);

                        //if (!responseListener.WaitEvents())
                        //    throw new Exception("Response waiting timeout expired");
                    };

                    tableManager = session.getTableManager();

                    var managerStatus = tableManager.getStatus();

                    // max wait
                    while (managerStatus == O2GTableManagerStatus.TablesLoading)
                    {
                        Thread.Sleep(50);

                        managerStatus = tableManager.getStatus();
                    }

                    if (managerStatus == O2GTableManagerStatus.TablesLoadFailed)
                    {
                        throw new Exception("TableManager refresh failed!");
                    }

                    tableListener.SetSymbols(
                        Enum.GetValues(typeof(Symbol)).Cast <Symbol>().ToList());

                    tableListener.SubscribeEvents(tableManager);

                    O2GOffersTable offers = null;

                    offers = (O2GOffersTable)tableManager.getTable(O2GTableType.Offers);

                    tableListener.HandleOffers(offers);

                    cancelEvent.WaitOne();

                    OnCancelled?.Invoke(this, EventArgs.Empty);
                }
            }
            catch (Exception error)
            {
                OnError?.Invoke(this, new GenericArgs <Exception>(error));
            }
            finally
            {
                Shutdown(session, statusListener, tableListener, tableManager);

                if (canUnsubscribeSessionStatus)
                {
                    session.unsubscribeSessionStatus(statusListener);
                }

                if (session != null)
                {
                    session.Dispose();
                }
            }
        }
Exemple #21
0
 private void Close()
 {
     OnCancelled?.Invoke();
 }
 void CancelInternal()
 {
     SetText("");
     this.realtimeSearchCachedText = "";
     OnCancelled?.Invoke(this, EventArgs.Empty);
 }
        public Tuple <bool, string> ScanOneNotePages(IProgress <Tuple <int, int, int, string> > progress, System.Threading.CancellationToken cancellationToken)
        {
            Tuple <bool, string> resultUpdatePageInfos = UpdatePageInfos();

            if (resultUpdatePageInfos.Item1 == false)
            {
                return(resultUpdatePageInfos);
            }
            else
            {
                etc.LoggerHelper.LogInfo("Found {0} pages.", pageInfos.Count);
                int    statCountReadSuccess = 0;
                int    statCountReadFailed  = 0;
                int    statCountTotal       = pageInfos.Count;
                string statPageTitle        = null;
                progress.Report(Tuple.Create(statCountReadSuccess, statCountReadFailed, statCountTotal, statPageTitle));
                foreach (KeyValuePair <string, OneNotePageInfo> elem in pageInfos)
                {
                    if (cancellationToken.IsCancellationRequested)
                    {
                        OnCancelled.Invoke();
                        break;
                    }
                    string          pageId      = elem.Key;
                    OneNotePageInfo pageInfo    = elem.Value;
                    string          pageContent = "";
                    bool            successHash = false;
                    pageInfo.HashValueForInnerText = null;
                    if (onenoteApplication.TryGetPageContent(elem.Key, out pageContent))
                    {
                        try
                        {
                            System.Xml.XmlDocument pageContentXml = new System.Xml.XmlDocument();
                            pageContentXml.LoadXml(pageContent);

                            /*
                             * Though the page contents are identical, it is quite common to see different 'objectID' and 'lastModified' attributes.
                             * This difference results in a completely different hash value, which cannot be detected by other duplicate remove software.
                             * By simply taking 'innerText' of the internal XML-like format, those attributes will be ignored.
                             * [!] The underlying assumption is that a user cannot modify the attributes directly.
                             */
                            if (TryCalculateHashValue(pageContentXml.InnerText, out string hashValue))
                            {
                                successHash = true;
                                pageInfo.HashValueForInnerText = hashValue;
                            }
                            else
                            {
                                etc.LoggerHelper.LogWarn("Failed to calculate hash for the page ({0}).", pageId);
                            }
                        }
                        catch (System.Exception exception)
                        {
                            etc.LoggerHelper.LogUnexpectedException(exception);
                        }
                    }

                    statPageTitle = pageInfo.PageTitle;
                    if (successHash)
                    {
                        statCountReadSuccess += 1;
                    }
                    else
                    {
                        statCountReadFailed += 1;
                        etc.LoggerHelper.LogWarn("Failed to retrieve the content of the page ({0}).", pageId);
                    }
                    progress.Report(Tuple.Create(statCountReadSuccess, statCountReadFailed, statCountTotal, statPageTitle));
                }
            }
            return(Tuple.Create(true, ""));
        }