Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- // тестовый пример по десериализации через ExtendedXmlSerializer
- static void Main()
- {
- string executableLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
- string path = Path.Combine(executableLocation, "test.xml");
- using var fs = new FileStream(path, FileMode.Open);
- IExtendedXmlSerializer extendedXmlSerializer = new ConfigurationContainer()
- .UseAutoFormatting()
- .UseOptimizedNamespaces()
- .EnableImplicitTyping(typeof(CarCollection))
- .Create();
- ;
- XmlSerializer standartSerializer = new XmlSerializer(typeof(CarCollection));
- // стандартный сериализатор работает, расширенный нет
- var cars1 = standartSerializer.Deserialize(fs);
- fs.Seek(0, SeekOrigin.Begin);
- var cars2 = extendedXmlSerializer.Deserialize<CarCollection>(fs);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment