Do not repeatedly evaluate `ModelMetadata.Properties` enumeration

- supports useful property updates of `ModelMetadata` instances in the collection
- provide a controllable ordering using the `Order` value
- part of #964
This commit is contained in:
dougbu 2014-08-12 21:07:43 -07:00
parent 53432e1483
commit c0179f74cc
1 changed files with 4 additions and 1 deletions

View File

@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Linq;
using Microsoft.AspNet.Mvc.ModelBinding.Internal;
@ -139,8 +140,10 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
{
if (_properties == null)
{
_properties = Provider.GetMetadataForProperties(Model, RealModelType);
var properties = Provider.GetMetadataForProperties(Model, RealModelType);
_properties = properties.OrderBy(m => m.Order).ToList();
}
return _properties;
}
}