protected override void WriteResult <T>(IEnumerable <T> dataObjects)
        {
            SyncTaskHelper.OneParameterMethod <bool, IConfigurable> oneParameterMethod  = null;
            SyncTaskHelper.OneParameterMethod <bool, IConfigurable> oneParameterMethod2 = null;
            ADRawEntry adrawEntry = null;

            if (dataObjects is ADPagedReader <ADRawEntry> )
            {
                bool flag;
                if (this.requireTwoQueries)
                {
                    IEnumerable <ADRawEntry> dataObjects2 = (IEnumerable <ADRawEntry>)dataObjects;
                    IEnumerable <ADRawEntry> dataObjects3 = this.reader2;
                    SyncCookie syncCookie = this.inputCookie;
                    SyncTaskHelper.ParameterlessMethod <bool> isStopping = () => base.Stopping;
                    if (oneParameterMethod == null)
                    {
                        oneParameterMethod = ((IConfigurable dataObject) => false);
                    }
                    this.searchNeedsRetry = !SyncTaskHelper.HandleTaskWritePagedResult <ADRawEntry>(dataObjects2, dataObjects3, syncCookie, ref this.outputCookie, isStopping, oneParameterMethod, new SyncTaskHelper.VoidOneParameterMethod <IConfigurable>(this.WriteResult), this.Pages, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskErrorLoggingDelegate(base.WriteError), out flag);
                }
                else
                {
                    IEnumerable <ADRawEntry> dataObjects4 = (IEnumerable <ADRawEntry>)dataObjects;
                    SyncCookie syncCookie2 = this.inputCookie;
                    SyncTaskHelper.ParameterlessMethod <bool> isStopping2 = () => base.Stopping;
                    if (oneParameterMethod2 == null)
                    {
                        oneParameterMethod2 = ((IConfigurable dataObject) => false);
                    }
                    this.searchNeedsRetry = !SyncTaskHelper.HandleTaskWritePagedResult <ADRawEntry>(dataObjects4, syncCookie2, ref this.outputCookie, isStopping2, oneParameterMethod2, new SyncTaskHelper.VoidOneParameterMethod <IConfigurable>(this.WriteResult), this.Pages, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskErrorLoggingDelegate(base.WriteError), out flag);
                }
                if (!this.searchNeedsRetry && !flag)
                {
                    adrawEntry = new DeletedRecipient();
                }
            }
            else
            {
                adrawEntry = ((List <ADRawEntry>)dataObjects)[0];
            }
            if (adrawEntry != null)
            {
                this.outputCookie = new SyncCookie(this.inputCookie.DomainController, this.inputCookie.HighWatermarks, WatermarkMap.Empty, null);
                this.WriteResult(adrawEntry);
            }
        }
Ejemplo n.º 2
0
        public static bool HandleTaskWritePagedResult <T>(IEnumerable <T> dataObjects, SyncCookie inputCookie, ref SyncCookie outputCookie, SyncTaskHelper.ParameterlessMethod <bool> isStopping, SyncTaskHelper.OneParameterMethod <bool, IConfigurable> shouldSkipObject, SyncTaskHelper.VoidOneParameterMethod <IConfigurable> writeResult, int pages, Task.TaskVerboseLoggingDelegate writeVerbose, Task.TaskErrorLoggingDelegate writeError, out bool hasOutput) where T : IConfigurable, new()
        {
            TaskLogger.LogEnter(new object[]
            {
                dataObjects
            });
            ADPagedReader <T> adpagedReader = dataObjects as ADPagedReader <T>;

            hasOutput = false;
            using (IEnumerator <T> enumerator = dataObjects.GetEnumerator())
            {
                bool flag = true;
                SyncTaskHelper.CookieObjectTriple <T> cookieObjectTriple = null;
                byte[] cookie = adpagedReader.Cookie;
                bool   flag2  = enumerator.MoveNext();
                if (adpagedReader.LastRetrievedCount == 0 && adpagedReader.Cookie != null && adpagedReader.Cookie.Length != 0)
                {
                    return(false);
                }
                while (!isStopping() && flag2)
                {
                    T      t             = enumerator.Current;
                    byte[] pageCookie    = adpagedReader.Cookie;
                    int    pagesReturned = adpagedReader.PagesReturned;
                    flag2 = enumerator.MoveNext();
                    if (!shouldSkipObject(t))
                    {
                        hasOutput = true;
                        if (cookieObjectTriple != null)
                        {
                            if (cookieObjectTriple.CurrentPage != pagesReturned || flag)
                            {
                                outputCookie = cookieObjectTriple.Cookie;
                            }
                            else
                            {
                                outputCookie = null;
                            }
                            writeResult(cookieObjectTriple.DataObject);
                            if (outputCookie != null)
                            {
                                pages--;
                                if (pages < 0)
                                {
                                    break;
                                }
                            }
                            flag = false;
                        }
                        else
                        {
                            pageCookie = cookie;
                        }
                        cookieObjectTriple = new SyncTaskHelper.CookieObjectTriple <T>(pagesReturned, t, new SyncCookie(inputCookie.DomainController, inputCookie.LowWatermarks, inputCookie.HighWatermarks, pageCookie));
                    }
                }
                if (!flag2 && cookieObjectTriple != null && pages >= 0)
                {
                    outputCookie = new SyncCookie(inputCookie.DomainController, inputCookie.HighWatermarks, WatermarkMap.Empty, null);
                    writeResult(cookieObjectTriple.DataObject);
                }
            }
            TaskLogger.LogExit();
            return(true);
        }
Ejemplo n.º 3
0
        public static bool HandleTaskWritePagedResult <T>(IEnumerable <T> dataObjects, IEnumerable <T> dataObjects2, SyncCookie inputCookie, ref SyncCookie outputCookie, SyncTaskHelper.ParameterlessMethod <bool> isStopping, SyncTaskHelper.OneParameterMethod <bool, IConfigurable> shouldSkipObject, SyncTaskHelper.VoidOneParameterMethod <IConfigurable> writeResult, int pages, Task.TaskVerboseLoggingDelegate writeVerbose, Task.TaskErrorLoggingDelegate writeError, out bool hasOutput) where T : IConfigurable, new()
        {
            TaskLogger.LogEnter(new object[]
            {
                dataObjects
            });
            int  num   = 1000;
            int  num2  = 0;
            bool flag  = true;
            bool flag2 = true;

            SyncTaskHelper.CookieObjectTriple <T> cookieObjectTriple = null;
            int num3 = 1;
            ADPagedReader <T> adpagedReader  = dataObjects as ADPagedReader <T>;
            ADPagedReader <T> adpagedReader2 = dataObjects2 as ADPagedReader <T>;

            byte[] pageCookie = null;
            byte[] array      = null;
            byte[] cookie     = adpagedReader.Cookie;
            byte[] cookie2    = adpagedReader2.Cookie;
            byte[] array2     = cookie2;
            hasOutput = false;
            for (;;)
            {
                using (IEnumerator <T> enumerator = flag ? dataObjects.GetEnumerator() : dataObjects2.GetEnumerator())
                {
                    bool flag3 = enumerator.MoveNext();
                    bool flag4 = !flag && ((cookieObjectTriple == null && num2 == 0) || (cookieObjectTriple != null && num2 == num - 1));
                    if ((adpagedReader.LastRetrievedCount == 0 && adpagedReader.Cookie != null && adpagedReader.Cookie.Length != 0) || (adpagedReader2.LastRetrievedCount == 0 && adpagedReader2.Cookie != null && adpagedReader2.Cookie.Length != 0))
                    {
                        return(false);
                    }
                    while (!isStopping() && flag3)
                    {
                        T t = enumerator.Current;
                        if (flag)
                        {
                            pageCookie = adpagedReader.Cookie;
                        }
                        else if (array != adpagedReader2.Cookie)
                        {
                            array2 = array;
                            array  = adpagedReader2.Cookie;
                        }
                        flag3 = enumerator.MoveNext();
                        if (!shouldSkipObject(t))
                        {
                            hasOutput = true;
                            if (cookieObjectTriple != null)
                            {
                                if (num2 == num - 1 || flag2)
                                {
                                    outputCookie = cookieObjectTriple.Cookie;
                                }
                                else
                                {
                                    outputCookie = null;
                                }
                                writeResult(cookieObjectTriple.DataObject);
                                flag2 = false;
                                if (num2 == num - 1)
                                {
                                    num2 = 0;
                                    num3++;
                                }
                                else
                                {
                                    num2++;
                                }
                                if (outputCookie != null)
                                {
                                    pages--;
                                    if (pages < 0)
                                    {
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                pageCookie = cookie;
                                array      = cookie2;
                                array2     = cookie2;
                            }
                            cookieObjectTriple = new SyncTaskHelper.CookieObjectTriple <T>(num3, t, new SyncCookie(inputCookie.DomainController, inputCookie.LowWatermarks, inputCookie.HighWatermarks, pageCookie, flag4 ? array : array2));
                        }
                    }
                    if (pages >= 0)
                    {
                        if (!flag && !flag3 && cookieObjectTriple != null && pages >= 0)
                        {
                            outputCookie = new SyncCookie(inputCookie.DomainController, inputCookie.HighWatermarks, WatermarkMap.Empty, null, null);
                            writeResult(cookieObjectTriple.DataObject);
                        }
                        else if (flag)
                        {
                            flag = false;
                            continue;
                        }
                    }
                }
                break;
            }
            TaskLogger.LogExit();
            return(true);
        }
Ejemplo n.º 4
0
        public static bool HandleTaskWritePagedResult <T>(IEnumerable <T> dataObjects, SyncCookie inputCookie, ref SyncCookie outputCookie, SyncTaskHelper.ParameterlessMethod <bool> isStopping, SyncTaskHelper.OneParameterMethod <bool, IConfigurable> shouldSkipObject, SyncTaskHelper.VoidOneParameterMethod <IConfigurable> writeResult, int pages, Task.TaskVerboseLoggingDelegate writeVerbose, Task.TaskErrorLoggingDelegate writeError) where T : IConfigurable, new()
        {
            bool flag;

            return(SyncTaskHelper.HandleTaskWritePagedResult <T>(dataObjects, inputCookie, ref outputCookie, isStopping, shouldSkipObject, writeResult, pages, writeVerbose, writeError, out flag));
        }