Exemplo n.º 1
0
 private ArrayHasher(HasherResolver resolver, IConfigurationProvider configuration, IVariable variable)
 {
     _variable          = variable;
     _arrayHashEmitter  = new ArrayHashEmitter(resolver, variable);
     _configuration     = configuration.Get(variable.OwnerType);
     _hasCustomComparer = configuration.HasCustomComparer(variable.VariableType.GetElementType());
 }
        private EnumerablesHasher(HasherResolver resolver, IConfigurationProvider configuration, IVariable variable)
        {
            _resolver      = resolver;
            _configuration = configuration;
            _variable      = variable;

            var variableType = variable.VariableType;

            _elementType = variableType
                           .FindGenericInterface(typeof(IEnumerable <>))
                           .GetGenericArguments()
                           .Single();

            _getEnumeratorMethod = variableType.FindMethod(nameof(IEnumerable.GetEnumerator), Type.EmptyTypes);
            _enumeratorType      = _getEnumeratorMethod.ReturnType;
            _moveNextMethod      = _enumeratorType.FindMethod(nameof(IEnumerator.MoveNext), Type.EmptyTypes);
            _getCurrentMethod    = _enumeratorType.GetPropertyGetter(nameof(IEnumerator.Current));
            _arrayHashEmitter    = new ArrayHashEmitter(resolver, variable);
        }