/// <summary>
 /// Tries the get.
 /// </summary>
 /// <param name="anchorType">Type of the anchor.</param>
 /// <param name="registrar">The registrar.</param>
 /// <param name="createIfRequired">if set to <c>true</c> [create if required].</param>
 /// <returns></returns>
 public static bool TryGet(Type anchorType, out ServiceCacheRegistrar registrar, bool createIfRequired)
 {
     if (anchorType == null)
     {
         throw new ArgumentNullException("anchorType");
     }
     _rwLock.EnterUpgradeableReadLock();
     try
     {
         var exists = _items.TryGetValue(anchorType, out registrar);
         if (exists || !createIfRequired)
         {
             return(exists);
         }
         _rwLock.EnterWriteLock();
         try
         {
             if (!_items.TryGetValue(anchorType, out registrar))
             {
                 // create
                 registrar = new ServiceCacheRegistrar(anchorType);
                 _items.Add(anchorType, registrar);
             }
         }
         finally { _rwLock.ExitWriteLock(); }
         return(true);
     }
     finally { _rwLock.ExitUpgradeableReadLock(); }
 }
        static ServiceCache()
        {
            var registrar = ServiceCacheRegistrar.Get(typeof(ServiceCache));

            registrar.Register(Primitives.YesNo);
            registrar.Register(Primitives.Gender);
            registrar.Register(Primitives.Integer);
        }
 /// <summary>
 /// Attaches the registrar.
 /// </summary>
 /// <param name="registrar">The registrar.</param>
 /// <param name="absoluteName">Name of the absolute.</param>
 public void AttachRegistrar(ServiceCacheRegistrar registrar, string absoluteName)
 {
     Registrar    = registrar;
     AbsoluteName = absoluteName;
 }