Exemplo n.º 1
0
 public static Stream WriteDataToStream <T>(this T obj)
 {
     try
     {
         return(XmlAction.SaveStream(obj));
     }
     catch { }
     return(null);
 }
Exemplo n.º 2
0
        /// <summary> 写入数据到 XML </summary>
        /// <typeparam name="T"> 读取的数据类型 </typeparam>
        /// <param name="obj">      将要写入的数据 </param>
        /// <param name="fullpath"> 写 =入的文件路径 </param>
        /// <returns> 返回为 null 的时候写入成功 </returns>
        public static string WriteToXml <T>(this T obj, string fullpath)
        {
            try
            {
                FileHelper.CreatFile(fullpath);

                if (XmlAction.Save(obj, fullpath))
                {
                    return(null);
                }
                else
                {
                    return("false");
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Exemplo n.º 3
0
 /// <summary> 从XML读取数据 </summary>
 /// <typeparam name="T"> 读取的数据类型 </typeparam>
 /// ///
 /// <param name="FullPath"> 包含数据的文件路径 </param>
 /// <returns> Tpye = C , 返回为null的时候读取失败 </returns>
 public static T ReadFromXml <T>(this string FullPath)
 {
     return(XmlAction.Read <T>(FullPath));
 }
Exemplo n.º 4
0
 /// <summary> 从XML读取数据 </summary>
 /// <typeparam name="T"> 读取的数据类型 </typeparam>
 /// <param name="stream"> 包含数据的数据流 </param>
 /// <returns> Tpye = C , 返回为null的时候读取失败 </returns>
 public static T ReadFromStream <T>(this Stream stream)
 {
     return(XmlAction.Read <T>(stream));
 }
Exemplo n.º 5
0
 public static object ReadFromXml(this Stream stream, Type type)
 {
     return(XmlAction.Read(stream, type));
 }