public static HeaderType Find(string name) { HeaderType type; long id = HeaderType.GetNameCode(name); if (mHeaderTypes.TryGetValue(id, out type)) { return(type); } HeaderType[] items; lock (mHeaderTypes) { if (mHeaderTypes.TryGetValue(id, out type)) { return(type); } items = mHeaderTypes.Values.ToArray(); foreach (var item in items) { if (item.Compare(name)) { type = item; } } } if (type == null) { type = new HeaderType(name); } Add(name, type); return(type); }
private HeaderValue FindOnly(string name) { HeaderValue result; long id = HeaderType.GetNameCode(name); mValues.TryGetValue(id, out result); return(result); }
private static void Add(string name, HeaderType type) { if (mCount < 5000) { lock (mHeaderTypes) { long id = HeaderType.GetNameCode(name); mHeaderTypes[id] = type; } System.Threading.Interlocked.Increment(ref mCount); } }
public static HeaderType Find(string name) { HeaderType type; long id = HeaderType.GetNameCode(name); if (mHeaderTypes.TryGetValue(id, out type)) { return(type); } foreach (var item in mHeaderTypes.Values) { if (item.Compare(name)) { Add(name, item); return(item); } } type = new HeaderType(name); Add(name, type); return(type); }
public void Remove(string name) { long id = HeaderType.GetNameCode(name); mValues.Remove(id); }