示例#1
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;
		}
示例#2
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;
        }
示例#3
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;
 }
示例#4
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;
 }
示例#5
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();
			}
		}