Пример #1
0
 void IDisposable.Dispose()
 {
     if (desktop != null)
     {
         desktop.Dispose();
     }
 }
Пример #2
0
        /// <summary>
        /// Checks desktop
        /// </summary>
        /// <param name="desktop">The desktop</param>
        /// <param name="binders">The serialization binders</param>
        /// <returns>List of exceptions or null if right</returns>
        public static List <Exception> Check(IDesktop desktop, SerializationBinder[] binders)
        {
            exceptions = new List <Exception>();
            bool b = false;

            try
            {
                IEnumerable <IObjectLabel> objects = desktop.Objects;
                IEnumerable <IArrowLabel>  arrows  = desktop.Arrows;
                PureDesktopPeer            d       = new PureDesktopPeer();
                d.Copy(objects, arrows, true);
                d.SetParents();
                Stream stream = new MemoryStream();
                d.Save(stream);
                PureDesktopPeer dnew = new PureDesktopPeer();
                b = dnew.Load(stream);
                dnew.Dispose();
            }
            catch (Exception e)
            {
                e.ShowError(10);
                if (exceptions != null)
                {
                    exceptions.Add(e);
                }
            }
            List <Exception> res = b ? null : exceptions;

            exceptions = null;
            desktop.SetParents();
            return(res);
        }
Пример #3
0
        /// <summary>
        /// Checks loading from stream
        /// </summary>
        /// <param name="stream">The stream</param>
        /// <returns>List of exceptions</returns>
        public static List <Exception> Check(Stream stream)
        {
            bool b = false;
            SerializationBinder binder = SerializationInterface.StaticExtensionSerializationInterface.Binder;

            exceptions = new List <Exception>();
            try
            {
                PureDesktopPeer d = new PureDesktopPeer();
                d.Load(stream, binder, true);
                d.SetParents();
                Stream s = new MemoryStream();
                d.Save(s);
                d.Dispose();
                PureDesktopPeer dnew = new PureDesktopPeer();
                b = dnew.Load(s, binder, true);
                dnew.Dispose();
            }
            catch (Exception e)
            {
                e.ShowError(10);
                if (exceptions != null)
                {
                    exceptions.Add(e);
                }
            }
            List <Exception> res = b ? null : exceptions;

            if (res != null)
            {
                if (res.Count == 0)
                {
                    res = null;
                }
            }
            exceptions = null;
            return(res);
        }