public void IgnoresCase()
        {
            CaseInsensitiveHashtable st = new CaseInsensitiveHashtable();

            st.Add("key", "value");
            Assert.AreEqual("value", st["KEY"]);
            st["KeY"] = "value2";
            Assert.AreEqual(1, st.Count);
            Assert.AreEqual("value2", st["key"]);

            try
            {
                st.Add("KEY", "value2");
                Assert.Fail();
            }
            catch (ArgumentException)
            { }

            Hashtable ht = new Hashtable();

            ht.Add("key", "value");
            ht.Add("KEY", "value");
            try
            {
                st = new CaseInsensitiveHashtable(ht, CultureInfo.InvariantCulture);
                Assert.Fail();
            }
            catch (ArgumentException)
            { }
        }
        public void ComparePerformance()
        {
            const int runs  = 30000000;
            StopWatch watch = new StopWatch();

            Hashtable ht = CollectionsUtil.CreateCaseInsensitiveHashtable();

            for (int i = 0; i < 1000000; i++)
            {
                ht.Add(Guid.NewGuid().ToString(), "val");                               // gen. higher number of elements results in OOM exception????
            }
            CaseInsensitiveHashtable ciht = new CaseInsensitiveHashtable(ht, CultureInfo.InvariantCulture);

            using (watch.Start("Duration: {0}"))
            {
                for (int i = 0; i < runs; i++)
                {
                    object v = ht["somekey"];
                }
            }

            using (watch.Start("Duration: {0}"))
            {
                for (int i = 0; i < runs; i++)
                {
                    object v = ciht["somekey"];
                }
            }
        }
 public void IsSerializable()
 {
     CaseInsensitiveHashtable storiginal = new CaseInsensitiveHashtable();
     storiginal.Add("key", "value");
     CaseInsensitiveHashtable st = (CaseInsensitiveHashtable)SerializeDeserializeObject(storiginal);
     Assert.AreNotSame(storiginal, st);
     Assert.AreEqual("value", st["KEY"]);
     Assert.AreEqual(1, st.Count);
 }
        public void AcceptsNonStringKeys()
        {
            CaseInsensitiveHashtable st = new CaseInsensitiveHashtable();

            object key = new object();
            st.Add(key, "value");
            Assert.AreEqual(1, st.Count);            
            Assert.AreEqual("value", st[key]);
            Assert.IsNull(st[new object()]);
        }
        public void AcceptsNonStringKeys()
        {
            CaseInsensitiveHashtable st = new CaseInsensitiveHashtable();

            object key = new object();

            st.Add(key, "value");
            Assert.AreEqual(1, st.Count);
            Assert.AreEqual("value", st[key]);
            Assert.IsNull(st[new object()]);
        }
        public void IsSerializable()
        {
            CaseInsensitiveHashtable storiginal = new CaseInsensitiveHashtable();

            storiginal.Add("key", "value");
            CaseInsensitiveHashtable st = (CaseInsensitiveHashtable)SerializeDeserializeObject(storiginal);

            Assert.AreNotSame(storiginal, st);
            Assert.AreEqual("value", st["KEY"]);
            Assert.AreEqual(1, st.Count);
        }
        public void InitializeFromOtherCopiesValues()
        {
            Hashtable ht = new Hashtable();

            ht["key"]  = "value";
            ht["key2"] = "value2";

            CaseInsensitiveHashtable st = new CaseInsensitiveHashtable(ht, CultureInfo.InvariantCulture);

            Assert.AreEqual(2, st.Count);
            ht.Remove("key");
            Assert.AreEqual(1, ht.Count);
            Assert.AreEqual(2, st.Count);
        }
 /// <summary>
 /// Creates a new instance of the
 /// <see cref="Spring.Objects.Factory.Support.DefaultListableObjectFactory"/> class.
 /// </summary>
 /// <param name="caseSensitive">Flag specifying whether to make this object factory case sensitive or not.</param>
 /// <param name="parentFactory">The parent object factory.</param>
 public DefaultListableObjectFactory(bool caseSensitive, IObjectFactory parentFactory)
     : base(caseSensitive, parentFactory)
 {
     if (caseSensitive)
     {
         objectDefinitionMap = new Hashtable();
     }
     else
     {
         objectDefinitionMap = new CaseInsensitiveHashtable(); //CollectionsUtil.CreateCaseInsensitiveHashtable();
     }
 }
Example #9
0
        protected override void OnPreInit( EventArgs e )
#endif
        {
            if (SharedState == null)
            {
                SharedState = new CaseInsensitiveHashtable();
            }
            InitializeCulture();
            InitializeMessageSource();
#if !NET_2_0
            EventHandler handler = (EventHandler) base.Events[EventPreInit];
            if (handler != null)
            {
                handler(this, e);
            }
#else
            base.OnPreInit( e );
#endif
        }
        public void IgnoresCase()
        {
            CaseInsensitiveHashtable st = new CaseInsensitiveHashtable();
            st.Add("key", "value");
            Assert.AreEqual("value", st["KEY"]);
            st["KeY"] = "value2";
            Assert.AreEqual(1, st.Count);
            Assert.AreEqual("value2", st["key"]);

            try
            {
                st.Add("KEY", "value2");
                Assert.Fail();
            }
            catch (ArgumentException)
            { }

            Hashtable ht = new Hashtable();
            ht.Add("key", "value");
            ht.Add("KEY", "value");
            try
            {
                st = new CaseInsensitiveHashtable(ht, CultureInfo.InvariantCulture);
                Assert.Fail();
            }
            catch (ArgumentException)
            { }
        }
        public void ComparePerformance()
        {
            const int runs = 30000000;
            StopWatch watch = new StopWatch();

            Hashtable ht = CollectionsUtil.CreateCaseInsensitiveHashtable();
            for (int i = 0; i < 1000000; i++) ht.Add(Guid.NewGuid().ToString(), "val"); // gen. higher number of elements results in OOM exception????
            CaseInsensitiveHashtable ciht = new CaseInsensitiveHashtable(ht, CultureInfo.InvariantCulture);

            using (watch.Start("Duration: {0}"))
            {
                for (int i = 0; i < runs; i++)
                {
                    object v = ht["somekey"];
                }
            }

            using (watch.Start("Duration: {0}"))
            {
                for (int i = 0; i < runs; i++)
                {
                    object v = ciht["somekey"];
                }
            }
        }
        public void InitializeFromOtherCopiesValues()
        {
            Hashtable ht = new Hashtable();
            ht["key"] = "value";
            ht["key2"] = "value2";

            CaseInsensitiveHashtable st = new CaseInsensitiveHashtable(ht, CultureInfo.InvariantCulture);
            Assert.AreEqual(2, st.Count);
            ht.Remove("key");
            Assert.AreEqual(1, ht.Count);
            Assert.AreEqual(2, st.Count);
        }
Example #13
0
        /// <summary>
        /// Initializes Spring.NET page internals and raises the PreInit event.
        /// </summary>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected override void OnPreInit( EventArgs e )
        {
            if (SharedState == null)
            {
                SharedState = new CaseInsensitiveHashtable();
            }
            InitializeCulture();
            InitializeMessageSource();

            base.OnPreInit( e );
        }
        /// <summary>
        /// Returns a redirect url string that points to the 
        /// <see cref="Spring.Web.Support.Result.TargetPage"/> defined by this
        /// result.
        /// </summary>
        /// <param name="context">
        /// A redirect url string.
        /// </param>
        public virtual string GetRedirectUri( object context )
        {
            string path = GetResolvedTargetPage( context );

            IDictionary resolvedParameters = null;
            if (this.Parameters != null && this.Parameters.Count > 0)
            {
                resolvedParameters = new CaseInsensitiveHashtable();
                foreach (DictionaryEntry entry in this.Parameters)
                {
                    object key = ResolveValueIfNecessary( context, entry.Key.ToString() );
                    object value = ResolveValueIfNecessary( context, entry.Value.ToString() );
                    resolvedParameters[key] = value;
                }
            }

            return BuildUrl( path, resolvedParameters );
        }