public IntegrationMessageFilterContext(IIntegrationMessage message, MessageMetaData meta, IEndpoint endpoint, FilterDirection direction, MessageTypeProperties props) { Message = message; MessageMetaData = meta; Endpoint = endpoint; Direction = direction; Props = props; }
public void Filter(string message, IChatWindow window, FilterDirection direction, Action <string> onAccept) { var filteredMessage = new StringBuilder(message); if (Filter(filteredMessage, window, direction)) { onAccept(filteredMessage.ToString()); } }
public bool Filter(StringBuilder message, IChatWindow window, FilterDirection direction) { foreach (IMessageFilter filter in this.Where(f => (f.Direction & direction) == direction)) { if (!filter.Filter(message, window)) { return(false); } } return(true); }
public static ColumnSchemaCollection Filter(this ColumnSchemaCollection columns, FilterRules rules, FilterDirection direction) { var matches = (from column in columns where !column.IsPrimaryKeyMember || !rules.HasFlag(FilterRules.IsPrimaryKey) where !column.IsIdentityColumn() || !rules.HasFlag(FilterRules.IsIdentity) where !column.IsIdentifierColumn() || !rules.HasFlag(FilterRules.IsIdentifier) where !column.IsDeleteFlag() || !rules.HasFlag(FilterRules.IsDeleteFlag) where !column.IsVersionDateColumn() || !rules.HasFlag(FilterRules.IsDeleteFlag) where !column.IsVersionUserColumn() || !rules.HasFlag(FilterRules.IsVersionUser) where !column.HasDefaultValue() || !rules.HasFlag(FilterRules.HasDefaultValue) select column).ToList(); return (direction == FilterDirection.Include) ? matches.ToColumnSchemaCollection() : columns.Where(column => !matches.Contains(column)).ToList().ToColumnSchemaCollection(); }
public FilterAttribute(Type filterInfo, FilterDirection direction = FilterDirection.Allow) { _filterInfo = filterInfo; if (!_filterInfo.GetInterfaces().Contains(typeof(Filter))) { throw new ArgumentException("Invalid argument to FilterAttribute"); } _filterMethodInfo = _filterInfo.GetMethod("Filter", BindingFlags.Public | BindingFlags.Instance); if (_filterMethodInfo == null) { throw new ArgumentException("Filter must have a Filter method"); } if (_filterMethodInfo.ReturnType != typeof(bool)) { throw new ArgumentException("Filter method must return bool"); } var constructors = _filterInfo.GetConstructors(); if (constructors.Length != 1) { throw new ArgumentException("Filter type is supposed to have a single constructor"); } var constructor = constructors.First(); if (constructor.GetParameters().Count() != 0) { throw new ArgumentException("Filter object is not supposed to have arguments"); } _filterObject = (Filter)constructor.Invoke(new object[0]); _direction = direction; }
public void FilterBackward() { int j, i, n = FilterSteps.Length; int nstvec = FilterSteps[0].StateVectorLength; int nmsvec = FilterSteps[0].MeasurementsVectorLength; if (n <= 0 || nstvec <= 0 || nmsvec <= 0) { return; } //for (i=n; i>=0; i--) for (i = n - 2; i >= 0; i--) { // predict the covariance of estimate double[,] Cmm = Matrices.Product(FilterSteps[i + 1].BackwardPropagator, FilterSteps[i + 1].FiltStateCovariance); double[,] Amm = Matrices.Transpose(FilterSteps[i + 1].BackwardPropagator); Cmm = Matrices.Product(Cmm, Amm); Cmm = Matrices.Sum(Cmm, FilterSteps[i + 1].NoiseCovariance); FilterSteps[i].SetPredictedStateCovariance(Cmm); // calculate kalman gain matrix double[,] Cnm = Matrices.Product(FilterSteps[i].StateMeasure, FilterSteps[i].PredStateCovariance); double[,] Bmn = Matrices.Transpose(FilterSteps[i].StateMeasure); double[,] Cnn = Matrices.Product(Cnm, Bmn); Cnn = Matrices.Sum(Cnn, FilterSteps[i].MeasCovariance); double[,] Cnninv = Matrices.InvertMatrix(Cnn); double[,] Cmn = Matrices.Product(FilterSteps[i].PredStateCovariance, Bmn); FilterSteps[i].SetKalmanGain(Matrices.Product(Cmn, Cnninv)); // predict and filter state vector if (i > 0) { // if there is a measurement double[] xm = Matrices.Product(FilterSteps[i + 1].BackwardPropagator, FilterSteps[i + 1].StateVec); FilterSteps[i].SetPredStateVec(xm); double[] ym = new double[xm.Length]; for (j = 0; j < xm.Length; j++) { ym[j] = xm[j]; } double[] xn = Matrices.Product(FilterSteps[i].StateMeasure, xm); xn = Matrices.Subtract(FilterSteps[i].MeasureVec, xn); xm = Matrices.Product(FilterSteps[i].KalmanGain, xn); xm = Matrices.Sum(xm, ym); FilterSteps[i].SetStateVec(xm); } else { // no measurement (i.e. final iteration) FilterSteps[i].SetStateVec(Matrices.Product(FilterSteps[i + 1].BackwardPropagator, FilterSteps[i + 1].StateVec)); } // filter covariance matrix Cmm = Matrices.Product(FilterSteps[i].KalmanGain, FilterSteps[i].StateMeasure); double[,] Bmm = Matrices.Identity(nstvec); Bmm = Matrices.Subtract(Bmm, Cmm); Bmm = Matrices.Product(Bmm, FilterSteps[i].PredStateCovariance); FilterSteps[i].SetFiltStateCovariance(Bmm); //Quality checks on filtering progress if (i <= n) { // calculate filtered residual double[] zn = Matrices.Product(FilterSteps[i].StateMeasure, FilterSteps[i].StateVec); zn = Matrices.Subtract(FilterSteps[i].MeasureVec, zn); FilterSteps[i].SetResidualVec(zn); // calculate residual covariance matrix Cnn = Matrices.Product(FilterSteps[i].StateMeasure, FilterSteps[i].KalmanGain); double[,] Bnn = Matrices.Identity(nmsvec); Bnn = Matrices.Subtract(Bnn, Cnn); Bnn = Matrices.Product(Bnn, FilterSteps[i].MeasCovariance); FilterSteps[i].SetResidualMat(Bnn); // calculate chi-squared double[,] Dnn = Matrices.InvertMatrix(FilterSteps[i].ResidualMat); zn = Matrices.Product(Dnn, FilterSteps[i].ResidualVec); FilterSteps[i].SetChiSquared(Matrices.ScalarProduct(FilterSteps[i].ResidualVec, zn)); } } LastFilter = FilterDirection.Forward; }
public static ColumnSchemaCollection Filter(this ColumnSchemaCollection columns, FilterRules rules, FilterDirection direction) { var matches = (from column in columns where !column.IsPrimaryKeyMember || !rules.HasFlag(FilterRules.IsPrimaryKey) where !column.IsIdentityColumn() || !rules.HasFlag(FilterRules.IsIdentity) where !column.IsIdentifierColumn() || !rules.HasFlag(FilterRules.IsIdentifier) where !column.IsDeleteFlag() || !rules.HasFlag(FilterRules.IsDeleteFlag) where !column.IsVersionDateColumn() || !rules.HasFlag(FilterRules.IsDeleteFlag) where !column.IsVersionUserColumn() || !rules.HasFlag(FilterRules.IsVersionUser) where !column.HasDefaultValue() || !rules.HasFlag(FilterRules.HasDefaultValue) select column).ToList(); return((direction == FilterDirection.Include) ? matches.ToColumnSchemaCollection() : columns.Where(column => !matches.Contains(column)).ToList().ToColumnSchemaCollection()); }
public TransportMessageFilterContext(TransportMessage message, IEndpoint endpoint, FilterDirection direction) { TransportMessage = message; Endpoint = endpoint; Direction = direction; }