예제 #1
0
        public static bool TryLoad(string str, out cPanelResult <TResponse> res)
        {
            MemoryStream ms     = new MemoryStream();
            StreamWriter writer = new StreamWriter(ms);

            writer.Write(str);
            writer.Flush();
            ms.Position = 0;

            return(TryLoad(ms, out res));
        }
예제 #2
0
        public static bool TrySave(out string str, cPanelResult <TResponse> res)
        {
            MemoryStream ms     = new MemoryStream();
            bool         result = TrySave(ms, res);

            ms.Position = 0;
            StreamReader reader = new StreamReader(ms);

            str = reader.ReadToEnd();

            return(result);
        }
예제 #3
0
        public static bool TrySave(Stream s, cPanelResult <TResponse> res)
        {
            Type[]        tArray = new Type[] { typeof(TResponse) };
            XmlSerializer ser    = new XmlSerializer(res.GetType(), tArray);

            try
            {
                ser.Serialize(s, res);
            }
            catch (Exception e)
            {
                Console.WriteLine("XML Serialization Failure: " + e.Message);
            }

            return(true);
        }
예제 #4
0
        public static bool TryLoad(Stream s, out cPanelResult <TResponse> res)
        {
            res = new cPanelResult <TResponse>();
            Type[] tArray = new Type[] { typeof(TResponse) };

            try
            {
                XmlSerializer ser = new XmlSerializer(res.GetType(), tArray);
                ser.UnknownAttribute += new XmlAttributeEventHandler(XmlUnknownAttribute);
                ser.UnknownNode      += new XmlNodeEventHandler(XmlUnknownNode);
                res = (cPanelResult <TResponse>)ser.Deserialize(s);
            }
            catch (Exception e)
            {
                Console.WriteLine("XML Serialization Failure: " + e.Message);
                return(false);
            }

            return(true);
        }