Beispiel #1
0
        public static void Write <T>(T xmlObject, string path)
        {
            lock (_lock)
            {
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(T));
                MemoryStream  memoryStream  = new MemoryStream();
                XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8)
                {
                    Formatting = Formatting.Indented
                };

                xmlSerializer.Serialize(xmlTextWriter, xmlObject);

                string output             = Encoding.UTF8.GetString(memoryStream.ToArray());
                string _byteOrderMarkUtf8 = Encoding.UTF8.GetString(Encoding.UTF8.GetPreamble());
                if (output.StartsWith(_byteOrderMarkUtf8, StringComparison.Ordinal))
                {
                    output = output.Remove(0, _byteOrderMarkUtf8.Length);
                }

                if (!Directory.Exists(DefaultConfiguration.AppDomain()))
                {
                    Directory.CreateDirectory(DefaultConfiguration.AppDomain());
                }

                File.WriteAllText(path, output);
            }
        }
        public static void Write <T>(T jsonObject, string path)
        {
            lock (_lock)
            {
                string output = JsonConvert.SerializeObject(jsonObject);

                if (!Directory.Exists(DefaultConfiguration.AppDomain()))
                {
                    Directory.CreateDirectory(DefaultConfiguration.AppDomain());
                }

                File.WriteAllText(path, output);
            }
        }
 internal static string FileName() => $"{DefaultConfiguration.AppDomain()}{DefaultConfiguration.LocalizationPathTemplate}.json";