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

            if (item.Metadata is IActionConstraint constraint)
            {
                item.Constraint = constraint;
                item.IsReusable = true;
                return;
            }

            if (item.Metadata is IActionConstraintFactory factory)
            {
                item.Constraint = factory.CreateInstance(services);
                item.IsReusable = factory.IsReusable;
                return;
            }
        }
Ejemplo n.º 2
0
        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;
                item.IsReusable = true;
                return;
            }

            var factory = item.Metadata as IActionConstraintFactory;
            if (factory != null)
            {
                item.Constraint = factory.CreateInstance(services);
                item.IsReusable = factory.IsReusable;
                return;
            }
        }