Esempio n. 1
0
 /// <summary>
 /// RaiseOpenedEvent should be called by a controller extending Open once the model is loaded.
 /// </summary>
 /// <param name="eventArgs"></param>
 protected void RaiseOpenedEvent(OpenedEventArgs eventArgs)
 {
     if (this.Opened != null)
     {
         this.Opened(this, eventArgs);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// OnOpenedInternal should be called by a controller extending Open once the model is loaded.
        /// </summary>
        /// <param name="eventArgs"></param>
        protected void OnOpenedInternal(OpenedEventArgs eventArgs)
        {
            if (this.UndoManager != null)
            {
                this.UndoManager.Model = this.Model;
            }

            if (this.SearchEngine != null)
            {
                this.SearchEngine.Model = this.Model;
            }

            if (this.ValidationManager != null)
            {
                this.ValidationManager.Model = this.Model;
            }

            this.OnOpened(eventArgs);
        }
Esempio n. 3
0
        /// <summary>
        /// Open an existing Configuration from the underlying migration tools
        /// DB synchronously.
        /// </summary>
        /// <param name="sessionGroupUniqueId">The unique id of the configuration</param>
        /// <returns><c>true</c> if the open completed, <c>false</c> otherwise.</returns>
        public bool Open(Guid sessionGroupUniqueId)
        {
            if (this.Close())
            {
                string guid = sessionGroupUniqueId.ToString();

                OpeningEventArgs openingEventArgs = new OpeningEventArgs(guid);
                this.OnOpeningInternal(openingEventArgs);
                this.RaiseOpeningEvent(openingEventArgs);

                OpenedEventArgs openedEventArgs = null;

                try
                {
                    base.Model      = ConfigurationModel.Load(sessionGroupUniqueId);
                    openedEventArgs = new OpenedEventArgs(guid, null);
                }
                catch (Exception exception)
                {
                    openedEventArgs = new OpenedEventArgs(guid, exception);
                }

                try
                {
                    this.OnOpenedInternal(openedEventArgs);
                }
                catch (Exception exception)
                {
                    openedEventArgs = new OpenedEventArgs(guid, exception);
                }

                this.RaiseOpenedEvent(openedEventArgs);

                return(true);
            }

            return(false);
        }
Esempio n. 4
0
        private bool Open(Stream stream, string path)
        {
            if (this.Close())
            {
                OpeningEventArgs openingEventArgs = new OpeningEventArgs(path);
                this.OnOpeningInternal(openingEventArgs);
                this.RaiseOpeningEvent(openingEventArgs);

                OpenedEventArgs openedEventArgs = null;

                try
                {
                    this.OpenInternal(stream, path);
                    openedEventArgs = new OpenedEventArgs(path, null);
                }
                catch (Exception exception)
                {
                    openedEventArgs = new OpenedEventArgs(path, exception);
                }

                try
                {
                    this.OnOpenedInternal(openedEventArgs);
                }
                catch (Exception exception)
                {
                    openedEventArgs = new OpenedEventArgs(path, exception);
                }

                this.RaiseOpenedEvent(openedEventArgs);

                return(true);
            }

            return(false);
        }
Esempio n. 5
0
        private void OpenAsync(Stream stream, string path)
        {
            if (this.Close())
            {
                OpeningEventArgs openingEventArgs = new OpeningEventArgs(path);
                this.OnOpeningInternal(openingEventArgs);
                this.RaiseOpeningEvent(openingEventArgs);

                SendOrPostCallback onOpened = delegate(object eventArgs)
                {
                    OpenedEventArgs openedEventArgs = eventArgs as OpenedEventArgs;
                    Debug.Assert(openedEventArgs != null);
                    this.OnOpenedInternal(openedEventArgs);
                };

                SendOrPostCallback raiseEvent = delegate(object eventArgs)
                {
                    OpenedEventArgs openedEventArgs = eventArgs as OpenedEventArgs;
                    Debug.Assert(openedEventArgs != null);
                    this.RaiseOpenedEvent(openedEventArgs);
                };

                AnonymousMethod open = delegate
                {
                    OpenedEventArgs openedEventArgs = null;

                    try
                    {
                        this.OpenInternal(stream, path);
                        openedEventArgs = new OpenedEventArgs(path, null);
                    }
                    catch (ConfigurationSchemaViolationException e)
                    {
                        openedEventArgs = new OpenedEventArgs(path, e);
                    }
                    catch (ConfigurationBusinessRuleViolationException e)
                    {
                        openedEventArgs = new OpenedEventArgs(path, e);
                    }
                    catch (Exception exception)
                    {
                        openedEventArgs = new OpenedEventArgs(path, exception);
                    }

                    try
                    {
                        // For the OnOpened virtual method, do a synchronous send so that we
                        // can trap any exceptions and report them to the event handlers
                        this.asyncOperation.SynchronizationContext.Send(onOpened, openedEventArgs);
                    }
                    catch (Exception exception)
                    {
                        openedEventArgs = new OpenedEventArgs(path, exception);
                    }

                    // For the Opened event, do an asynchronous post because we don't care about
                    // exceptions that are raised by event handlers
                    this.asyncOperation.Post(raiseEvent, openedEventArgs);
                };

                open.BeginInvoke(null, null);
            }
        }
Esempio n. 6
0
 /// <summary>
 /// Called before the Opened event is raised.
 /// </summary>
 /// <remarks>
 /// Notes to Inheritors: When overriding OnOpened in a derived class, calling the base class's OnOpened method is not necessary because there is no initial implementation.
 /// </remarks>
 /// <param name="eventArgs">An EventArgs that contains the event data.</param>
 protected virtual void OnOpened(OpenedEventArgs eventArgs)
 {
 }