Beispiel #1
0
        public bool LoadObjectFromXmlNode<T>(XmlNode node, ref T dest)
        {
            XmlNodeReader reader = new XmlNodeReader(node);
            try
            {
                
                if (reader != null)
                {
                    //NetDataContractSerializer serial = new NetDataContractSerializer();
                    XmlSerializer serial = new XmlSerializer(typeof(T));
                    dest = (T)serial.Deserialize(reader);
                    return true;
                }
            }
            catch (Exception e)
            {
                SLogManager.getInstance().getClassLogger(GetType()).Error(e.Message);
            }
            finally
            {
                if (reader != null) reader.Close();
            }

            return false;
        }
Beispiel #2
0
		public bool LoadObject<T>(string key, ref T dest)
		{
			Stream reader = null;
			try
			{
				reader = GetReader(key);

				if (reader != null)
				{
					NetDataContractSerializer serial = new NetDataContractSerializer();
					//XmlSerializer serial = new XmlSerializer(typeof(T));
					dest = (T)serial.ReadObject(reader);
					return true;
				}
			}
			catch (Exception e)
			{
				SLogManager.getInstance().getClassLogger(GetType()).Error(e.Message);
			}
			finally
			{
				if (reader != null) reader.Close();
			}

			return false;
		}
Beispiel #3
0
 public static SLogManager getInstance()
 {
     if (instance == null)
     {
         instance = new SLogManager();
     }
     return(instance);
 }
Beispiel #4
0
 public static Icon GetIconFromFile(string fileName, Type host = null)
 {
     Icon bitmap = null;
     try
     {
         bitmap = Icon.ExtractAssociatedIcon(GetDefaultAssetsPath(AssetKind.Image, host) + Path.DirectorySeparatorChar + fileName);
     }
     catch (Exception e)
     {
         SLogManager.getInstance().Error(e.Message);
         return null;
     }
     return bitmap;
 }
Beispiel #5
0
 public static Bitmap GetBitmapFromFile(string fileName, Type host = null)
 {
     Bitmap bitmap = null;
     try
     {
         bitmap = (Bitmap)Image.FromFile(GetDefaultAssetsPath(AssetKind.Image, host) + Path.DirectorySeparatorChar + fileName, true);
     }
     catch (Exception e)
     {
         SLogManager.getInstance().Error(e.Message);
         return null;
     }
     return bitmap;
 }
Beispiel #6
0
		public void SaveObject<T>(string key, T what) {
			Stream writer = null;
			try
			{

				//XmlSerializer serial = new XmlSerializer(typeof(T));
				NetDataContractSerializer serial = new NetDataContractSerializer();
				writer = GetWriter(key);
				serial.WriteObject(writer, what);
			}
			catch (Exception e)
			{
				SLogManager.getInstance().getClassLogger(GetType()).Error(e.Message);
			}
			finally
			{
				writer.Close();
			}
		}
Beispiel #7
0
 public static SLogManager getInstance()
 {
     if (instance == null)
     {
         instance = new SLogManager();
     }
     return instance;
 }