Example #1
0
        /// <summary>
        /// Remove the cache reference from the store.
        /// </summary>
        /// <param name="cache">
        /// The cache reference.
        /// </param>
        /// <returns>
        /// Whether the item was found.
        /// </returns>
        public virtual bool ReleaseCache(INamedCache cache)
        {
            IDictionary mapByName  = m_mapByName;
            string      sCacheName = cache.CacheName;
            bool        fFound     = false;

            object oHolder = mapByName[sCacheName];

            if (oHolder == cache)
            {
                // remove the mapping
                mapByName.Remove(sCacheName);
                fFound = true;
            }
            else if (oHolder is PrincipalScopedReference)
            {
                PrincipalScopedReference scopedRef = (PrincipalScopedReference)
                                                     oHolder;

                if (scopedRef.Get() == cache)
                {
                    scopedRef.Remove();
                    fFound = true;
                }
            }
            return(fFound);
        }
Example #2
0
        /// <summary>
        /// Store a service reference.
        /// </summary>
        /// <remarks>
        /// Service name and type are passed in rather than using
        /// service.Info because the service may not have been configured
        /// and started yet, so the Info may not be safely available.
        /// </remarks>
        /// <param name="service">
        /// The referenced service.
        /// </param>
        /// <param name="sName">
        /// The service name.
        /// </param>
        /// <param name="serviceType">
        /// The service type.
        /// </param>
        public virtual void PutService(IService service, string sName,
                                       ServiceType serviceType)
        {
            IDictionary mapByName = m_mapByName;

            if (IsRemoteServiceType(serviceType) && OperationalContext.IsPrincipalScopingEnabled)
            {
                PrincipalScopedReference scopedRef =
                    (PrincipalScopedReference)mapByName[sName];
                if (scopedRef == null)
                {
                    scopedRef        = new PrincipalScopedReference();
                    mapByName[sName] = scopedRef;
                }
                scopedRef.Set(service);
            }
            else
            {
                mapByName[sName] = service;
            }
        }
Example #3
0
        /// <summary>
        /// Store a cache reference.
        /// </summary>
        /// <param name="cache">
        /// The cache reference.
        /// </param>
        public virtual void PutCache(INamedCache cache)
        {
            IDictionary   mapByName    = m_mapByName;
            string        sCacheName   = cache.CacheName;
            ICacheService cacheService = cache.CacheService;

            if (cacheService != null && IsRemoteServiceType(
                    cacheService.Info.ServiceType) && OperationalContext.IsPrincipalScopingEnabled)
            {
                PrincipalScopedReference scopedRef =
                    (PrincipalScopedReference)mapByName[sCacheName];
                if (scopedRef == null)
                {
                    scopedRef             = new PrincipalScopedReference();
                    mapByName[sCacheName] = scopedRef;
                }
                scopedRef.Set(cache);
            }
            else
            {
                mapByName[sCacheName] = cache;
            }
        }