Esempio n. 1
0
        /* Dserializza da un file CSV */
        public static C_CIE readFromCSV(string source_file, string separator)
        {
            if (!File.Exists(source_file))
            {
                return(null);
            }

            C_CIE  tmp    = new C_CIE();
            string source = System.IO.File.ReadAllText(source_file);

            String[] substrings = source.Split(separator.ToCharArray());
            tmp.firstName = substrings[0];
            tmp.lastName  = substrings[1];
            tmp.birthCity = substrings[2];
            tmp.birthProv = substrings[3];
            tmp.address   = substrings[4];
            tmp.prov      = substrings[5];
            tmp.cf        = substrings[6];
            tmp.mrz       = substrings[7];
            tmp.dateIssue = substrings[8];
            tmp.city      = substrings[9];

            string cie_j = "";

            for (int i = 10; i < substrings.Length; i++)
            {
                cie_j += substrings[i];
            }

            tmp.cie_jpg2k_image = Convert.FromBase64String(cie_j);

            return(tmp);
        }
Esempio n. 2
0
        /* Deserializza da un file XML*/
        static public C_CIE readFromXML(String path)
        {
            C_CIE cie = null;

            XmlSerializer serializer = new XmlSerializer(typeof(C_CIE));

            if (!File.Exists(path))
            {
                return(null);
            }

            StreamReader reader = new StreamReader(path);

            cie = (C_CIE)serializer.Deserialize(reader);
            reader.Close();

            return(cie);
        }