Exemple #1
0
            internal override AttributeBinding Evaluate(AjaxPage page)
            {
                IEnumerable <KeyValuePair <string, object> > arguments = page.Context.Variables.Concat(new KeyValuePair <string, object>[] {
                    new KeyValuePair <string, object>("$dataItem", page.Context.DataItem),
                    new KeyValuePair <string, object>("$index", page.Context.Index),
                    new KeyValuePair <string, object>("$context", page.Context),
                    new KeyValuePair <string, object>("$id", (Func <string, string>)(id => page.Context.GetInstanceId(id))),
                });

                if (!isValid)
                {
                    return(new AttributeBinding(Attribute, BindingResult.Invalid));
                }
                else
                {
                    if (script == null)
                    {
                        lock (this)
                        {
                            if (script == null)
                            {
                                script = new JavaScript.ScriptFunction(Page.ScriptEngineFactory, arguments.Select(a => a.Key), Path);
                            }
                        }
                    }

                    try
                    {
                        return(new AttributeBinding(Attribute, new BindingResult()
                        {
                            Value = script.Evaluate(arguments.Select(a => a.Value), Page.ScriptMarshaller), IsValid = true
                        }));
                    }
                    catch
                    {
                        isValid = false;
                        return(new AttributeBinding(Attribute, BindingResult.Invalid));
                    }
                }
            }
Exemple #2
0
            internal override AttributeBinding Evaluate(AjaxPage page)
            {
                IEnumerable<KeyValuePair<string, object>> arguments = page.Context.Variables.Concat( new KeyValuePair<string, object>[] {
                    new KeyValuePair<string, object>("$dataItem", page.Context.DataItem),
                    new KeyValuePair<string, object>("$index", page.Context.Index),
                    new KeyValuePair<string, object>("$context", page.Context),
                    new KeyValuePair<string, object>("$id", (Func<string, string>)(id => page.Context.GetInstanceId(id))),
                });

                if (!isValid)
                    return new AttributeBinding(Attribute, BindingResult.Invalid);
                else
                {
                    if (script == null)
                    {
                        lock (this)
                        {
                            if (script == null)
                                script = new JavaScript.ScriptFunction(Page.ScriptEngineFactory, arguments.Select(a => a.Key), Path);
                        }
                    }

                    try
                    {
                        return new AttributeBinding(Attribute, new BindingResult() { Value = script.Evaluate(arguments.Select(a => a.Value), Page.ScriptMarshaller), IsValid = true });
                    }
                    catch
                    {
                        isValid = false;
                        return new AttributeBinding(Attribute, BindingResult.Invalid);
                    }
                }
            }