Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Error XML #4

Closed
gladitop opened this issue Mar 17, 2020 · 1 comment
Closed

Bug: Error XML #4

gladitop opened this issue Mar 17, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@gladitop
Copy link
Owner

Code a class XML

[Serializable]
    public class SettingsXmlFtp
    {
        //[XmlArray("serverXmlsList")]
        //public List<ServerXmlFtp> serverXmls = new List<ServerXmlFtp>();
        //public int lol { get; set; } = 0;

        public SettingsXmlFtp(Settings.listServer listServer)
        {
            DescriptionServer = listServer.descriptionServer;
            RootNameFolder = listServer.nameServer;
            RootPlaceFolder = listServer.pathServer;
            Passworld = listServer.passworld;
            Ver = listServer.ver;
            PathCertificate = listServer.pathCertificate;
            PassworldCertificate = listServer.passworldCertificate;

            TypeConnect = Settings.TypeConnect.FTP;// !!!

            User = listServer.user;
            MaxConnections = listServer.maxConnections;
            Port = listServer.port;
        }

        [XmlElement("descriptionServer")]
        public string DescriptionServer { get; set; } = null;

        [XmlElement("rootNameFolder")]
        public string RootNameFolder { get; set; } = null;

        [XmlElement("rootPlaceFolder")]
        public string RootPlaceFolder { get; set; } = null;

        [XmlElement("passworld")]
        public string Passworld { get; set; } = null;

        [XmlElement("ver")]
        public string Ver { get; set; } = null;

        [XmlElement("pathCertificate")]
        public string PathCertificate { get; set; } = null;

        [XmlElement("passworldCertificate")]
        public string PassworldCertificate { get; set; } = null;

        [XmlElement("typeConnect")]
        public Settings.TypeConnect? TypeConnect { get; set; } = null; //Этот класс только для FTP (но без этого не куда!)

        [XmlElement("user")]
        public string User { get; set; } = null;

        [XmlElement("maxConnections")]
        public int MaxConnections { get; set; } = 0;

        [XmlElement("port")]
        public int Port { get; set; } = 0;
    }
    [Serializable]

XML Serialize

        public void Import(SettingsXmlFtp settings)//Save
        {
            XmlSerializer xml = new XmlSerializer(typeof(SettingsXmlFtp));

            using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate))
            {
                xml.Serialize(fs, settings); // тут баг!
                //он не имеет беспараметрического конструктора
            }
        }

Description exception

it does not have a parameterless constructor

@gladitop gladitop added the bug Something isn't working label Mar 17, 2020
@gladitop
Copy link
Owner Author

I fixed it!

XML Serialize

        public void Import(ServerInfoFTP serverInfoFTP)//Save
        {
            XmlSerializer xml = new XmlSerializer(typeof(ServerInfoFTP));

            using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate))
            {
                xml.Serialize(fs, serverInfoFTP);

                fs.Close();
            }
        }

Code a class XML

    [Serializable]
    public class ServerInfoFTP
    {
        [XmlElement("lol")]
        public int Lol { get; set; }
        [XmlElement("lolKek")]
        public string LOlKek { get; set; }
    }

I think the export and import of servers I will do in version 1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant