Exemple #1
0
        /// <summary>
        /// Create vendor extended paramters from BitArray
        /// </summary>
        /// <param name="bit_array">BitArray. Input</param>
        /// <param name="cursor">The current bit position to be processed.</param>
        /// <param name="length">Total length of the array</param>
        /// <returns></returns>
        public static ICustom_Parameter DecodeCustomParameter(ref BitArray bit_array, ref int cursor, int length)
        {
            if (cursor >= length)
            {
                return(null);
            }

            int          old_cursor = cursor;
            PARAM_Custom param      = PARAM_Custom.FromBitArray(ref bit_array, ref cursor, length);

            if (param != null)
            {
                string key = param.VendorID + "-" + param.SubType;
                if (vendorExtensionIDTypeHash != null)
                {
                    try
                    {
                        Type       tp  = (Type)vendorExtensionIDTypeHash[key];
                        MethodInfo mis = tp.GetMethod("FromBitArray");

                        if (mis == null)
                        {
                            return(null);
                        }

                        cursor = old_cursor;
                        object[] parameters = new object[] { bit_array, cursor, length };

                        object obj = mis.Invoke(null, parameters);
                        cursor = (int)parameters[1];

                        return((ICustom_Parameter)obj);
                    }
                    catch
                    {
                        return(param);
                    }
                }
                else
                {
                    return(param);
                }
            }
            else
            {
                return(null);
            }
        }
        public static ICustom_Parameter DecodeCustomParameter(
            ref BitArray bit_array,
            ref int cursor,
            int length)
        {
            if (cursor >= length)
            {
                return((ICustom_Parameter)null);
            }
            int          num1        = cursor;
            PARAM_Custom paramCustom = PARAM_Custom.FromBitArray(ref bit_array, ref cursor, length);

            if (paramCustom == null)
            {
                return((ICustom_Parameter)null);
            }
            string str = paramCustom.VendorID.ToString() + "-" + (object)paramCustom.SubType;

            if (CustomParamDecodeFactory.vendorExtensionIDTypeHash != null)
            {
                int num2 = cursor;
                try
                {
                    MethodInfo method = ((Type)CustomParamDecodeFactory.vendorExtensionIDTypeHash[(object)str]).GetMethod("FromBitArray");
                    if (method == null)
                    {
                        return((ICustom_Parameter)null);
                    }
                    cursor = num1;
                    object[] parameters = new object[3]
                    {
                        (object)bit_array,
                        (object)cursor,
                        (object)length
                    };
                    object obj = method.Invoke((object)null, parameters);
                    cursor = (int)parameters[1];
                    return((ICustom_Parameter)obj);
                }
                catch
                {
                    cursor = num2;
                }
            }
            return((ICustom_Parameter)paramCustom);
        }