private void EmbedExceptionMessage(DekiScriptDom expr, DekiScriptEnv env, DekiScriptEvalContext context, Exception exception, XmlNode parent) { if (exception is DreamRequestFatalException) { exception.Rethrow(); } context.InsertExceptionMessageBeforeNode(env, parent, null, expr.Location, exception); }
public XDoc Evaluate(DekiScriptDom expr, DekiScriptEvalMode mode, bool fallthrough, DekiScriptEnv env) { DekiScriptEvalContext context = new DekiScriptEvalContext(mode, fallthrough); try { expr.VisitWith(this, new DekiScriptDomEvaluationState(context, context.Document, env)); } catch (DekiScriptDocumentTooLargeException) { // this exception is thrown to unwind the DOM stack; we can safely ignore it } context.MergeContextIntoDocument(context.Document); return(new XDoc(context.Document)); }
private void EvaluateAttribute(DekiScriptDomElement.Attribute expr, DekiScriptEvalContext context, XmlElement element, DekiScriptEnv env) { if (!expr.IsNamespaceDefinition) { try { string name = expr.Name.VisitWith(DekiScriptExpressionEvaluation.Instance, env).AsString(); if (name != null) { name = XmlConvert.EncodeLocalName(name); string value = expr.Value.VisitWith(DekiScriptExpressionEvaluation.Instance, env).AsString(); if (value != null) { element.SetAttribute(name, context.Namespaces.LookupNamespace(expr.Prefix), value); } } } catch (Exception e) { context.InsertExceptionMessageBeforeNode(env, element, null, expr.Location, e); } } }
//--- Constructor --- public DekiScriptDomEvaluationState(DekiScriptEvalContext context, XmlNode parent, DekiScriptEnv env) { this.Context = context; this.Env = env; this.Parent = parent; }
private void EvaluateNamespaceDefinitionAttribute(DekiScriptDomElement.Attribute expr, DekiScriptEvalContext context, DekiScriptEnv env) { if (expr.IsNamespaceDefinition) { DekiScriptLiteral name = expr.Name.VisitWith(DekiScriptExpressionEvaluation.Instance, env); DekiScriptLiteral value = expr.Value.VisitWith(DekiScriptExpressionEvaluation.Instance, env); if (!value.IsNil) { if (string.IsNullOrEmpty(expr.Prefix)) { context.Namespaces.AddNamespace(string.Empty, value.AsString()); } else { context.Namespaces.AddNamespace(XmlConvert.EncodeLocalName(name.AsString() ?? string.Empty), value.AsString()); } } } }