Example #1
0
        private static void InsertFormatterInfo(HFType type, string hfName, FormatValueFunc fvf, LengthFunc lf)
        {
            int index = (int)type;

            FormatFuncs[(index)]    = fvf;
            LenFuncs[index]         = lf;
            BinaryHeaderName[index] = Encoding.ASCII.GetBytes(hfName);
        }
Example #2
0
        public T GetSingleField <T>(HFType type) where T : IHeaderField
        {
            if (type == HFType.Undefined || type == HFType.Cookie)
            {
                string msg = string.Format("Cannot get no-single field as single one." +
                                           " Use 'GetUndefinedField()' or 'GetCookieFields()' as needed");
                throw new InvalidOperationException(msg);
            }

            return((T)onlySingleHeaderFields[type]);
        }
Example #3
0
        internal bool TryGetFirst(HFType type, out IHeaderField field)
        {
            foreach (var hf in headerFieldsList)
            {
                if (hf.Type == type)
                {
                    field = hf;
                    return(true);
                }
            }

            field = null;
            return(false);
        }
Example #4
0
 ///<summary>Indicates if at least one field of '<param name="type"/>' type is present in the header</summary>
 ///<param name="type">Type of header field</param>
 public bool Contains(HFType type)
 {
     if (HFType.Undefined == type)
     {
         return(undefinedHfList.Count > 0);
     }
     else if (HFType.Cookie == type)
     {
         return(cookieHfList.Count > 0);
     }
     else
     {
         return(onlySingleHeaderFields.ContainsKey(type));
     }
 }