private void InvokeEhfDeleteDomains()
        {
            if (this.domainsToDelete == null || this.domainsToDelete.Count == 0)
            {
                return;
            }
            DomainResponseInfoSet responseSet = null;

            base.InvokeProvisioningService("Delete Domain", delegate
            {
                responseSet = this.ProvisioningService.DeleteDomains(this.domainsToDelete);
            }, this.domainsToDelete.Count);
            int transientFailureCount = 0;
            int permanentFailureCount = 0;

            for (int i = 0; i < responseSet.ResponseInfo.Length; i++)
            {
                DomainResponseInfo domainResponseInfo = responseSet.ResponseInfo[i];
                EhfDomainItem      ehfDomainItem      = this.domainsToDelete[i];
                if (domainResponseInfo.Status == ResponseStatus.Success)
                {
                    base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Successfully deleted EHF domain: DN=<{0}>; GUID=<{1}>; EHF-Company-ID=<{2}>", new object[]
                    {
                        ehfDomainItem.DistinguishedName,
                        domainResponseInfo.DomainGuid.Value,
                        ehfDomainItem.Domain.CompanyId
                    });
                }
                else if (domainResponseInfo.Fault.Id == FaultId.DomainDoesNotExist)
                {
                    base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Attempted to delete a domain that does not exist; ignoring the domain: DN=<{0}>; GUID=<{1}>; EHF-Company-ID=<{2}>", new object[]
                    {
                        ehfDomainItem.DistinguishedName,
                        ehfDomainItem.GetDomainGuid(),
                        ehfDomainItem.Domain.CompanyId
                    });
                }
                else if (domainResponseInfo.Fault.Id == FaultId.DomainExistOutsideThisCompany)
                {
                    base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Attempted to delete a domain that belongs to a different company under this reseller; ignoring the domain: DN=<{0}>; GUID=<{1}>; EHF-Company-ID=<{2}>", new object[]
                    {
                        ehfDomainItem.DistinguishedName,
                        ehfDomainItem.GetDomainGuid(),
                        ehfDomainItem.Domain.CompanyId
                    });
                }
                else if (domainResponseInfo.Fault.Id == FaultId.AccessDenied)
                {
                    base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Attempted to delete a domain that belongs to a different company outside of this reseller; ignoring the domain: DN=<{0}>; GUID=<{1}>; EHF-Company-ID=<{2}>", new object[]
                    {
                        ehfDomainItem.DistinguishedName,
                        ehfDomainItem.GetDomainGuid(),
                        ehfDomainItem.Domain.CompanyId
                    });
                }
                else
                {
                    this.HandleFailedDomain("Delete Domain", ehfDomainItem, domainResponseInfo, ref transientFailureCount, ref permanentFailureCount);
                }
                if (!ehfDomainItem.EventLogAndTryStoreSyncErrors(base.ADAdapter))
                {
                    throw new InvalidOperationException("EventLogAndTryStoreSyncErrors() returned false for a deleted object");
                }
            }
            base.HandlePerEntryFailureCounts("Delete Domain", this.domainsToDelete.Count, transientFailureCount, permanentFailureCount, false);
            this.domainsToDelete.Clear();
        }
        protected virtual void HandleCreateDomainResponse(DomainResponseInfoSet responseSet, List <EhfDomainItem> domainsTriedToCreate)
        {
            int num = 0;
            int permanentFailureCount = 0;

            for (int i = 0; i < responseSet.ResponseInfo.Length; i++)
            {
                DomainResponseInfo domainResponseInfo = responseSet.ResponseInfo[i];
                EhfDomainItem      ehfDomainItem      = domainsTriedToCreate[i];
                bool flag = false;
                if (domainResponseInfo.Status == ResponseStatus.Success)
                {
                    flag = true;
                    base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Successfully created EHF domain: DN=<{0}>; Name=<{1}>; GUID=<{2}>; EHF-Company-ID=<{3}>", new object[]
                    {
                        ehfDomainItem.DistinguishedName,
                        ehfDomainItem.Domain.Name,
                        domainResponseInfo.DomainGuid.Value,
                        ehfDomainItem.Domain.CompanyId
                    });
                }
                else if (domainResponseInfo.Fault.Id == FaultId.DomainExistUnderThisCompany || domainResponseInfo.Fault.Id == FaultId.DomainExistOutsideThisCompany)
                {
                    Guid domainGuid = ehfDomainItem.GetDomainGuid();
                    if (domainResponseInfo.Fault.Id == FaultId.DomainExistUnderThisCompany && domainResponseInfo.DomainGuid.Value.Equals(domainGuid))
                    {
                        flag = true;
                        base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Attempted to create a domain that already exists: DN=<{0}>; Name=<{1}>; GUID=<{2}>; EHF-Company-ID=<{3}>", new object[]
                        {
                            ehfDomainItem.DistinguishedName,
                            ehfDomainItem.Domain.Name,
                            domainGuid,
                            ehfDomainItem.Domain.CompanyId
                        });
                    }
                    else if (!this.handledAllDeletedDomains)
                    {
                        base.AddItemToLazyList <EhfDomainItem>(ehfDomainItem, ref this.domainsToCreateLast);
                        EdgeSyncDiag         diagSession = base.DiagSession;
                        EdgeSyncLoggingLevel level       = EdgeSyncLoggingLevel.Low;
                        string   messageFormat           = "Attempted to create a domain with the name that already exists but a different GUID: DN=<{0}>; Name=<{1}>; AD-GUID=<{2}>; EHF-GUID=<{3}>; EHF-Company-ID=<{4}>";
                        object[] array = new object[5];
                        array[0] = ehfDomainItem.DistinguishedName;
                        array[1] = ehfDomainItem.Name;
                        array[2] = domainGuid;
                        object[] array2      = array;
                        int      num2        = 3;
                        Guid?    domainGuid2 = domainResponseInfo.DomainGuid;
                        array2[num2] = ((domainGuid2 != null) ? domainGuid2.GetValueOrDefault() : "null");
                        array[4]     = ehfDomainItem.Domain.CompanyId;
                        diagSession.LogAndTraceInfo(level, messageFormat, array);
                    }
                    else
                    {
                        this.HandleFailedDomain("Create Domain", ehfDomainItem, domainResponseInfo, ref num, ref permanentFailureCount);
                    }
                }
                else
                {
                    this.HandleFailedDomain("Create Domain", ehfDomainItem, domainResponseInfo, ref num, ref permanentFailureCount);
                }
                if (flag && ehfDomainItem.TryClearForceDomainSyncFlagFromPerimeterConfig(base.ADAdapter) == EhfADResultCode.Failure)
                {
                    num++;
                }
                if (!ehfDomainItem.EventLogAndTryStoreSyncErrors(base.ADAdapter))
                {
                    num++;
                }
            }
            base.HandlePerEntryFailureCounts("Create Domain", domainsTriedToCreate.Count, num, permanentFailureCount, false);
        }