Beispiel #1
0
        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);
        }
Beispiel #2
0
        private HeaderValue FindOnly(string name)
        {
            HeaderValue result;
            long        id = HeaderType.GetNameCode(name);

            mValues.TryGetValue(id, out result);
            return(result);
        }
Beispiel #3
0
 private static void Add(String name)
 {
     lock (mHeaderTypes)
     {
         HeaderType type = new HeaderType(name);
         mHeaderTypes[type.ID] = type;
     }
 }
Beispiel #4
0
 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);
     }
 }
Beispiel #5
0
        private HeaderValue Find(string name)
        {
            HeaderType  type = HeaderTypeFactory.Find(name);
            HeaderValue value;

            if (mValues.TryGetValue(type.ID, out value))
            {
                return(value);
            }
            value            = new HeaderValue(type, null);
            mValues[type.ID] = value;
            return(value);
        }
Beispiel #6
0
 public HeaderValue(HeaderType type, string value)
 {
     Type  = type;
     Value = value;
 }
Beispiel #7
0
        public void Remove(string name)
        {
            long id = HeaderType.GetNameCode(name);

            mValues.Remove(id);
        }
Beispiel #8
0
        public static void Write(string name, PipeStream stream)
        {
            HeaderType type = Find(name);

            stream.Write(type.Bytes, 0, type.Bytes.Length);
        }