コード例 #1
0
 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);
 }
コード例 #2
0
        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));
        }
コード例 #3
0
 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);
         }
     }
 }
コード例 #4
0
 //--- Constructor ---
 public DekiScriptDomEvaluationState(DekiScriptEvalContext context, XmlNode parent, DekiScriptEnv env)
 {
     this.Context = context;
     this.Env     = env;
     this.Parent  = parent;
 }
コード例 #5
0
 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());
             }
         }
     }
 }