// TODO: toggle comments of exception handlers // public override void BeginLoad(IDesignerLoaderHost host) { if (host == null) { throw new ArgumentNullException("host"); } if (_loaded) { throw new InvalidOperationException("Already loaded."); } if (_host != null && _host != host) { throw new InvalidOperationException("Trying to load with a different host"); } if (_host == null) // beingload is called on reload - no need to initialize twice. { _host = host; Initialize(); } IDisposable session = _serializationMananger.CreateSession(); IDesignerLoaderService loader = _host.GetService(typeof(IDesignerLoaderService)) as IDesignerLoaderService; if (loader != null) { _dependenciesCount = -1; loader.AddLoadDependency(); } else { OnBeginLoad(); } bool successful = true; // try { PerformLoad(_serializationMananger); // } catch (Exception e) { // successful = false; // _serializationMananger.Errors.Add (e); // while (e.InnerException != null) { // _serializationMananger.Errors.Add (e); // Console.WriteLine (e.InnerException); // e = e.InnerException; // } // } if (loader != null) { loader.DependentLoadComplete(successful, _serializationMananger.Errors); } else { OnEndLoad(successful, _serializationMananger.Errors); } session.Dispose(); }
public override void Flush() { if (!_loaded) { throw new InvalidOperationException("host not initialized"); } if (!_flushing && this.Modified) { _flushing = true; using ((IDisposable)_serializationMananger.CreateSession()) { try { PerformFlush(_serializationMananger); } catch (Exception e) { _serializationMananger.Errors.Add(e); while (e.InnerException != null) { _serializationMananger.Errors.Add(e); Console.WriteLine(e.InnerException); e = e.InnerException; } ReportFlushErrors(_serializationMananger.Errors); } } _flushing = false; } }
public IDisposable CreateSession() { return(_manager.CreateSession()); }