예제 #1
0
        public void SetExceptionBehavior(ExceptionBehaviorMap newMap)
        {
            var changed = _exceptionBehaviorMap.CopyFrom(newMap);

            if (!_wasPrepared || changed.Count == 0)
            {
                return;
            }
            SetupBehaviors(changed);
        }
예제 #2
0
 /// <summary>
 /// Copy the state of the given object to me.
 /// </summary>
 public void CopyFrom(ExceptionBehaviorMap source)
 {
     lock (mapLock)
     {
         DefaultStopOnThrow  = source.DefaultStopOnThrow;
         DefaultStopUncaught = source.DefaultStopUncaught;
         map.Clear();
         foreach (var entry in source.map)
         {
             map[entry.Key] = entry.Value;
         }
     }
 }
예제 #3
0
        /// <summary>
        /// Copy the state of the given object to me.
        ///
        /// Returns all behaviors that have changed, with their new  values.
        /// If the default behavior was changed, the first returned behavior
        /// will be null.
        /// </summary>
        public IList <ExceptionBehavior> CopyFrom(ExceptionBehaviorMap source)
        {
            source = source.Clone();

            lock (mapLock)
            {
                List <string> changed = new List <string>();

                // find changed values
                foreach (var entry in source.map)
                {
                    if (!Equals(this[entry.Key], entry.Value))
                    {
                        changed.Add(entry.Key);
                    }
                }

                // add all values that have been removed.
                changed.AddRange(map.Keys.ToList()
                                 .Where(key => !source.map.ContainsKey(key)));

                map.Clear();
                foreach (var entry in source.map)
                {
                    map[entry.Key] = entry.Value;
                }

                List <ExceptionBehavior> ret = new List <ExceptionBehavior>();

                if (DefaultStopUncaught != source.DefaultStopUncaught || DefaultStopOnThrow != source.DefaultStopOnThrow)
                {
                    ret.Insert(0, null);
                }

                ret.AddRange(changed.Select(x => this[x]));

                DefaultStopOnThrow  = source.DefaultStopOnThrow;
                DefaultStopUncaught = source.DefaultStopUncaught;

                return(ret);
            }
        }
예제 #4
0
 public void SetExceptionBehavior(ExceptionBehaviorMap newMap)
 {
     var changed = _exceptionBehaviorMap.CopyFrom(newMap);
     if (!_wasPrepared || changed.Count == 0) return;
     SetupBehaviors(changed);
 }
예제 #5
0
 private ExceptionBehaviorMap(ExceptionBehaviorMap copy)
 {
     DefaultStopOnThrow = copy.DefaultStopOnThrow;
     DefaultStopUncaught = copy.DefaultStopUncaught;
     map = new Dictionary<string, ExceptionBehavior>(copy.map);
 }
예제 #6
0
        /// <summary>
        /// Copy the state of the given object to me.
        /// 
        /// Returns all behaviors that have changed, with their new  values.
        /// If the default behavior was changed, the first returned behavior
        /// will be null.
        /// </summary>
        public IList<ExceptionBehavior> CopyFrom(ExceptionBehaviorMap source)
        {
            source = source.Clone();

            lock (mapLock)
            {
                List<string> changed = new List<string>();

                // find changed values
                foreach (var entry in source.map)
                {
                    if (!Equals(this[entry.Key], entry.Value))
                        changed.Add(entry.Key);
                }

                // add all values that have been removed.
                changed.AddRange(map.Keys.ToList()
                                         .Where(key => !source.map.ContainsKey(key)));

                map.Clear();
                foreach (var entry in source.map)
                {
                    map[entry.Key] = entry.Value;
                }

                List<ExceptionBehavior> ret = new List<ExceptionBehavior>();

                if(DefaultStopUncaught != source.DefaultStopUncaught || DefaultStopOnThrow  != source.DefaultStopOnThrow)
                    ret.Insert(0, null);

                ret.AddRange(changed.Select(x => this[x]));

                DefaultStopOnThrow = source.DefaultStopOnThrow;
                DefaultStopUncaught = source.DefaultStopUncaught;

                return ret;
            }
        }
예제 #7
0
 private ExceptionBehaviorMap(ExceptionBehaviorMap copy)
 {
     DefaultStopOnThrow  = copy.DefaultStopOnThrow;
     DefaultStopUncaught = copy.DefaultStopUncaught;
     map = new Dictionary <string, ExceptionBehavior>(copy.map);
 }