예제 #1
0
        public static ICustom_Parameter DecodeXmlNodeToCustomParameter(XmlNode node)
        {
            string[] strArray = node.Name.Split(':');
            string   str      = "PARAM_" + strArray[strArray.Length - 1];

            if (str == "PARAM_Custom")
            {
                return((ICustom_Parameter)PARAM_Custom.FromXmlNode(node));
            }
            if (CustomParamDecodeFactory.vendorExtensionNameTypeHash != null)
            {
                try
                {
                    Type type = (Type)CustomParamDecodeFactory.vendorExtensionNameTypeHash[(object)str];
                    if (type != null)
                    {
                        MethodInfo method = type.GetMethod("FromXmlNode");
                        if (method == null)
                        {
                            return((ICustom_Parameter)null);
                        }
                        object[] parameters = new object[1]
                        {
                            (object)node
                        };
                        return((ICustom_Parameter)method.Invoke((object)null, parameters));
                    }
                }
                catch
                {
                }
            }
            return((ICustom_Parameter)null);
        }
예제 #2
0
        /// <summary>
        /// Decode a general Xml node to vendor extended parameters.
        /// </summary>
        /// <param name="node">Xml node to be decoded.</param>
        /// <returns>Custom Parameter</returns>
        public static ICustom_Parameter DecodeXmlNodeToCustomParameter(XmlNode node)
        {
            // Our hash is not namespace aware.
            string[] temp      = node.Name.Split(new char[] { ':' });
            string   type_name = "PARAM_" + temp[temp.Length - 1];

            if (type_name == "PARAM_Custom")
            {
                return((ICustom_Parameter)PARAM_Custom.FromXmlNode(node));
            }
            else if (null != vendorExtensionNameTypeHash)
            {
                try
                {
                    Type tp = (Type)vendorExtensionNameTypeHash[type_name];
                    if (tp != null)
                    {
                        MethodInfo mis = tp.GetMethod("FromXmlNode");
                        if (mis == null)
                        {
                            return(null);
                        }

                        object[] parameters = new object[] { node };
                        object   obj        = mis.Invoke(null, parameters);

                        return((ICustom_Parameter)obj);
                    }
                }
                catch { }
            }

            return(null);
        }