﻿// Decompiled with JetBrains decompiler
// Type: System.Web.ModelBinding.ComplexModel
// Assembly: System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// MVID: 7E68A73E-4066-4F24-AB0A-F147209F50EC
// Assembly location: C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Web.dll

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime;

namespace System.Web.ModelBinding
{
  /// <summary>
  /// Describes a complex model, using a collection rather than individual properties as the data store.
  /// </summary>
  public class ComplexModel
  {
    /// <summary>
    /// Gets the metadata for the model.
    /// </summary>
    /// 
    /// <returns>
    /// The metadata for the model.
    /// </returns>
    public ModelMetadata ModelMetadata { [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] get; private set; }

    /// <summary>
    /// Gets the metadata for the properties of the model.
    /// </summary>
    /// 
    /// <returns>
    /// The metadata for the properties of the model.
    /// </returns>
    public ReadOnlyCollection<ModelMetadata> PropertyMetadata { [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] get; private set; }

    /// <summary>
    /// Gets a collection that contains entries that correspond to each property for which binding was attempted.
    /// </summary>
    /// 
    /// <returns>
    /// Metadata for model properties for which model binding was attempted.
    /// </returns>
    public IDictionary<ModelMetadata, ComplexModelResult> Results { [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] get; private set; }

    /// <summary>
    /// Initializes a new instance of the <see cref="T:System.Web.ModelBinding.ComplexModel"/> class.
    /// </summary>
    /// <param name="modelMetadata">Metadata for the model.</param><param name="propertyMetadata">Metadata for the properties of the model.</param><exception cref="T:System.ArgumentNullException">The <paramref name="modelMetadata"/> or <paramref name="propertyMetadata"/> parameter is null.</exception>
    public ComplexModel(ModelMetadata modelMetadata, IEnumerable<ModelMetadata> propertyMetadata)
    {
      if (modelMetadata == null)
        throw new ArgumentNullException("modelMetadata");
      if (propertyMetadata == null)
        throw new ArgumentNullException("propertyMetadata");
      this.ModelMetadata = modelMetadata;
      this.PropertyMetadata = new ReadOnlyCollection<ModelMetadata>((IList<ModelMetadata>) Enumerable.ToList<ModelMetadata>(propertyMetadata));
      this.Results = (IDictionary<ModelMetadata, ComplexModelResult>) new Dictionary<ModelMetadata, ComplexModelResult>();
    }
  }
}
