public void GivenIsACustomListProcessorWith(string processorKey, string elementProcessorKey) { var elementProcessor = _scenario.GetEx <IValueProcessor>(elementProcessorKey); var factory = new CustomListProcessorFactory(_scenario); ICollectionProcessor processor = factory.Create(elementProcessor); _scenario.Set(processor, processorKey); }
public void Initialise() { List <string> unwantedChars = new List <string>(); unwantedChars.Add("4"); unwantedChars.Add("_"); stringProcessor = new StringProcessor(unwantedChars); collectionProcessor = new StringCollectionProcessor(stringProcessor); // var inputString = "AAAc91%cWwWkLq$1ci3_848v3d__K"; }
private void InvalidateProcessors() { _locationProcessor = new LocationProcessor(_deviceInfo, _user, _httpRequestProcessor, _logger); _collectionProcessor = new CollectionProcessor(_deviceInfo, _user, _httpRequestProcessor, _logger); _mediaProcessor = new MediaProcessor(_deviceInfo, _user, _httpRequestProcessor, _logger); _userProcessor = new UserProcessor(_deviceInfo, _user, _httpRequestProcessor, _logger); _storyProcessor = new StoryProcessor(_deviceInfo, _user, _httpRequestProcessor, _logger); _commentProcessor = new CommentProcessor(_deviceInfo, _user, _httpRequestProcessor, _logger); _profileProcessor = new UserProfileProcessor(_deviceInfo, _user, _httpRequestProcessor, _logger); _messagingProcessor = new MessagingProcessor(_deviceInfo, _user, _httpRequestProcessor, _logger); _feedProcessor = new FeedProcessor(_deviceInfo, _user, _httpRequestProcessor, _logger); }
/// <summary> /// Returns node's value for the given context. /// </summary> /// <param name="context">Context to evaluate expressions against.</param> /// <param name="evalContext">Current expression evaluation context.</param> /// <returns>Node's value.</returns> protected override object Get(object context, EvaluationContext evalContext) { string methodName = this.getText(); object[] argValues = ResolveArguments(evalContext); ICollectionProcessor localCollectionProcessor = null; IMethodCallProcessor methodCallProcessor = null; // resolve method, if necessary lock (this) { // check if it is a collection and the methodname denotes a collection processor if ((context == null || context is ICollection)) { // predefined collection processor? localCollectionProcessor = (ICollectionProcessor)collectionProcessorMap[methodName]; // user-defined collection processor? if (localCollectionProcessor == null && evalContext.Variables != null) { object temp; evalContext.Variables.TryGetValue(methodName, out temp); localCollectionProcessor = temp as ICollectionProcessor; } } // try extension methods methodCallProcessor = (IMethodCallProcessor)extensionMethodProcessorMap[methodName]; { // user-defined extension method processor? if (methodCallProcessor == null && evalContext.Variables != null) { object temp; evalContext.Variables.TryGetValue(methodName, out temp); methodCallProcessor = temp as IMethodCallProcessor; } } // try instance method if (context != null) { // calculate checksum, if the cached method matches the current context if (initialized) { int calculatedHash = CalculateMethodHash(context.GetType(), argValues); initialized = (calculatedHash == cachedInstanceMethodHash); } if (!initialized) { Initialize(methodName, argValues, context); initialized = true; } } } if (localCollectionProcessor != null) { return(localCollectionProcessor.Process((ICollection)context, argValues)); } else if (methodCallProcessor != null) { return(methodCallProcessor.Process(context, argValues)); } else if (cachedInstanceMethod != null) { object[] paramValues = (cachedIsParamArray) ? ReflectionUtils.PackageParamArray(argValues, argumentCount, paramArrayType) : argValues; return(cachedInstanceMethod.Invoke(context, paramValues)); } else { throw new ArgumentException(string.Format("Method '{0}' with the specified number and types of arguments does not exist.", methodName)); } }