Exemple #1
0
        /// <inheritdoc/>
        protected override void PerformExecute(IModel model, IPathNode item)
        {
            ArgumentValidator.EnsureArgumentNotNull(item, "item");
            var node = (Node)item;

            foreach (var pair in properties)
            {
                node.SetProperty(pair.Key, PathNodeReference.Resolve(model, pair.Value));
            }
        }
        /// <summary>
        /// Tries to invoke node constructor with the specified set of arguments.
        /// </summary>
        /// <param name="model">The model to pass as the first argument.</param>
        /// <param name="arguments">The other arguments.</param>
        /// <returns>Created node, if the constructor was successfully bound;
        /// otherwise, <see langword="null" />.</returns>
        protected Node TryConstructor(IModel model, params object[] arguments)
        {
            if (parameters != null)
            {
                arguments = arguments.Concat(parameters.Select(p => PathNodeReference.Resolve(model, p))).ToArray();
            }
            var argTypes = arguments.Select(a => a.GetType()).ToArray();
            var ci       = type.GetConstructor(argTypes);

            if (ci == null)
            {
                return(null);
            }
            return((Node)ci.Invoke(arguments));
        }