private PolicyChangeBatch GetBindingChanges(TenantCookieCollection tenantCookies)
        {
            IConfigDataProvider   configDataProvider = ConfigDataProviderFactory.Default.Create(DatabaseType.Directory);
            PolicyChangeBatch     newBatch           = UnifiedPolicySession.GetNewBatch <BindingConfiguration>(tenantCookies);
            List <BindingStorage> list  = new List <BindingStorage>();
            List <ScopeStorage>   list2 = new List <ScopeStorage>();

            new List <BindingConfiguration>();
            foreach (TenantCookie tenantCookie in ((IEnumerable <TenantCookie>)tenantCookies))
            {
                PolicySyncCookie policySyncCookie = PolicySyncCookie.Deserialize(tenantCookie.Cookie);
                string           pagingWatermark  = UnifiedPolicySession.GetPagingWatermark <BindingConfiguration>(policySyncCookie);
                string           pagingWatermark2 = UnifiedPolicySession.GetPagingWatermark <ScopeConfiguration>(policySyncCookie);
                QueryFilter      queryFilter      = UnifiedPolicySession.CreateGetChangesQueryFilter(tenantCookie, pagingWatermark, tenantCookies.Workload, true);
                QueryFilter      queryFilter2     = UnifiedPolicySession.CreateGetChangesQueryFilter(tenantCookie, pagingWatermark2, tenantCookies.Workload, true);
                list.AddRange(configDataProvider.FindPaged <BindingStorage>(queryFilter, null, false, null, 1000).Cast <BindingStorage>());
                list2.AddRange(configDataProvider.FindPaged <ScopeStorage>(queryFilter2, null, false, null, 1000).Cast <ScopeStorage>());
                bool flag;
                UnifiedPolicySession.SetPagingWatermark <BindingConfiguration>(policySyncCookie, PagingHelper.GetProcessedCookie(queryFilter, out flag));
                bool flag2;
                UnifiedPolicySession.SetPagingWatermark <ScopeConfiguration>(policySyncCookie, PagingHelper.GetProcessedCookie(queryFilter2, out flag2));
                TenantCookie tenantCookie2 = newBatch.NewCookies[tenantCookie.TenantId];
                tenantCookie2.Cookie   = policySyncCookie.Serialize();
                tenantCookie2.MoreData = (!flag || !flag2);
            }
            using (List <ScopeStorage> .Enumerator enumerator2 = list2.GetEnumerator())
            {
                while (enumerator2.MoveNext())
                {
                    UnifiedPolicySession.< > c__DisplayClass19 CS$ < > 8__locals1 = new UnifiedPolicySession.< > c__DisplayClass19();
                    CS$ < > 8__locals1.scope = enumerator2.Current;
                    Guid           parentBindingId = Guid.Parse((string)CS$ < > 8__locals1.scope[UnifiedPolicyStorageBaseSchema.ContainerProp]);
                    BindingStorage bindingStorage  = list.FirstOrDefault((BindingStorage b) => b.Id.ObjectGuid == parentBindingId && b.OrganizationalUnitRoot.ObjectGuid == CS$ < > 8__locals1.scope.OrganizationalUnitRoot.ObjectGuid);
                    if (bindingStorage == null)
                    {
                        bindingStorage = configDataProvider.Find <BindingStorage>(UnifiedPolicySession.CreateGetObjectQueryFilter(CS$ < > 8__locals1.scope.OrganizationalUnitRoot.ObjectGuid, parentBindingId, true), null, false, null).Cast <BindingStorage>().FirstOrDefault <BindingStorage>();
                        list.Add(bindingStorage);
                    }
                    if (CS$ < > 8__locals1.scope.ObjectState == ObjectState.Deleted)
                    {
                        bindingStorage.RemovedScopes.Add(CS$ < > 8__locals1.scope);
                    }
        private PolicyChangeBatch GetChangesInternal <TStorage, TResult>(TenantCookieCollection tenantCookies, Func <TStorage, TResult> convertFunc, bool scopeToWorkload) where TStorage : UnifiedPolicyStorageBase, new() where TResult : PolicyConfigurationBase
        {
            PolicyChangeBatch newBatch = UnifiedPolicySession.GetNewBatch <TResult>(tenantCookies);
            List <TResult>    list     = new List <TResult>();

            foreach (TenantCookie tenantCookie in ((IEnumerable <TenantCookie>)tenantCookies))
            {
                PolicySyncCookie policySyncCookie = PolicySyncCookie.Deserialize(tenantCookie.Cookie);
                string           pagingWatermark  = UnifiedPolicySession.GetPagingWatermark <TResult>(policySyncCookie);
                QueryFilter      queryFilter      = UnifiedPolicySession.CreateGetChangesQueryFilter(tenantCookie, pagingWatermark, tenantCookies.Workload, scopeToWorkload);
                list.AddRange(from TStorage s in UnifiedPolicySession.GetTenantSession(tenantCookie.TenantId).FindPaged <TStorage>(queryFilter, null, false, null, 1000)
                              select convertFunc(s));
                bool flag;
                UnifiedPolicySession.SetPagingWatermark <TResult>(policySyncCookie, PagingHelper.GetProcessedCookie(queryFilter, out flag));
                TenantCookie tenantCookie2 = newBatch.NewCookies[tenantCookie.TenantId];
                tenantCookie2.Cookie   = policySyncCookie.Serialize();
                tenantCookie2.MoreData = !flag;
            }
            newBatch.Changes = list;
            return(newBatch);
        }