public static void WriteToXmlFile(DynamicFormModel dynamicFormModel, string path)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(DynamicFormModel));

            using (TextWriter writer = File.CreateText(path))
                serializer.Serialize(writer, dynamicFormModel);
        }
        public static DynamicFormModel ReadFromXmlFile(string path)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(DynamicFormModel));

            using (StreamReader reader = File.OpenText(path))
            {
                DynamicFormModel dynamicFormModel = (DynamicFormModel)serializer.Deserialize(reader);
                return(dynamicFormModel);
            }
        }
        public void SaveDummyModel()
        {
            //given --
            DynamicFormModel dynamicModel = new DynamicFormModel();
            ToolModel toolModelNotePad = new ToolModel(textButton:"run", actionButton: "notepad.exe");
            ToolModel toolModelBrowser = new ToolModel(textButton: "navigate", actionButton: "www.google.com");
            dynamicModel.ToolModels = new[] {toolModelNotePad, toolModelBrowser };

            //when
            DynamicFormModelSerializer.WriteToXmlFile(dynamicModel, path: "Z:\\config.xml");
        }
 public static void WriteToXmlFile(DynamicFormModel dynamicFormModel, string path)
 {
     XmlSerializer serializer = new XmlSerializer(typeof(DynamicFormModel));
     using (TextWriter writer = File.CreateText(path))
         serializer.Serialize(writer, dynamicFormModel);
 }