public void ExpressionNodeCompilationResultCollectionToStringTest()
        {
            var items = new ExpressionNodeCompilationResultCollection();
            items.Add(new ExpressionNodeCompilationResult("Field1", "Value1"));
            items.Add(new ExpressionNodeCompilationResult("Field2", "Value2"));

            Assert.AreEqual("Field1 - Value1" + Environment.NewLine + "Field2 - Value2" + Environment.NewLine, items.ToString());
        }
        public void ExpressionNodeCompilationResultCollectionIndexerTest()
        {
            var items = new ExpressionNodeCompilationResultCollection();
            items.Add(new ExpressionNodeCompilationResult("Field1", "Value1"));
            items.Add(new ExpressionNodeCompilationResult("Field2", "Value2"));

            Assert.AreEqual("Field1", items["Field1"].FieldName);
            Assert.AreEqual("foo", items["foo"].FieldName);
        }
        public void ExpressionNodeCompilationResultCollectionContainsKeyTest()
        {
            var items = new ExpressionNodeCompilationResultCollection();
            items.Add(new ExpressionNodeCompilationResult("Field1", "Value1"));
            items.Add(new ExpressionNodeCompilationResult("Field2", "Value2"));

            Assert.AreEqual(true, items.ContainsKey("Field1"));
            Assert.AreEqual(false, items.ContainsKey("foo"));
        }
Esempio n. 4
0
        public ExpressionNodeCompilationResultCollection Execute(string xmlExpression, object itemContext, ExpressionOwner expressionOwner, IList<ExpressionFieldIntermediateAssistant> fieldsIntermediateList)
        {
#if !SILVERLIGHT

            var filter = new Dictionary<string, string>
                {
                    { "this", "context" }
                };

            if (fieldsIntermediateList != null)
            {
                filter.Add("Utils.CurrentUserName", "((dynamic)context).CurrentUserName");
                filter.Add("Utils.CurrentUserFullName", "((dynamic)context).CurrentUserFullName");
                filter.Add("Utils.CurrentUserPersonId", "((dynamic)context).CurrentUserPersonId");
                filter.Add("Utils.CurrentUserEmailAddress", "((dynamic)context).CurrentUserEmailAddress");
                filter.Add("Utils.CurrentUserFirstName", "((dynamic)context).CurrentUserFirstName");
                filter.Add("Utils.CurrentUserLastName", "((dynamic)context).CurrentUserLastName");
                filter.Add("Utils.CurrentUserBusinessUnitId", "((dynamic)context).CurrentUserBusinessUnitId");
                filter.Add("Utils.CurrentUserBusinessUnit", "((dynamic)context).CurrentUserBusinessUnit");
                filter.Add("Utils.CurrentUserClientIP", "((dynamic)context).CurrentUserClientIP");
                filter.Add("Utils.CurrentUserDeviceName", "((dynamic)context).CurrentUserDeviceName");
                filter.Add("Utils.CurrentUserRolesList", "((dynamic)context).CurrentUserRolesList");
                filter.Add("Utils.CurrentUserLocale", "((dynamic)context).CurrentUserLocale");
            }

            var result = new ExpressionNodeCompilationResultCollection();

            if (expressionOwner != ExpressionOwner.Trigger)
            {
                var sharpCode = PrepareScriptFromXml(xmlExpression, filter);
                var value = BuildAndExecute(xmlExpression, itemContext, fieldsIntermediateList,  sharpCode);
                result.Add(value);
                return result;
            }

            var destinations = PrepareScriptForMultipleDestinations(xmlExpression, new object());
            
            foreach (var destination in destinations)
            {
                var value = BuildAndExecute(xmlExpression, itemContext, fieldsIntermediateList, destination.Value);
                result.Add(value);
            }

            return result;

#else
            return null;
#endif
        }