Пример #1
0
        public static void SaveToFile(KPTranslation kpTrl, string strFileName,
                                      IXmlSerializerEx xs)
        {
            if (xs == null)
            {
                throw new ArgumentNullException("xs");
            }

            FileStream fs = new FileStream(strFileName, FileMode.Create,
                                           FileAccess.Write, FileShare.None);

#if !KeePassLibSD
            GZipStream gz = new GZipStream(fs, CompressionMode.Compress);
#else
            GZipOutputStream gz = new GZipOutputStream(fs);
#endif

            XmlWriterSettings xws = new XmlWriterSettings();
            xws.CheckCharacters = true;
            xws.Encoding        = StrUtil.Utf8;
            xws.Indent          = true;
            xws.IndentChars     = "\t";

            XmlWriter xw = XmlWriter.Create(gz, xws);

            xs.Serialize(xw, kpTrl);

            xw.Close();
            gz.Close();
            fs.Close();
        }
Пример #2
0
        public static void Save(KPTranslation kpTrl, Stream sOut,
                                IXmlSerializerEx xs)
        {
            if (xs == null)
            {
                throw new ArgumentNullException("xs");
            }

#if !KeePassLibSD
            GZipStream gz = new GZipStream(sOut, CompressionMode.Compress);
#else
            GZipOutputStream gz = new GZipOutputStream(sOut);
#endif

            XmlWriterSettings xws = new XmlWriterSettings();
            xws.CheckCharacters = true;
            xws.Encoding        = StrUtil.Utf8;
            xws.Indent          = true;
            xws.IndentChars     = "\t";

            XmlWriter xw = XmlWriter.Create(gz, xws);

            xs.Serialize(xw, kpTrl);

            xw.Close();
            gz.Close();
            sOut.Close();
        }
Пример #3
0
        public static KPTranslation Load(Stream s, IXmlSerializerEx xs)
        {
            if (xs == null)
            {
                throw new ArgumentNullException("xs");
            }

            KPTranslation kpTrl = null;

#if !KeePassLibSD
            using (GZipStream gz = new GZipStream(s, CompressionMode.Decompress))
#else
            using (GZipInputStream gz = new GZipInputStream(s))
#endif
            {
                kpTrl = (xs.Deserialize(gz) as KPTranslation);
            }

#if KeePassUWP
            s.Dispose();
#else
            s.Close();
#endif

            return(kpTrl);
        }
Пример #4
0
        public static void Save(KPTranslation kpTrl, Stream sOut,
                                IXmlSerializerEx xs)
        {
            if (xs == null)
            {
                throw new ArgumentNullException("xs");
            }

#if !KeePassLibSD
            using (GZipStream gz = new GZipStream(sOut, CompressionMode.Compress))
#else
            using (GZipOutputStream gz = new GZipOutputStream(sOut))
#endif
            {
                using (XmlWriter xw = XmlUtilEx.CreateXmlWriter(gz))
                {
                    xs.Serialize(xw, kpTrl);
                }
            }

#if KeePassUWP
            sOut.Dispose();
#else
            sOut.Close();
#endif
        }
Пример #5
0
 public static void Save(KPTranslation kpTrl, string strFileName,
                         IXmlSerializerEx xs)
 {
     using (FileStream fs = new FileStream(strFileName, FileMode.Create,
                                           FileAccess.Write, FileShare.None))
     {
         Save(kpTrl, fs, xs);
     }
 }
Пример #6
0
        public static KPTranslation Load(string strFile, IXmlSerializerEx xs)
        {
            KPTranslation kpTrl = null;

            using (FileStream fs = new FileStream(strFile, FileMode.Open,
                                                  FileAccess.Read, FileShare.Read))
            {
                kpTrl = Load(fs, xs);
            }

            return(kpTrl);
        }
Пример #7
0
        public static KPTranslation LoadFromFile(string strFile,
                                                 IXmlSerializerEx xs)
        {
            if (xs == null)
            {
                throw new ArgumentNullException("xs");
            }

            FileStream fs = new FileStream(strFile, FileMode.Open,
                                           FileAccess.Read, FileShare.Read);

#if !KeePassLibSD
            GZipStream gz = new GZipStream(fs, CompressionMode.Decompress);
#else
            GZipInputStream gz = new GZipInputStream(fs);
#endif

            KPTranslation kpTrl = (xs.Deserialize(gz) as KPTranslation);

            gz.Close();
            fs.Close();
            return(kpTrl);
        }
Пример #8
0
        public static void SaveToFile(KPTranslation kpTrl, string strFileName,
            IXmlSerializerEx xs)
        {
            if(xs == null) throw new ArgumentNullException("xs");

            FileStream fs = new FileStream(strFileName, FileMode.Create,
                FileAccess.Write, FileShare.None);

            #if !KeePassLibSD
            GZipStream gz = new GZipStream(fs, CompressionMode.Compress);
            #else
            GZipOutputStream gz = new GZipOutputStream(fs);
            #endif

            XmlWriterSettings xws = new XmlWriterSettings();
            xws.CheckCharacters = true;
            xws.Encoding = StrUtil.Utf8;
            xws.Indent = true;
            xws.IndentChars = "\t";

            XmlWriter xw = XmlWriter.Create(gz, xws);

            xs.Serialize(xw, kpTrl);

            xw.Close();
            gz.Close();
            fs.Close();
        }
Пример #9
0
        public static KPTranslation LoadFromFile(string strFile,
            IXmlSerializerEx xs)
        {
            if(xs == null) throw new ArgumentNullException("xs");

            FileStream fs = new FileStream(strFile, FileMode.Open,
                FileAccess.Read, FileShare.Read);

            #if !KeePassLibSD
            GZipStream gz = new GZipStream(fs, CompressionMode.Decompress);
            #else
            GZipInputStream gz = new GZipInputStream(fs);
            #endif

            KPTranslation kpTrl = (xs.Deserialize(gz) as KPTranslation);

            gz.Close();
            fs.Close();
            return kpTrl;
        }
Пример #10
0
        public static void Save(KPTranslation kpTrl, Stream sOut,
            IXmlSerializerEx xs)
        {
            if(xs == null) throw new ArgumentNullException("xs");

            #if !KeePassLibSD
            GZipStream gz = new GZipStream(sOut, CompressionMode.Compress);
            #else
            GZipOutputStream gz = new GZipOutputStream(sOut);
            #endif

            XmlWriterSettings xws = new XmlWriterSettings();
            xws.CheckCharacters = true;
            xws.Encoding = StrUtil.Utf8;
            xws.Indent = true;
            xws.IndentChars = "\t";

            XmlWriter xw = XmlWriter.Create(gz, xws);

            xs.Serialize(xw, kpTrl);

            xw.Close();
            gz.Close();
            sOut.Close();
        }
Пример #11
0
 public static void Save(KPTranslation kpTrl, string strFileName,
     IXmlSerializerEx xs)
 {
     using(FileStream fs = new FileStream(strFileName, FileMode.Create,
         FileAccess.Write, FileShare.None))
     {
         Save(kpTrl, fs, xs);
     }
 }
Пример #12
0
        public static KPTranslation Load(Stream s, IXmlSerializerEx xs)
        {
            if(xs == null) throw new ArgumentNullException("xs");

            #if !KeePassLibSD
            GZipStream gz = new GZipStream(s, CompressionMode.Decompress);
            #else
            GZipInputStream gz = new GZipInputStream(s);
            #endif

            KPTranslation kpTrl = (xs.Deserialize(gz) as KPTranslation);

            gz.Close();
            s.Close();
            return kpTrl;
        }
Пример #13
0
        public static KPTranslation Load(string strFile, IXmlSerializerEx xs)
        {
            KPTranslation kpTrl = null;

            using(FileStream fs = new FileStream(strFile, FileMode.Open,
                FileAccess.Read, FileShare.Read))
            {
                kpTrl = Load(fs, xs);
            }

            return kpTrl;
        }