Esempio n. 1
0
 public RowSingleCellValueEvaluator(
     int targetColumnIndex,
     IValueComparer valueComparer)
 {
     this.targetColumnIndex = targetColumnIndex;
     this.valueComparer     = valueComparer;
 }
Esempio n. 2
0
 public void RegisterValueComparer(IValueComparer valueComparer)
 {
     if (valueComparer.GetType() == typeof(DefaultValueComparer))
       _registeredValueComparers.Add(valueComparer);
     else
       _registeredValueComparers.Insert(0, valueComparer);
 }
Esempio n. 3
0
 public PropertyDiffers(string propertyName, object expected, object actual, IValueComparer comparer)
 {
     this.propertyName = propertyName;
     this.expected     = expected;
     this.actual       = actual;
     this.comparer     = comparer;
 }
Esempio n. 4
0
        public string GetValue(IValueComparer valueComparer, ExecutionContext executionContext,
                               Argument rowArgument, Argument columnArgument)
        {
            Guard.AgainstNull(valueComparer, nameof(valueComparer));
            Guard.AgainstNull(executionContext, nameof(executionContext));
            Guard.AgainstNull(rowArgument, nameof(rowArgument));

            if (ColumnArgumentId.HasValue)
            {
                Guard.AgainstNull(columnArgument, nameof(columnArgument));
            }

            var row = FindConstraint("Row", valueComparer, rowArgument.DataType,
                                     executionContext.GetArgumentValue(RowArgumentId));
            var column = ColumnArgumentId.HasValue
                ? FindConstraint("Column", valueComparer, columnArgument.DataType,
                                 executionContext.GetArgumentValue(ColumnArgumentId.Value))
                : 1;

            var element = _elements.FirstOrDefault(item => item.Row == row && item.Column == column);

            if (element == null)
            {
                throw new InvalidOperationException(
                          $"Could not an element for matrix '{Name}' at intersection of row '{row}' and column '{column}'.");
            }

            return(element.Value);
        }
 public SingleCellValueEvaluatorFactory(
     string name,
     string targetColumnName,
     IValueComparer valueComparer)
 {
     this.Name             = name;
     this.targetColumnName = targetColumnName;
     this.valueComparer    = valueComparer;
 }
Esempio n. 6
0
        /// <summary>
        /// Sets <see cref="IBaseComparer.DefaultValueComparer"/>.
        /// </summary>
        /// <param name="valueComparer">Value Comparer.</param>
        public void SetDefaultComparer(IValueComparer valueComparer)
        {
            if (valueComparer == null)
            {
                throw new ArgumentNullException(nameof(valueComparer));
            }

            DefaultValueComparer = valueComparer;
        }
Esempio n. 7
0
        public void AddComparer(IValueComparer valueComparer, Func <MemberInfo, bool> filter)
        {
            if (filter == null)
            {
                throw new ArgumentNullException(nameof(filter));
            }

            _overridesByMemberFilter.Add(new Tuple <Func <MemberInfo, bool>, IValueComparer>(filter, valueComparer));
        }
Esempio n. 8
0
 public void RegisterValueComparer(IValueComparer valueComparer)
 {
     if (valueComparer.GetType() == typeof(DefaultValueComparer))
     {
         _registeredValueComparers.Add(valueComparer);
     }
     else
     {
         _registeredValueComparers.Insert(0, valueComparer);
     }
 }
Esempio n. 9
0
        public ExecutionService(IValueComparer valueComparer, IFormulaRepository formulaRepository,
                                IArgumentRepository argumentRepository, IMatrixRepository matrixRepository)
        {
            Guard.AgainstNull(valueComparer, nameof(valueComparer));
            Guard.AgainstNull(formulaRepository, nameof(formulaRepository));
            Guard.AgainstNull(argumentRepository, nameof(argumentRepository));
            Guard.AgainstNull(matrixRepository, nameof(matrixRepository));

            _valueComparer      = valueComparer;
            _formulaRepository  = formulaRepository;
            _argumentRepository = argumentRepository;
            _matrixRepository   = matrixRepository;
        }
Esempio n. 10
0
        public void AddComparer(MemberInfo memberInfo, IValueComparer valueComparer)
        {
            if (memberInfo == null)
            {
                throw new ArgumentNullException(nameof(memberInfo));
            }

            if (_overridesByMember.ContainsKey(memberInfo))
            {
                throw new ValueComparerExistsException(memberInfo);
            }

            _overridesByMember[memberInfo] = valueComparer ?? throw new ArgumentNullException(nameof(valueComparer));
        }
Esempio n. 11
0
        private int FindConstraint(string axis, IValueComparer valueComparer, string dataTypeName, string value)
        {
            var constraint = _constraints.FirstOrDefault(item =>
                                                         item.Axis.Equals(axis, StringComparison.InvariantCultureIgnoreCase)
                                                         &&
                                                         valueComparer.IsSatisfiedBy(dataTypeName, item.Value, item.Comparison, value)
                                                         );

            if (constraint == null)
            {
                throw new InvalidOperationException(
                          $"There is no {axis.ToLower()} constraint in matrix '{Name}' where argument '{RowArgumentId}' is satisfied by '{value}'.");
            }

            return(constraint.Index);
        }
Esempio n. 12
0
        /*public void Sort()
         * {
         *  for(var i=0;i<_list.Count-1;i++)
         *      for (var j = i + 1; j < _list.Count; j++)
         *      {
         *          var left = (Book) _list[i];
         *          var right = (Book) _list[j];
         *          if (left.Id > right.Id)
         *          {
         *              //Swap
         *              var temp = left;
         *              _list[i] = _list[j];
         *              _list[j] = temp;
         *          }
         *      }
         * }*/

        public void Sort(IValueComparer <T> comparer)
        {
            for (var i = 0; i < _list.Count - 1; i++)
            {
                for (var j = i + 1; j < _list.Count; j++)
                {
                    var left       = (T)_list[i];
                    var right      = (T)_list[j];
                    var shouldSwap = comparer.Compare(left, right) == 1;
                    if (shouldSwap)
                    {
                        var temp = _list[i];
                        _list[i] = _list[j];
                        _list[j] = temp;
                    }
                }
            }
        }
        private static bool TheValuesDoNotMatch <T>(T instance, TableRow row)
        {
            var expected      = GetTheExpectedValue(row);
            var propertyValue = instance.GetPropertyValue(row.Id());

            var valueComparers = new IValueComparer[]
            {
                new DateTimeValueComparer(),
                new BooleanValueComparer(),
                new GuidValueComparer(),
                new DecimalValueComparer(),
                new DoubleValueComparer(),
                new DefaultValueComparer()
            };

            return(valueComparers
                   .FirstOrDefault(x => x.CanCompare(propertyValue))
                   .TheseValuesAreTheSame(expected, propertyValue) == false);
        }
Esempio n. 14
0
        public TestsController(IServiceBus bus, IDatabaseContextFactory databaseContextFactory,
                               IDataRowMapper dataRowMapper, ITestRepository testRepository, ITestQuery testQuery,
                               IExecutionService executionService, IValueComparer valueComparer)
        {
            Guard.AgainstNull(bus, nameof(bus));
            Guard.AgainstNull(databaseContextFactory, nameof(databaseContextFactory));
            Guard.AgainstNull(dataRowMapper, nameof(dataRowMapper));
            Guard.AgainstNull(testRepository, nameof(testRepository));
            Guard.AgainstNull(testQuery, nameof(testQuery));
            Guard.AgainstNull(executionService, nameof(executionService));
            Guard.AgainstNull(valueComparer, nameof(valueComparer));

            _bus = bus;
            _databaseContextFactory = databaseContextFactory;
            _dataRowMapper          = dataRowMapper;
            _testRepository         = testRepository;
            _testQuery        = testQuery;
            _executionService = executionService;
            _valueComparer    = valueComparer;
        }
Esempio n. 15
0
        public void AddComparer(string memberName, IValueComparer valueComparer,
                                Func <MemberInfo, bool> filter = null)
        {
            if (string.IsNullOrWhiteSpace(memberName))
            {
                throw new ArgumentException($"{nameof(memberName)} cannot be null or empty");
            }

            if (valueComparer == null)
            {
                throw new ArgumentNullException(nameof(valueComparer));
            }

            if (!_overridesByName.ContainsKey(memberName))
            {
                _overridesByName[memberName] = new List <ValueComparerWithFilter>();
            }

            _overridesByName[memberName].Add(new ValueComparerWithFilter(valueComparer, filter));
        }
Esempio n. 16
0
        public void AddComparer(Type type, IValueComparer valueComparer,
                                Func <MemberInfo, bool> filter = null)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            if (valueComparer == null)
            {
                throw new ArgumentNullException(nameof(valueComparer));
            }

            if (!_overridesByType.ContainsKey(type))
            {
                _overridesByType[type] = new List <ValueComparerWithFilter>();
            }

            _overridesByType[type].Add(new ValueComparerWithFilter(valueComparer, filter));
        }
Esempio n. 17
0
 public LambdaParameterWrapper(object val, IValueComparer valueComparer)
 {
     Cmp = valueComparer;
     if (val is LambdaParameterWrapper)
     {
         _Value = ((LambdaParameterWrapper)val).Value;                 // unwrap
     }
     else if (val is object[])
     {
         var objArr = (object[])val;
         for (int i = 0; i < objArr.Length; i++)
         {
             if (objArr[i] is LambdaParameterWrapper)
             {
                 objArr[i] = ((LambdaParameterWrapper)objArr[i]).Value;
             }
         }
         _Value = val;
     }
     else
     {
         _Value = val;
     }
 }
Esempio n. 18
0
 public void UnregisterValueComparer(IValueComparer valueComparer)
 {
     ValueComparers.Unregister(valueComparer);
 }
Esempio n. 19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultValueValueComparer{T}" /> class.
 /// </summary>
 /// <param name="defaultValue">Default value.</param>
 /// <param name="valueComparer">Instance of <see cref="IValueComparer"/> which is used when values are not defaults.</param>
 public DefaultValueValueComparer(T defaultValue, IValueComparer valueComparer)
 {
     _defaultValue     = defaultValue;
     _valueComparer    = valueComparer;
     _typeDefaultValue = default(T);
 }
Esempio n. 20
0
 /// <summary>
 /// Adds Comparer Override by Member.
 /// </summary>
 /// <typeparam name="TProp">Type of the member.</typeparam>
 /// <param name="memberLambda">Lambda to get member.</param>
 /// <param name="valueComparer">Value Comparer.</param>
 public void AddComparerOverride <TProp>(Expression <Func <TProp> > memberLambda, IValueComparer valueComparer)
 {
     OverridesCollection.AddComparer(PropertyHelper.GetMemberInfo(memberLambda), valueComparer);
 }
Esempio n. 21
0
 public void RegisterValueComparer(IValueComparer valueComparer)
 {
     ValueComparers.Register(valueComparer);
 }
Esempio n. 22
0
 public void UnregisterValueComparer(IValueComparer valueComparer)
 {
     _registeredValueComparers.Remove(valueComparer);
 }
Esempio n. 23
0
 public void UnregisterValueComparer(IValueComparer valueComparer)
 {
     _registeredValueComparers.Remove(valueComparer);
 }
Esempio n. 24
0
 public LambdaParser()
 {
     UseCache = true;
     Comparer = ValueComparer.Instance;
 }
Esempio n. 25
0
 public ValueComparerWithFilter(IValueComparer valueComparer, Func <MemberInfo, bool> filter)
 {
     Filter        = filter;
     ValueComparer = valueComparer;
 }
Esempio n. 26
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="dicomServices"></param>
 /// <param name="imgProcFactory">ImageProcessing Factory</param>
 /// <param name="valueComparer"></param>
 /// <param name="fileSystem">Provides extra filesystem capabilities</param>
 /// <param name="processBuilder">Builds exe or java processes and executes them</param>
 /// <param name="capiConfig">CAPI configuration</param>
 /// <param name="log">Log4Net logger</param>
 /// <param name="context">Agent Repository (DbContext) to communicate data with database</param>
 public JobBuilder(IValueComparer valueComparer, DbBroker context)
 {
     _valueComparer = valueComparer;
     _log           = Log.GetLogger();
     _context       = context;
 }
Esempio n. 27
0
 /// <summary>
 /// Adds Comparer Override by Type.
 /// </summary>
 /// <param name="type">Type.</param>
 /// <param name="valueComparer">Value Comparer.</param>
 /// <param name="filter">Value Comparer will be used only if filter(memberInfo) == true. Null by default.</param>
 public void AddComparerOverride(Type type, IValueComparer valueComparer, Func <MemberInfo, bool> filter = null)
 {
     OverridesCollection.AddComparer(type, valueComparer, filter);
 }
Esempio n. 28
0
 /// <summary>
 /// Adds Comparer Override by Type.
 /// </summary>
 /// <typeparam name="TType">Type.</typeparam>
 /// <param name="valueComparer">Value Comparer.</param>
 /// <param name="filter">Value Comparer will be used only if filter(memberInfo) == true. Null by default.</param>
 public void AddComparerOverride <TType>(IValueComparer valueComparer, Func <MemberInfo, bool> filter = null)
 {
     AddComparerOverride(typeof(TType), valueComparer, filter);
 }
Esempio n. 29
0
 /// <summary>
 /// Adds Comparer Override by Member.
 /// </summary>
 /// <param name="memberInfo">Member Info.</param>
 /// <param name="valueComparer">Value Comparer.</param>
 public void AddComparerOverride(MemberInfo memberInfo, IValueComparer valueComparer)
 {
     OverridesCollection.AddComparer(memberInfo, valueComparer);
 }
Esempio n. 30
0
 public LambdaParser(IValueComparer valueComparer) : this()
 {
     Comparer = valueComparer;
 }
 public InvertedValueComparer(IValueComparer valueComparer)
 {
     this.valueComparer = valueComparer;
 }
Esempio n. 32
0
 /// <summary>
 /// Adds Comparer Override by Member name.
 /// </summary>
 /// <param name="memberName">Member Name.</param>
 /// <param name="valueComparer">Value Comparer.</param>
 /// <param name="filter">Value Comparer will be used only if filter(memberInfo) == true. Null by default.</param>
 public void AddComparerOverride(string memberName, IValueComparer valueComparer, Func <MemberInfo, bool> filter = null)
 {
     OverridesCollection.AddComparer(memberName, valueComparer, filter);
 }