Exemple #1
0
        private string Serializacao()
        {
            belModulos     _objModulos = new belModulos();
            belFormularios _objForm;
            int            _cont = 0;

            while (_cont < gvForms.Rows.Count)
            {
                if ((gvForms[idForm.Name, _cont].Value != null) && ((bool)gvForms[ativo.Name, _cont].Value))
                {
                    _objForm             = new belFormularios();
                    _objForm.xType       = gvForms[namespaceform.Name, _cont].Value.ToString() + ", " + edtNamesPrinc.Text;
                    _objForm.xScope      = gvForms[scope.Name, _cont].Value.ToString();
                    _objForm.stSingleton = gvForms[singleton.Name, _cont].Value.ToString();
                    _objForm.xName       = gvForms[form.Name, _cont].Value.ToString();
                    _objForm.xId         = gvForms[idForm.Name, _cont].Value.ToString();
                    _objModulos.lFormularios.Add(_objForm);
                }
                _cont++;
            }

            cSerializar _objSeria = new cSerializar();

            return(_objSeria.Serializar(_objModulos, Application.StartupPath + @"\confs", edtModulo.Text));
        }
Exemple #2
0
        public string Serializar(belModulos vModulos, string vDiret, string vNomeArq)
        {
            string sXmlSerializer      = null;
            XmlSerializerNamespaces ns = new XmlSerializerNamespaces(
                new[] { new XmlQualifiedName("ns", "http://www.springframework.net"),
                        new XmlQualifiedName("default-lazy-init", "true") });
            XmlSerializer xs      = new XmlSerializer(typeof(belModulos));
            MemoryStream  memory  = new MemoryStream();
            XmlTextWriter xmltext = new XmlTextWriter(memory, Encoding.UTF8);

            xs.Serialize(xmltext, vModulos, ns);
            UTF8Encoding encoding = new UTF8Encoding();

            sXmlSerializer = encoding.GetString(memory.ToArray());
            sXmlSerializer = sXmlSerializer.Replace("ns:", "");
            sXmlSerializer = sXmlSerializer.Replace("xmldefault-lazy-init", "default-lazy-init");
            if (!Directory.Exists(vDiret))
            {
                Directory.CreateDirectory(vDiret);
            }
            File.Create(vDiret + @"\" + vNomeArq + ".xml").Close();
            StreamWriter _sw = new StreamWriter(vDiret + vNomeArq + ".xml");

            _sw.Write(sXmlSerializer);
            _sw.Close();
            return(vDiret + vNomeArq + ".xml");
        }