/// <summary> /// Evaluates the node, using the variables provided in the <paramref name="Variables"/> collection. /// </summary> /// <param name="Arguments">Function arguments.</param> /// <param name="Variables">Variables collection.</param> /// <returns>Result.</returns> public override IElement Evaluate(IElement[] Arguments, Variables Variables) { Uri Url = new Uri(Arguments[0].AssociatedObjectValue?.ToString()); List <KeyValuePair <string, string> > HeaderList = null; if (Arguments.Length > 1) { object Arg1 = Arguments[1].AssociatedObjectValue; if (Arg1 is IDictionary <string, IElement> Headers) { HeaderList = new List <KeyValuePair <string, string> >(); foreach (KeyValuePair <string, IElement> P in Headers) { HeaderList.Add(new KeyValuePair <string, string>(P.Key, P.Value.AssociatedObjectValue?.ToString())); } } else if (Arg1 is string Accept) { HeaderList = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("Accept", Accept) }; } else { throw new ScriptRuntimeException("Invalid second parameter to Get. Should be either an accept string, or an object with protocol-specific headers or options.", this); } } object Result = InternetContent.GetAsync(Url, HeaderList?.ToArray() ?? new KeyValuePair <string, string> [0]).Result; return(new ObjectValue(Result)); }