Example #1
0
        /// <summary>
        ///
        /// </summary>
        public void Initialize()
        {
            // Initialize FlushInterval
            _flushInterval.Initialize();

            try
            {
                if (_implementation == null)
                {
                    throw new DataMapperException("Error instantiating cache controller for cache named '" + _id + "'. Cause: The class for name '" + _implementation + "' could not be found.");
                }

                // Build the CacheController
                Type     type      = TypeUtils.ResolveType(_implementation);
                object[] arguments = new object[0];

                _controller = (ICacheController)Activator.CreateInstance(type, arguments);
            }
            catch (Exception e)
            {
                throw new ConfigurationException("Error instantiating cache controller for cache named '" + _id + ". Cause: " + e.Message, e);
            }

            //------------ configure Controller---------------------
            try
            {
                _controller.Configure(_properties);
            }
            catch (Exception e)
            {
                throw new ConfigurationException("Error configuring controller named '" + _id + "'. Cause: " + e.Message, e);
            }
        }
        public virtual void TestSizeOne()
        {
            ICacheController cc    = GetController();
            IDictionary      props = new HybridDictionary();

            props.Add("CacheSize", "1");
            cc.Configure(props);

            string testKey = "testKey";
            string testVal = "testVal";

            cc[testKey] = testVal;
            Assert.AreEqual(testVal, cc[testKey]);

            string testKey2 = "testKey2";
            string testVal2 = "testVal2";

            cc[testKey2] = testVal2;
            Assert.AreEqual(testVal2, cc[testKey2]);

            Assert.IsNull(cc[testKey]);
        }
Example #3
0
        /// <summary>
        /// 
        /// </summary>
        public void Initialize()
        {
            // Initialize FlushInterval
            _flushInterval.Initialize();

            try
            {
                if (_implementation == null)
                {
                    throw new DataMapperException ("Error instantiating cache controller for cache named '"+_id+"'. Cause: The class for name '"+_implementation+"' could not be found.");
                }

                // Build the CacheController
                Type type = TypeUtils.ResolveType(_implementation);
                object[] arguments = new object[0];

                _controller = (ICacheController)Activator.CreateInstance(type, arguments);
            }
            catch (Exception e)
            {
                throw new ConfigurationException("Error instantiating cache controller for cache named '"+_id+". Cause: " + e.Message, e);
            }

            //------------ configure Controller---------------------
            try
            {
                _controller.Configure(_properties);
            }
            catch (Exception e)
            {
                throw new ConfigurationException ("Error configuring controller named '"+_id+"'. Cause: " + e.Message, e);
            }
        }