Exemple #1
0
        public static XMLScreen load(string filename)
        {
            var serializer = new XmlSerializer(typeof(XMLScreen));
            //
            FileStream fs    = null;
            XMLScreen  rules = null;

            try
            {
                fs = new FileStream(filename, FileMode.Open);
                //XmlTextReader reader = new XmlTextReader(fs);

                rules          = (XMLScreen)serializer.Deserialize(fs);
                rules.FileName = filename;
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
            }
            rules.Render();
            return(rules);
        }
Exemple #2
0
        public static XMLScreen LoadFromString(string text)
        {
            var serializer = new XmlSerializer(typeof(XMLScreen));
            //
            StringReader fs    = null;
            XMLScreen    rules = null;

            try
            {
                fs = new StringReader(text);
                //XmlTextReader reader = new XmlTextReader(fs);

                rules          = (XMLScreen)serializer.Deserialize(fs); //reader);
                rules.FileName = null;
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception " + e.Message + " reading document. saved as c:\\dump.xml");
                var sw = File.CreateText("c:\\dump.xml");
                sw.WriteLine(text);
                sw.Close();
                throw;
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
            }
            rules.Render();
            rules._stringValueCache = text;
            return(rules);
        }
Exemple #3
0
        /// <summary>
        ///     Get the current screen as an XMLScreen data structure
        /// </summary>
        /// <returns></returns>
        internal IXMLScreen GetScreenAsXML()
        {
            DisposeOfCurrentScreenXML();

            if (currentConnection == null)
            {
                throw new TNHostException("TNEmulator is not connected", "There is no currently open TN3270 connection",
                                          null);
            }
            if (currentConnection.ExecuteAction(false, "DumpXML"))
            {
                //
                return(XMLScreen.LoadFromString(currentConnection.GetAllStringData(false)));
            }
            return(null);
        }
Exemple #4
0
        public static XMLScreen load(Stream sr)
        {
            var serializer = new XmlSerializer(typeof(XMLScreen));
            //
            XMLScreen rules = null;

            var temp = serializer.Deserialize(sr);

            rules = (XMLScreen)temp;

            if (rules != null)
            {
                rules.FileName = null;

                rules.Render();
            }
            return(rules);
        }