Пример #1
0
 /// <summary>
 /// Gets or sets the value associated with the specified key.
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public TValue this[TKey key]
 {
     get
     {
         if (map.ContainsKey(key))
         {
             return(map.Get(key));
         }
         throw new KeyNotFoundException();
     }
     set { map.Put(key, value); }
 }
Пример #2
0
 private static ConcurrentHashMap<Object, Object> map5()
 {
     ConcurrentHashMap<Object, Object> map = new ConcurrentHashMap<Object, Object>(5);
     Assert.IsTrue(map.IsEmpty());
     map.Put(one, "A");
     map.Put(two, "B");
     map.Put(three, "C");
     map.Put(four, "D");
     map.Put(five, "E");
     Assert.IsFalse(map.IsEmpty());
     Assert.AreEqual(5, map.Size());
     return map;
 }
Пример #3
0
 /// <summary>Registers a scheme.</summary>
 /// <remarks>
 /// Registers a scheme.
 /// The scheme can later be retrieved by its name
 /// using
 /// <see cref="GetScheme(string)">getScheme</see>
 /// or
 /// <see cref="Get(string)">get</see>
 /// .
 /// </remarks>
 /// <param name="sch">the scheme to register</param>
 /// <returns>
 /// the scheme previously registered with that name, or
 /// <code>null</code> if none was registered
 /// </returns>
 public Apache.Http.Conn.Scheme.Scheme Register(Apache.Http.Conn.Scheme.Scheme sch
                                                )
 {
     Args.NotNull(sch, "Scheme");
     Apache.Http.Conn.Scheme.Scheme old = registeredSchemes.Put(sch.GetName(), sch);
     return(old);
 }
Пример #4
0
        public static EnumInfo GetEnumInfo(Type enumType)
        {
            var info = enumInfo.Get(enumType);

            if (info == null)
            {
                var infoField = enumType.JavaGetDeclaredField(EnumInfoFieldName);
                info = (EnumInfo)infoField.Get(null);
                enumInfo.Put(enumType, info);
            }

            return(info);
        }
 private void LoadPreviouslyStoredCookies(Database db)
 {
     try
     {
         IDictionary <string, object> cookiesDoc = db.GetExistingLocalDocument(CookieLocalDocName
                                                                               );
         if (cookiesDoc == null)
         {
             return;
         }
         foreach (string name in cookiesDoc.Keys)
         {
             // ignore special couchbase lite fields like _id and _rev
             if (name.StartsWith("_"))
             {
                 continue;
             }
             string encodedCookie = (string)cookiesDoc.Get(name);
             if (encodedCookie == null)
             {
                 continue;
             }
             Apache.Http.Cookie.Cookie decodedCookie = DecodeCookie(encodedCookie);
             if (decodedCookie == null)
             {
                 continue;
             }
             if (!decodedCookie.IsExpired(new DateTime()))
             {
                 cookies.Put(name, decodedCookie);
             }
         }
     }
     catch (Exception e)
     {
         Log.E(Log.TagSync, "Exception loading previously stored cookies", e);
     }
 }
Пример #6
0
        internal static EventInfo[] GetEvents(Type definingType, Type declaringType)
        {
            var result = loadedEvents.Get(declaringType);

            if (result != null)
            {
                return(result);
            }

            // Not found, build it
            result = BuildEvents(definingType, declaringType);

            // Store in loaded map
            loadedEvents.Put(declaringType, result);

            return(result);
        }
Пример #7
0
 static Log()
 {
     // default "catch-all" tag
     enabledTags = new ConcurrentHashMap <string, int>();
     enabledTags.Put(Log.Tag, Warn);
     enabledTags.Put(Log.TagSync, Warn);
     enabledTags.Put(Log.TagRemoteRequest, Warn);
     enabledTags.Put(Log.TagView, Warn);
     enabledTags.Put(Log.TagQuery, Warn);
     enabledTags.Put(Log.TagChangeTracker, Warn);
     enabledTags.Put(Log.TagRouter, Warn);
     enabledTags.Put(Log.TagDatabase, Warn);
     enabledTags.Put(Log.TagListener, Warn);
     enabledTags.Put(Log.TagMultiStreamWriter, Warn);
     enabledTags.Put(Log.TagBlobStore, Warn);
 }
Пример #8
0
 /// <summary>Enable logging for a particular tag / loglevel combo</summary>
 /// <param name="tag">
 /// Used to identify the source of a log message.  It usually identifies
 /// the class or activity where the log call occurs.
 /// </param>
 /// <param name="logLevel">
 /// The loglevel to enable.  Anything matching this loglevel
 /// or having a more urgent loglevel will be emitted.  Eg, Log.VERBOSE.
 /// </param>
 public static void EnableLogging(string tag, int logLevel)
 {
     enabledTags.Put(tag, logLevel);
 }
Пример #9
0
        public void TestSetValueWriteThrough()
        {
            ConcurrentHashMap<Object, Object> map = new ConcurrentHashMap<Object, Object>(2, 5.0f, 1);
            Assert.IsTrue(map.IsEmpty());
            for (int i = 0; i < 20; i++)
            {
                map.Put(i, i);
            }
            Assert.IsFalse(map.IsEmpty());
            Entry<Object, Object> entry1 = map.EntrySet().Iterator().Next();

            // assert that entry1 is not 16
            Assert.IsTrue(!entry1.Key.Equals(16), "entry is 16, test not valid");

            // remove 16 (a different key) from map
            // which just happens to cause entry1 to be cloned in map
            map.Remove(16);

            entry1.Value = "XYZ";

            Assert.IsTrue(map.ContainsValue("XYZ"));
        }
Пример #10
0
 public void TestRemove3()
 {
     try
     {
         ConcurrentHashMap<Object, Object> c = new ConcurrentHashMap<Object, Object>(5);
         c.Put("sadsdf", "asdads");
         Assert.IsFalse(c.Remove("sadsdf", null));
     }
     catch(NullReferenceException)
     {
         Assert.Fail();
     }
 }
Пример #11
0
 public void TestRemove2_NullReferenceException()
 {
     try
     {
         ConcurrentHashMap<Object, Object> c = new ConcurrentHashMap<Object, Object>(5);
         c.Put("sadsdf", "asdads");
         c.Remove(null, "whatever");
         ShouldThrow();
     }
     catch(NullReferenceException)
     {
     }
 }
Пример #12
0
 public void TestPut2NullReferenceException()
 {
     try
     {
         ConcurrentHashMap<Object, Object> c = new ConcurrentHashMap<Object, Object>(5);
         c.Put("whatever", null);
         ShouldThrow();
     }
     catch(NullReferenceException)
     {
     }
 }
 static Log()
 {
     // default "catch-all" tag
     enabledTags = new ConcurrentHashMap<string, int>();
     enabledTags.Put(Log.Tag, Warn);
     enabledTags.Put(Log.TagSync, Warn);
     enabledTags.Put(Log.TagRemoteRequest, Warn);
     enabledTags.Put(Log.TagView, Warn);
     enabledTags.Put(Log.TagQuery, Warn);
     enabledTags.Put(Log.TagChangeTracker, Warn);
     enabledTags.Put(Log.TagRouter, Warn);
     enabledTags.Put(Log.TagDatabase, Warn);
     enabledTags.Put(Log.TagListener, Warn);
     enabledTags.Put(Log.TagMultiStreamWriter, Warn);
     enabledTags.Put(Log.TagBlobStore, Warn);
 }
 public virtual void SetCredentials(AuthScope authscope, Credentials credentials)
 {
     Args.NotNull(authscope, "Authentication scope");
     credMap.Put(authscope, credentials);
 }
Пример #15
0
 /// <summary>
 /// Sets an attribute.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="value"></param>
 /// <param name="upsert"></param>
 /// <returns></returns>
 public bool SetAttribute(string name, object value, bool upsert = true)
 {
     return(attributes.Put(name, value, upsert));
 }