static XElement SerializeVisualizer(MashupVisualizer visualizer)
        {
            var document   = new XDocument();
            var serializer = new XmlSerializer(visualizer.GetType());

            using (var writer = document.CreateWriter())
            {
                serializer.Serialize(writer, visualizer);
            }
            document.Root.AddFirst(new XElement("VisualizerTypeName", visualizer.VisualizerType.FullName));
            return(document.Root);
        }
        static void DeserializeVisualizer(XElement root, MashupVisualizer visualizer)
        {
            var visualizerTypeName = root.Element("VisualizerTypeName").Value;

            if (visualizerTypeName == visualizer.VisualizerType.FullName)
            {
                var visualizerType     = visualizer.GetType();
                var visualizerProperty = visualizerType.GetProperty(nameof(MashupVisualizer <TableLayoutPanelVisualizer> .Visualizer));
                if (visualizerProperty == null)
                {
                    throw new InvalidOperationException("Incompatible mashup visualizer object.");
                }

                var serializer = new XmlSerializer(visualizerType);
                using (var reader = root.CreateReader())
                {
                    var mashupSettings     = (MashupVisualizer)serializer.Deserialize(reader);
                    var visualizerSettings = visualizerProperty.GetValue(mashupSettings);
                    visualizerProperty.SetValue(visualizer, visualizerSettings);
                }
            }
        }