Example #1
0
        /// <summary>
        /// 从xml文件反序列化为对象
        /// </summary>
        /// <example>
        /// <para>下面的代码演示了FromFile的用法</para>
        /// <code>
        /// <![CDATA[
        ///
        ///	//使用站点相对路径
        ///	usinessTypeManager btm = BusinessTypeManager.FromFile("/Map/Cbgl/Workflow/Demo1_HTML.xml");
        ///
        /// ]]>
        /// </code>
        /// </example>
        /// <param name="file">xml文件</param>
        /// <returns>BusinessTypeManager类实例</returns>
        public static BusinessTypeManager FromFile(string file)
        {
            if (string.IsNullOrEmpty(file))
            {
                throw new ArgumentNullException("file");
            }

            string fileName;

            HttpContext context = HttpContext.Current;

            if (context == null)
            {
                string runtimeFolder = AppDomain.CurrentDomain.BaseDirectory;
                fileName = Path.Combine(runtimeFolder, file);
            }
            else
            {
                fileName = context.Server.MapPath(file);
            }

            string              xml = File.ReadAllText(fileName, Encoding.Default);
            BusinessType        bt  = xml.FromXml <BusinessType>();
            BusinessTypeManager btm = new BusinessTypeManager();

            btm.BusinessType = bt;
            return(btm);
        }
Example #2
0
        /// <summary>
        /// 从xml字符串反序列化为对象
        /// </summary>
        /// <example>
        /// <para>下面的代码演示了FromXML的用法</para>
        /// <code>
        /// <![CDATA[
        ///
        ///	string xml = "<BusinessType BusinessGUID="" ...>...";
        ///	usinessTypeManager btm = BusinessTypeManager.FromXml(xml);
        ///
        /// ]]>
        /// </code>
        /// </example>
        /// <param name="xml">xml字符串</param>
        /// <returns>BusinessTypeManager类实例</returns>
        public static BusinessTypeManager FromXml(string xml)
        {
            if (string.IsNullOrEmpty(xml))
            {
                throw new ArgumentNullException("xml");
            }
            BusinessType        bt  = xml.FromXml <BusinessType>();
            BusinessTypeManager btm = new BusinessTypeManager();

            btm.BusinessType = bt;
            return(btm);
        }