public string Evaluate(IDisplayTemplateEvaluationContext context)
		{
			if (!(context.ContextObject is Dictionary<string, object>))
				throw new ArgumentException("context.ContextObject must be a Dictionary");

			string retVal = string.Empty;

			var query = GetTemplateMappings();

			//filter only active
			query = query.Where(t => t.IsActive);

			// sort content by type and priority
			query = query.OrderByDescending(x => x.Priority).ThenByDescending(x => x.Name);
									
			query = query.Where(x => x.TargetType == (int) context.TargetType);
						
			//Evaluate query
			var current = query.ToArray();

			//Evaluate condition expression
			Func<string, bool> conditionPredicate = (x) =>
			{
				var condition = DeserializeExpression<Func<IEvaluationContext, bool>>(x);
				return condition(context);
			};

			current = current.Where(x => string.IsNullOrEmpty(x.PredicateSerialized) || conditionPredicate(x.PredicateSerialized)).ToArray();

			if (current.Any())
				retVal = current.First().DisplayTemplate;

			return retVal;
		}
        public string Evaluate(IDisplayTemplateEvaluationContext context)
        {
            if (!(context.ContextObject is Dictionary <string, object>))
            {
                throw new ArgumentException("context.ContextObject must be a Dictionary");
            }

            string retVal = string.Empty;

            var query = GetTemplateMappings();

            //filter only active
            query = query.Where(t => t.IsActive);

            // sort content by type and priority
            query = query.OrderByDescending(x => x.Priority).ThenByDescending(x => x.Name);

            query = query.Where(x => x.TargetType == (int)context.TargetType);

            //Evaluate query
            var current = query.ToArray();

            //Evaluate condition expression
            Func <string, bool> conditionPredicate = (x) =>
            {
                var condition = DeserializeExpression <Func <IEvaluationContext, bool> >(x);
                return(condition(context));
            };

            current = current.Where(x => string.IsNullOrEmpty(x.PredicateSerialized) || conditionPredicate(x.PredicateSerialized)).ToArray();

            if (current.Any())
            {
                retVal = current.First().DisplayTemplate;
            }

            return(retVal);
        }