// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; using Microsoft.AspNet.Mvc.Rendering; namespace Microsoft.AspNet.Mvc { /// /// Extension methods for adding model binders to a collection. /// public static class ViewEngineDescriptorExtensions { /// /// Adds a type representing a to a descriptor collection. /// /// A list of ViewEngineDescriptors /// Type representing an . /// ViewEngineDescriptor representing the added instance. public static ViewEngineDescriptor Add([NotNull] this IList descriptors, [NotNull] Type viewEngineType) { var descriptor = new ViewEngineDescriptor(viewEngineType); descriptors.Add(descriptor); return descriptor; } /// /// Inserts a type representing a to a descriptor collection. /// /// A list of ViewEngineDescriptors /// Type representing an . /// ViewEngineDescriptor representing the inserted instance. public static ViewEngineDescriptor Insert([NotNull] this IList descriptors, int index, [NotNull] Type viewEngineType) { if (index < 0 || index > descriptors.Count) { throw new ArgumentOutOfRangeException("index"); } var descriptor = new ViewEngineDescriptor(viewEngineType); descriptors.Insert(index, descriptor); return descriptor; } /// /// Adds an to a descriptor collection. /// /// A list of ViewEngineDescriptors /// An instance. /// ViewEngineDescriptor representing the added instance. public static ViewEngineDescriptor Add([NotNull] this IList descriptors, [NotNull] IViewEngine viewEngine) { var descriptor = new ViewEngineDescriptor(viewEngine); descriptors.Add(descriptor); return descriptor; } /// /// Insert an to a descriptor collection. /// /// A list of ViewEngineDescriptors /// An instance. /// ViewEngineDescriptor representing the added instance. public static ViewEngineDescriptor Insert([NotNull] this IList 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; } } }