Пример #1
0
        /// <summary>
        /// Creates a <see cref="XElement"/> for this command.
        /// </summary>
        /// <param name="executor">Executor for <see cref="ActionResult"/>s.</param>
        /// <returns>A <see cref="XElement"/> for this command.</returns>
        internal override XElement CreateCommandXElement(ActionResultExecutor executor)
        {
            if (executor == null)
            {
                throw new ArgumentNullException("executor");
            }

            var script = _script ?? executor.Execute(_javaScriptResult);

            return(new XElement("eval", script));
        }
        public void Execute_NullActionResult_ThrowsArgumentNullException()
        {
            var controllerContext = Substitute.For<ControllerContext>();
              controllerContext.RouteData = Substitute.For<RouteData>();
              controllerContext.Controller = Substitute.For<Controller>();
              var executor = new ActionResultExecutor(controllerContext);

              Action action = () => executor.Execute(null);

              action.ShouldThrow<ArgumentNullException>();
        }
Пример #3
0
        /// <summary>
        /// Creates a <see cref="XElement"/> for this command.
        /// </summary>
        /// <param name="executor">Executor for <see cref="ActionResult"/>s.</param>
        /// <returns>A <see cref="XElement"/> for this command.</returns>
        internal override XElement CreateCommandXElement(ActionResultExecutor executor)
        {
            if (executor == null)
            {
                throw new ArgumentNullException("executor");
            }

            var xElement = new XElement(_command,
                                        new XAttribute("select", _selector),
                                        _arguments.Where(x => x != null).Select((x, i) => new XAttribute("arg" + (i + 1), x)));

            return(xElement);
        }
Пример #4
0
        /// <summary>
        /// Creates a <see cref="XElement"/> for this command.
        /// </summary>
        /// <param name="executor">Executor for <see cref="ActionResult"/>s.</param>
        /// <returns>A <see cref="XElement"/> for this command.</returns>
        internal override XElement CreateCommandXElement(ActionResultExecutor executor)
        {
            if (executor == null)
            {
                throw new ArgumentNullException("executor");
            }

            // Use the HTML content or execute the PartialViewResult.
            var content = Html ?? executor.Execute(Partial);

            return(new XElement(_command,
                                new XAttribute("select", Selector),
                                new XCData(content)));
        }
Пример #5
0
        /// <summary>
        /// Processes this <see cref="TaconiteResult"/>, writing the resulting Taconite
        /// document to the response.
        /// </summary>
        /// <param name="context">The context in which the result is executed.</param>
        public override void ExecuteResult(ControllerContext context)
        {
            if (context == null)
            throw new ArgumentNullException("context");

              // Create an ActionResultExecutor that commands can use to execute other ActionResults.
              var executor = new ActionResultExecutor(context);

              // Create the document root element containing the command elements for the commands.
              var rootElement = new XElement("taconite",
                                     Commands.Select(c => c.CreateCommandXElement(executor)));

              // Write the resulting Taconite document XML to the response.
              context.HttpContext.Response.ContentType = "text/xml";
              context.HttpContext.Response.Write(rootElement);
        }
Пример #6
0
        /// <summary>
        /// Processes this <see cref="TaconiteResult"/>, writing the resulting Taconite
        /// document to the response.
        /// </summary>
        /// <param name="context">The context in which the result is executed.</param>
        public override void ExecuteResult(ControllerContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            // Create an ActionResultExecutor that commands can use to execute other ActionResults.
            var executor = new ActionResultExecutor(context);

            // Create the document root element containing the command elements for the commands.
            var rootElement = new XElement("taconite",
                                           Commands.Select(c => c.CreateCommandXElement(executor)));

            // Write the resulting Taconite document XML to the response.
            context.HttpContext.Response.ContentType = "text/xml";
            context.HttpContext.Response.Write(rootElement);
        }
Пример #7
0
 /// <summary>
 /// Creates a <see cref="XElement"/> for this command.
 /// </summary>
 /// <param name="executor">Executor for <see cref="ActionResult"/>s.</param>
 /// <returns>A <see cref="XElement"/> for this command.</returns>
 internal abstract XElement CreateCommandXElement(ActionResultExecutor executor);
Пример #8
0
        /// <summary>
        /// Creates a <see cref="XElement"/> for this command.
        /// </summary>
        /// <param name="executor">Executor for <see cref="ActionResult"/>s.</param>
        /// <returns>A <see cref="XElement"/> for this command.</returns>
        internal override XElement CreateCommandXElement(ActionResultExecutor executor)
        {
            if (executor == null)
            throw new ArgumentNullException("executor");

              // Use the HTML content or execute the PartialViewResult.
              var content = Html ?? executor.Execute(Partial);

              return new XElement(_command,
                          new XAttribute("select", Selector),
                          new XCData(content));
        }
Пример #9
0
        /// <summary>
        /// Creates a <see cref="XElement"/> for this command.
        /// </summary>
        /// <param name="executor">Executor for <see cref="ActionResult"/>s.</param>
        /// <returns>A <see cref="XElement"/> for this command.</returns>
        internal override XElement CreateCommandXElement(ActionResultExecutor executor)
        {
            if (executor == null)
            throw new ArgumentNullException("executor");

              var script = _script ?? executor.Execute(_javaScriptResult);

              return new XElement("eval", script);
        }
Пример #10
0
 /// <summary>
 /// Creates a <see cref="XElement"/> for this command.
 /// </summary>
 /// <param name="executor">Executor for <see cref="ActionResult"/>s.</param>
 /// <returns>A <see cref="XElement"/> for this command.</returns>
 internal abstract XElement CreateCommandXElement(ActionResultExecutor executor);
Пример #11
0
        /// <summary>
        /// Creates a <see cref="XElement"/> for this command.
        /// </summary>
        /// <param name="executor">Executor for <see cref="ActionResult"/>s.</param>
        /// <returns>A <see cref="XElement"/> for this command.</returns>
        internal override XElement CreateCommandXElement(ActionResultExecutor executor)
        {
            if (executor == null)
            throw new ArgumentNullException("executor");

              var xElement = new XElement(_command,
                                  new XAttribute("select", _selector),
                                  _arguments.Where(x => x != null).Select((x, i) => new XAttribute("arg" + (i + 1), x)));

              return xElement;
        }