Пример #1
0
        /// <summary>
        /// Pushes an ObixError onto the stack if not cancelled.
        /// </summary>
        /// <param name="error">An instance of an Obix Error.</param>
        public ObixResult Push(ObixError error)
        {
            ObixErrorEventArgs args = null;

            if (error == null)
            {
                return(ObixResult.kObixClientUnknownError);
            }

            args = new ObixErrorEventArgs(error);
            if (ErrorAdded != null)
            {
                ErrorAdded(null, args);
            }

            if (args.Cancelled == true)
            {
                return(ObixResult.kObixClientUnknownError);
            }

            lock (errorMutex) {
                errorStack.Insert(0, error);
                if (errorStack.Count >= 100)
                {
                    errorStack.RemoveAt(errorStack.Count);
                }
            }

            return((ObixResult)error.ErrorCode);
        }
Пример #2
0
        /// <summary>
        /// Pops the entire error stack into an array.
        /// </summary>
        /// <returns>An array of ObixErrors, or NULL if an error occured.</returns>
        public ObixError[] PopArray()
        {
            ObixError[] errArry = null;

            if (errorStack.Count == 0)
            {
                return(null);
            }

            lock (errorMutex) {
                errArry = new ObixError[errorStack.Count];
                errorStack.CopyTo(errArry);
                errorStack.Clear();
            }

            return(errArry);
        }
Пример #3
0
        /// <summary>
        /// Pops a single error off the stack.
        /// </summary>
        /// <returns>A single ObixError object, or null if empty or an error.</returns>
        public ObixError Pop()
        {
            ObixError error = null;

            lock (errorMutex) {
                if (errorStack.Count > 0)
                {
                    error = errorStack[0];
                }
                if (error != null)
                {
                    errorStack.Remove(error);
                }
            }

            return(error);
        }
Пример #4
0
 public ObixErrorEventArgs(ObixError Error)
 {
     this.Error     = Error;
     this.Cancelled = false;
 }