Exemplo n.º 1
0
 public static Stream WriteDataToStream <C>(this C obj) where C : class
 {
     try
     {
         return(XmlAction.SaveStream(obj));
     }
     catch (Exception ex)
     {
     }
     return(null);
 }
Exemplo n.º 2
0
 /// <summary> 写入数据到 XML </summary>
 /// <typeparam name="C"> 读取的数据类型 </typeparam>
 /// <param name="obj"> 将要写入的数据</param>
 /// <param name="fullpath"> 写 =入的文件路径 </param>
 /// <returns> 返回为 null 的时候写入成功 </returns>
 public static string WriteDataToXml <C>(this C obj, string fullpath) where C : class
 {
     try
     {
         XmlAction.Save(obj, fullpath);
         return(null);
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
Exemplo n.º 3
0
 /// <summary> 写入数据到XML </summary>
 /// <typeparam name="S"> 写入的数据类型 </typeparam>
 /// <param name="obj"></param>
 /// <param name="fullpath"> 写入的路径 </param>
 /// <returns> 返回为 null 的时候写入成功 </returns>
 public static string WriteStructToXml <S>(this S obj, string fullpath) where S : struct
 {
     try
     {
         XmlAction.Save(obj, fullpath);
         return(null);
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
Exemplo n.º 4
0
 /// <summary> 从XML读取数据 </summary>
 /// <typeparam name="C">  读取的数据类型 </typeparam>
 /// <param name="stream">包含数据的数据流 </param>
 /// <returns> Tpye = C , 返回为null的时候读取失败 </returns>
 public static C ReadDataFromXml <C>(this Stream stream) where C : class
 {
     return(XmlAction.Read(stream, typeof(C)) as C);
 }
Exemplo n.º 5
0
 /// <summary> 从XML读取数据 </summary>
 /// <typeparam name="C"> 读取的数据类型 </typeparam>
 /// /// <param name="FullPath"> 包含数据的文件路径</param>
 /// <returns> Tpye = C , 返回为null的时候读取失败 </returns>
 public static C ReadDataFromXml <C>(this string FullPath) where C : class
 {
     return(XmlAction.Read(FullPath, typeof(C)) as C);
 }
Exemplo n.º 6
0
        /// <summary> 从XML读取数据 ,返回为默认值的时候读取失败 </summary>
        /// <typeparam name="S"> 读取的数据类型 </typeparam>
        /// <param name="FullPath"> 读取的路径 </param>
        /// <returns> 返回为默认值的时候读取失败 </returns>
        public static S ReadDataFromXml <S>(this Stream stream) where S : struct
        {
            var data = XmlAction.Read(stream, typeof(S));

            return(data != null ? (S)data : default(S));
        }
Exemplo n.º 7
0
        /// <summary> 从XML读取数据 </summary>
        /// <typeparam name="S"> 读取的数据类型 </typeparam>
        /// <param name="fileInfo"> 包含数据的文件 FileInfo 信息 </param>
        /// <returns> 返回为默认值的时候读取失败 </returns>
        public static S ReadDataFromXml <S>(this string FullPath) where S : struct
        {
            var data = XmlAction.Read(FullPath, typeof(S));

            return(data != null ? (S)data : default(S));
        }