Example #1
0
 static private void Save(AntiDupl.NET.Strings strings)
 {
     try
     {
         TextWriter    writer        = new StreamWriter(GetPath(Path, strings.Name, Extension));
         XmlSerializer xmlSerializer = new XmlSerializer(typeof(AntiDupl.NET.Strings));
         xmlSerializer.Serialize(writer, strings);
         writer.Close();
     }
     catch
     {
     }
 }
Example #2
0
            static public void Initialize()
            {
                m_strings.Clear();

                m_strings.Add(StringsDefaultEnglish.Get());
                m_strings.Add(StringsDefaultRussian.Get());

                DirectoryInfo directoryInfo = new DirectoryInfo(Path);

                if (directoryInfo.Exists)
                {
                    FileInfo[] fileInfos = directoryInfo.GetFiles(Filter, SearchOption.TopDirectoryOnly);
                    for (int i = 0; i < fileInfos.Length; i++)
                    {
                        AntiDupl.NET.Strings strings = Load(fileInfos[i].FullName);
                        if (strings != null)
                        {
                            string name = System.IO.Path.GetFileNameWithoutExtension(fileInfos[i].FullName);
                            if (name.CompareTo(StringsDefaultRussian.Get().Name) != 0 &&
                                name.CompareTo(StringsDefaultEnglish.Get().Name) != 0)
                            {
                                strings.Name = name;
                                m_strings.Add(strings);
                            }
                        }
                    }
                }

                try
                {
                    CreateIfNotExists(Path);
                    Save(StringsDefaultEnglish.Get());
                    Save(StringsDefaultRussian.Get());
                }
                catch (Exception)
                {
                }
            }
Example #3
0
            static private AntiDupl.NET.Strings Load(string path)
            {
                FileInfo fileInfo = new FileInfo(path);

                if (fileInfo.Exists)
                {
                    try
                    {
                        XmlSerializer        xmlSerializer = new XmlSerializer(typeof(AntiDupl.NET.Strings));
                        FileStream           fileStream    = new FileStream(path, FileMode.Open, FileAccess.Read);
                        AntiDupl.NET.Strings strings       = (AntiDupl.NET.Strings)xmlSerializer.Deserialize(fileStream);
                        fileStream.Close();
                        return(strings);
                    }
                    catch
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }