Пример #1
0
 public bool LoadBinary(string filename)
 {
     try
     {
         Stream          stream    = File.Open(filename, FileMode.Open);
         BinaryFormatter formatter = new BinaryFormatter();
         if (stream.Length > 0)
         {
             JxCustomPropertyCollection cpc = (JxCustomPropertyCollection)formatter.Deserialize(stream);
             foreach (JxCustomProperty customprop in cpc)
             {
                 customprop.RebuildAttributes();
                 this.Add(customprop);
             }
             cpc = null;
             stream.Close();
             return(true);
         }
         else
         {
             stream.Close();
             return(false);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #2
0
        public bool LoadXml(string filename)
        {
            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(JxCustomPropertyCollection));
                FileStream    reader     = new FileStream(filename, FileMode.Open);

                JxCustomPropertyCollection cpc = (JxCustomPropertyCollection)serializer.Deserialize(reader);
                foreach (JxCustomProperty customprop in cpc)
                {
                    customprop.RebuildAttributes();
                    this.Add(customprop);
                }
                cpc = null;
                reader.Close();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }