Ejemplo n.º 1
0
        private IHandler[] GetHandlersNoLock(Type service)
        {
            //we have 3 segments
            const int defaults  = 0;
            const int regulars  = 1;
            const int fallbacks = 2;
            var       handlers  = new SegmentedList <IHandler>(3);

            foreach (var handler in name2Handler.Values)
            {
                if (handler.Supports(service) == false)
                {
                    continue;
                }
                if (IsDefault(handler, service))
                {
                    handlers.AddFirst(defaults, handler);
                    continue;
                }
                if (IsFallback(handler, service))
                {
                    handlers.AddLast(fallbacks, handler);
                    continue;
                }
                handlers.AddLast(regulars, handler);
            }
            return(handlers.ToArray());
        }
Ejemplo n.º 2
0
            public void BasicToArray(T[] items)
            {
                SegmentedList <T> list = new SegmentedList <T>(items);

                T[] arr = list.ToArray();

                for (int i = 0; i < items.Length; i++)
                {
                    Assert.Equal(((object?)arr[i]), items[i]); //"Should be equal."
                }
            }
Ejemplo n.º 3
0
            public void EnsureNotUnderlyingToArray(T[] items, T item)
            {
                SegmentedList <T> list = new SegmentedList <T>(items);

                T[] arr = list.ToArray();
                list[0] = item;
                if (((object?)arr[0]) == null)
                {
                    Assert.NotNull(list[0]); //"Should NOT be null"
                }
                else
                {
                    Assert.NotEqual(((object?)arr[0]), list[0]); //"Should NOT be equal."
                }
            }
Ejemplo n.º 4
0
		private IHandler[] GetHandlersNoLock(Type service)
		{
			//we have 3 segments
			const int defaults = 0;
			const int regulars = 1;
			const int fallbacks = 2;
			var handlers = new SegmentedList<IHandler>(3);
			foreach (var handler in name2Handler.Values)
			{
				if (handler.Supports(service) == false)
				{
					continue;
				}
				if (IsDefault(handler, service))
				{
					handlers.AddFirst(defaults, handler);
					continue;
				}
				if (IsFallback(handler, service))
				{
					handlers.AddLast(fallbacks, handler);
					continue;
				}
				handlers.AddLast(regulars, handler);
			}
			return handlers.ToArray();
		}