// Token: 0x06000E60 RID: 3680 RVA: 0x00056750 File Offset: 0x00054950
        private static SharingPolicyCache GetHydratedPolicyFromCacheOrAD(OrganizationId orgId, ADObjectId policyId)
        {
            SharingPolicyCache sharingPolicyCache;

            lock (SharingPolicyCache.cacheSyncLock)
            {
                if (policyId == SharingPolicyCache.DynamicDefaultPolicy)
                {
                    if (SharingPolicyCache.hydratedDefaultCache.TryGetValue(orgId, out sharingPolicyCache))
                    {
                        SharingPolicyCache.Tracer.TraceDebug <ADObjectId, OrganizationId>(0L, "Found Default Sharing Policy {0} in hydratedDefaultCache for Org {1}.", policyId, orgId);
                        return(sharingPolicyCache);
                    }
                }
                else if (SharingPolicyCache.hydratedCache.TryGetValue(policyId.ObjectGuid, out sharingPolicyCache))
                {
                    SharingPolicyCache.Tracer.TraceDebug <ADObjectId, OrganizationId>(0L, "Found Sharing Policy {0} in hydratedCache for Org {1}.", policyId, orgId);
                    return(sharingPolicyCache);
                }
            }
            IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(orgId), 211, "GetHydratedPolicyFromCacheOrAD", "f:\\15.00.1497\\sources\\dev\\MailboxAssistants\\src\\assistants\\SharingPolicy\\SharingPolicyCache.cs");

            tenantOrTopologyConfigurationSession.SessionSettings.IsSharedConfigChecked = true;
            bool flag2 = policyId == SharingPolicyCache.DynamicDefaultPolicy;

            if (flag2)
            {
                policyId = SharingPolicyCache.GetDefaultSharingPolicyId(tenantOrTopologyConfigurationSession);
                if (policyId == null)
                {
                    return(null);
                }
            }
            SharingPolicy sharingPolicy = tenantOrTopologyConfigurationSession.Read <SharingPolicy>(policyId);

            if (sharingPolicy == null)
            {
                SharingPolicyCache.Tracer.TraceWarning <ADObjectId, bool>(0L, "Unable to find SharingPolicy {0} in the AD. PolicyId is default:{1}", policyId, flag2);
                sharingPolicyCache = null;
            }
            else
            {
                sharingPolicyCache = new SharingPolicyCache(sharingPolicy, false);
            }
            lock (SharingPolicyCache.cacheSyncLock)
            {
                SharingPolicyCache.Tracer.TraceDebug <ADObjectId>(0L, "Add the Sharing Policy {0} to cache.", policyId);
                SharingPolicyCache.hydratedCache[policyId.ObjectGuid] = sharingPolicyCache;
                if (sharingPolicyCache != null && flag2)
                {
                    SharingPolicyCache.Tracer.TraceDebug <ADObjectId, OrganizationId>(0L, "Add Default Sharing Policy {0} of Org {1} to hydrated cache ", policyId, orgId);
                    SharingPolicyCache.hydratedDefaultCache[orgId] = sharingPolicyCache;
                }
            }
            return(sharingPolicyCache);
        }
        // Token: 0x06000E61 RID: 3681 RVA: 0x000568D8 File Offset: 0x00054AD8
        private static SharingPolicyCache GetDehydratedPolicyFromCacheOrAD(OrganizationId orgId, ADObjectId policyId)
        {
            SharingPolicyCache sharingPolicyCache;

            if (policyId != SharingPolicyCache.DynamicDefaultPolicy)
            {
                lock (SharingPolicyCache.cacheSyncLock)
                {
                    if (SharingPolicyCache.dehydratedDefaultCache.TryGetValue(policyId.ObjectGuid, out sharingPolicyCache))
                    {
                        SharingPolicyCache.Tracer.TraceDebug <ADObjectId>(0L, "Found Sharing Policy {0} in dehydrated cache.", policyId);
                        return(sharingPolicyCache);
                    }
                }
            }
            SharedConfiguration   sharedConfiguration = SharedConfiguration.GetSharedConfiguration(orgId);
            IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, sharedConfiguration.GetSharedConfigurationSessionSettings(), 282, "GetDehydratedPolicyFromCacheOrAD", "f:\\15.00.1497\\sources\\dev\\MailboxAssistants\\src\\assistants\\SharingPolicy\\SharingPolicyCache.cs");

            tenantOrTopologyConfigurationSession.SessionSettings.IsSharedConfigChecked = true;
            bool flag2 = policyId == SharingPolicyCache.DynamicDefaultPolicy;

            if (flag2)
            {
                SharingPolicyCache.Tracer.TraceDebug <OrganizationId>(0L, "Find Default Policy Id for Org {0} ", orgId);
                policyId = SharingPolicyCache.GetDefaultSharingPolicyId(tenantOrTopologyConfigurationSession);
                if (policyId == null)
                {
                    return(null);
                }
                lock (SharingPolicyCache.cacheSyncLock)
                {
                    if (SharingPolicyCache.dehydratedDefaultCache.TryGetValue(policyId.ObjectGuid, out sharingPolicyCache))
                    {
                        SharingPolicyCache.Tracer.TraceDebug <ADObjectId>(0L, "Found Sharing Policy {0} in dehydrated cache.", policyId);
                        return(sharingPolicyCache);
                    }
                }
            }
            SharingPolicy sharingPolicy = tenantOrTopologyConfigurationSession.Read <SharingPolicy>(policyId);

            if (sharingPolicy == null)
            {
                SharingPolicyCache.Tracer.TraceError <ADObjectId, bool>(0L, "Unable to find SharingPolicy {0} in the AD. PolicyId is default:{1}", policyId, flag2);
                return(null);
            }
            sharingPolicyCache = new SharingPolicyCache(sharingPolicy, true);
            lock (SharingPolicyCache.cacheSyncLock)
            {
                SharingPolicyCache.dehydratedDefaultCache[policyId.ObjectGuid] = sharingPolicyCache;
            }
            return(sharingPolicyCache);
        }