Exemple #1
0
 /// <summary>
 ///     Nạp cấu hình của service
 /// </summary>
 /// <returns></returns>
 private NotifierProperties GetConfig()
 {
     try
     {
         var    myProperties = new NotifierProperties();
         string filePath     = string.Format("{0}{1}.xml", AppPath, myProperties.GetType().Name);
         var    myFileStream = new FileStream(filePath, FileMode.Open);
         var    mySerializer = new XmlSerializer(myProperties.GetType());
         myProperties = (NotifierProperties)mySerializer.Deserialize(myFileStream);
         myFileStream.Flush();
         myFileStream.Close();
         return(myProperties);
     }
     catch (Exception ex)
     {
         return(new NotifierProperties());
     }
 }
Exemple #2
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="ProcessIcon" /> class.
        /// </summary>
        public ProcessIcon()
        {
            _myProperties = GetConfig();

            //var myWriter = new StreamWriter(string.Format("{0}{1}.xml", AppDomain.CurrentDomain.BaseDirectory, _myProperties.GetType().Name));
            //try
            //{
            //    var mySerializer = new XmlSerializer(_myProperties.GetType());
            //    mySerializer.Serialize(myWriter, _myProperties);
            //}
            //catch (Exception)
            //{
            //}
            //finally
            //{
            //    myWriter.Flush();
            //    myWriter.Close();
            //}
            // Instantiate the NotifyIcon object.
            _ni = new NotifyIcon();
        }