예제 #1
0
 protected static IFileParserCSharp GetFileParser()
 {
     try
     {
         if (_fileParser == null)
         {
             _fileParser = ConfigParserFactory.Instance().CreateCSharpFileParser();
             _fileParser.Initialize();
         }
     }
     catch (Exception e)
     {
         Logger.Instance.LogDevWarning(e.Message);
     }
     return(_fileParser);
 }
예제 #2
0
        /// <summary>
        /// Desrialize
        /// </summary>
        /// <typeparam name="T">Target object type</typeparam>
        /// <param name="fullPathName">Full file path</param>
        /// <returns>Target object</returns>
        public static T Desrialize <T>(string fullPathName)
        {
            try
            {
                T obj = default(T);

                //Load xmlstring from xml file by FileParser
                IFileParserCSharp filePaser = ConfigParserFactory.Instance().CreateCSharpFileParser();
                filePaser.Initialize();
                filePaser.ParseByURI(fullPathName);
                string xmlString = filePaser.WriteToString();
                filePaser.Terminate();

                //Deserialize xmlstring to target object
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(T));
                obj = (T)(xmlSerializer.Deserialize(new StringReader(xmlString)));

                return(obj);
            }
            catch (Exception ex)
            {
                throw new Exception("Desrialize failed, Ex:" + ex.Message);
            }
        }
예제 #3
0
 static FileParserWrapper()
 {
     _fileParser = ConfigParserFactory.Instance().CreateCSharpFileParser();
     _fileParser.Initialize();
 }