Manos.Mvc.ModelBinder.BuildFieldList C# (CSharp) Method

BuildFieldList() private method

private BuildFieldList ( IModelValueProvider provider, object model ) : string[]
provider IModelValueProvider
model object
return string[]
        string[] BuildFieldList(IModelValueProvider provider, object model)
        {
            string[] fields = null;

            // If an include list was passed, try to get it from the provider
            // The HttpModelValueProvider uses the hidden field generated by the form
            // to build a list of valid fields for binding
            if (IncludeFields == null)
            {
                fields = provider.GetFieldList(model);
            }

            // If an exclude list was specified, apply it now
            if (ExcludeFields != null)
            {
                // If we don't have an include list, start with the full list of properties on the model
                if (fields == null)
                    fields = (from pi in model.GetType().GetProperties() select pi.Name).ToArray();

                // Exclude specified fields
                fields = (from f in fields where !ExcludeFields.Contains(f) select f).ToArray();
            }

            // Return the final field list
            return fields;
        }