Ejemplo n.º 1
0
        public bool LoadBinary(string filename)
        {
            bool result;

            try
            {
                Stream          stream          = File.Open(filename, FileMode.Open);
                BinaryFormatter binaryFormatter = new BinaryFormatter();
                if (stream.Length > 0L)
                {
                    CustomPropertyCollection customPropertyCollection = (CustomPropertyCollection)binaryFormatter.Deserialize(stream);
                    IEnumerator enumerator = null;
                    try
                    {
                        enumerator = customPropertyCollection.GetEnumerator();
                        while (enumerator.MoveNext())
                        {
                            CustomProperty customProperty = (CustomProperty)enumerator.Current;
                            customProperty.RebuildAttributes();
                            this.Add(customProperty);
                        }
                    }
                    finally
                    {
                        if (enumerator is IDisposable)
                        {
                            (enumerator as IDisposable).Dispose();
                        }
                    }
                    stream.Close();
                    result = true;
                }
                else
                {
                    stream.Close();
                    result = false;
                }
            }
            catch (Exception expr_84)
            {
                ProjectData.SetProjectError(expr_84);
                result = false;
                ProjectData.ClearProjectError();
            }
            return(result);
        }
Ejemplo n.º 2
0
        public bool LoadXml(string filename)
        {
            bool        result;
            IEnumerator enumerator = null;

            try
            {
                XmlSerializer            xmlSerializer            = new XmlSerializer(typeof(CustomPropertyCollection));
                FileStream               fileStream               = new FileStream(filename, FileMode.Open);
                CustomPropertyCollection customPropertyCollection = (CustomPropertyCollection)xmlSerializer.Deserialize(fileStream);
                try
                {
                    enumerator = customPropertyCollection.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        CustomProperty customProperty = (CustomProperty)enumerator.Current;
                        customProperty.RebuildAttributes();
                        this.Add(customProperty);
                    }
                }
                finally
                {
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
                fileStream.Close();
                result = true;
            }
            catch (Exception expr_7A)
            {
                ProjectData.SetProjectError(expr_7A);
                result = false;
                ProjectData.ClearProjectError();
            }
            return(result);
        }