Exemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="eventArgs"></param>
 protected void RaiseOpeningEvent(OpeningEventArgs eventArgs)
 {
     if (this.Opening != null)
     {
         this.Opening(this, eventArgs);
     }
 }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
            }
        }
Exemplo n.º 5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="eventArgs"></param>
 protected void OnOpeningInternal(OpeningEventArgs eventArgs)
 {
     this.OnOpening(eventArgs);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Called before the Opening event is raised.
 /// </summary>
 /// <remarks>
 /// Notes to Inheritors: When overriding OnOpening in a derived class, calling the base class's OnOpening 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 OnOpening(OpeningEventArgs eventArgs)
 {
 }