public void RequestFilters_are_prioritized() { appHost.Metadata.Add(typeof(AttributeAttributeFilteredService), typeof(DummyHolder), null); var attributes = FilterAttributeCache.GetRequestFilterAttributes(typeof(DummyHolder)); var attrPriorities = attributes.ToList().ConvertAll(x => x.Priority); Assert.That(attrPriorities, Is.EquivalentTo(new[] { int.MinValue, -100, -90, -80, 0, 0 })); var execOrder = new IRequestFilterBase[attributes.Length]; var i = 0; for (; i < attributes.Length && attributes[i].Priority < 0; i++) { execOrder[i] = attributes[i]; Console.WriteLine(attributes[i].Priority); } Console.WriteLine("break;"); for (; i < attributes.Length; i++) { execOrder[i] = attributes[i]; Console.WriteLine(attributes[i].Priority); } var execOrderPriorities = execOrder.ToList().ConvertAll(x => x.Priority); Assert.That(execOrderPriorities, Is.EquivalentTo(new[] { int.MinValue, -100, -90, -80, 0, 0 })); }
private static IRequestFilterBase[] ShallowCopy(this IRequestFilterBase[] filters) { var to = new IRequestFilterBase[filters.Length]; for (var i = 0; i < filters.Length; i++) { to[i] = filters[i].Copy(); } return(to); }