public ConfigFilterChainManager AddFilter(IConfigFilter filter) { // 根据order大小顺序插入 int i = 0; while (i < this.filters.Count) { IConfigFilter currentValue = this.filters[i]; if (currentValue.GetFilterName().Equals(filter.GetFilterName())) { break; } if (filter.GetOrder() >= currentValue.GetOrder() && i < this.filters.Count) { i++; } else { this.filters.Insert(i, filter); break; } } if (i == this.filters.Count) { this.filters.Insert(i, filter); } return(this); }
public ConfigFilterChainManager AddFilter(IConfigFilter filter) { lock (_filters) { int i = 0; while (i < _filters.Count) { var currentValue = _filters[i]; if (currentValue.GetFilterName() == filter.GetFilterName()) { break; } if (filter.GetOrder() >= currentValue.GetOrder() && i < _filters.Count) { i++; } else { _filters.Insert(i, filter); break; } } if (i == _filters.Count) { _filters.Add(filter); } return(this); } }
public void DoFilter(IConfigRequest request, IConfigResponse response) { if (this.currentPosition != this.additionalFilters.Count) { this.currentPosition++; IConfigFilter nextFilter = this.additionalFilters[this.currentPosition - 1]; nextFilter.DoFilter(request, response, this); } }