/// <summary>
 /// Adds an <see cref="IViewEngine"/> to a descriptor collection.
 /// </summary>
 /// <param name="descriptors">A list of ViewEngineDescriptors</param>
 /// <param name="viewEngine">An <see cref="IViewEngine"/> instance.</param>
 /// <returns>ViewEngineDescriptor representing the added instance.</returns>
 public static ViewEngineDescriptor Add([NotNull] this IList<ViewEngineDescriptor> descriptors,
                                        [NotNull] IViewEngine viewEngine)
 {
     var descriptor = new ViewEngineDescriptor(viewEngine);
     descriptors.Add(descriptor);
     return descriptor;
 }
        /// <summary>
        /// Adds an <see cref="IViewEngine"/> to a descriptor collection.
        /// </summary>
        /// <param name="descriptors">A list of ViewEngineDescriptors</param>
        /// <param name="viewEngine">An <see cref="IViewEngine"/> instance.</param>
        /// <returns>ViewEngineDescriptor representing the added instance.</returns>
        public static ViewEngineDescriptor Add([NotNull] this IList <ViewEngineDescriptor> descriptors,
                                               [NotNull] IViewEngine viewEngine)
        {
            var descriptor = new ViewEngineDescriptor(viewEngine);

            descriptors.Add(descriptor);
            return(descriptor);
        }
        /// <summary>
        /// Insert an <see cref="IViewEngine"/> to a descriptor collection.
        /// </summary>
        /// <param name="descriptors">A list of ViewEngineDescriptors</param>
        /// <param name="viewEngine">An <see cref="IViewEngine"/> instance.</param>
        /// <returns>ViewEngineDescriptor representing the added instance.</returns>
        public static ViewEngineDescriptor Insert([NotNull] this IList<ViewEngineDescriptor> descriptors,
                                                   int index,
                                                   [NotNull] IViewEngine viewEngine)
        {
            if (index < 0 || index > descriptors.Count)
            {
                throw new ArgumentOutOfRangeException("index");
            }

            var descriptor = new ViewEngineDescriptor(viewEngine);
            descriptors.Insert(index, descriptor);
            return descriptor;
        }
        /// <summary>
        /// Insert an <see cref="IViewEngine"/> to a descriptor collection.
        /// </summary>
        /// <param name="descriptors">A list of ViewEngineDescriptors</param>
        /// <param name="viewEngine">An <see cref="IViewEngine"/> instance.</param>
        /// <returns>ViewEngineDescriptor representing the added instance.</returns>
        public static ViewEngineDescriptor Insert([NotNull] this IList <ViewEngineDescriptor> descriptors,
                                                  int index,
                                                  [NotNull] IViewEngine viewEngine)
        {
            if (index < 0 || index > descriptors.Count)
            {
                throw new ArgumentOutOfRangeException("index");
            }

            var descriptor = new ViewEngineDescriptor(viewEngine);

            descriptors.Insert(index, descriptor);
            return(descriptor);
        }