private void ProvideConstraint(ActionConstraintItem item, IServiceProvider services) { // Don't overwrite anything that was done by a previous provider. if (item.Constraint != null) { return; } var constraint = item.Metadata as IActionConstraint; if (constraint != null) { item.Constraint = constraint; return; } var factory = item.Metadata as IActionConstraintFactory; if (factory != null) { item.Constraint = factory.CreateInstance(services); return; } }