public object Resolve(IBuilderContext context) { if (context.CurrentOperation is ConstructorArgumentResolveOperation operation) { var parameter = context.GetConstructorParameter(operation.ParameterName); if (parameter.IsOptional && parameter.HasDefaultValue) { return(parameter.DefaultValue); } else { throw new InvalidOperationException($"Parameter {parameter.Name} of a constructor {operation.ConstructorSignature} does not have a default value."); } } else if (context.CurrentOperation is MethodArgumentResolveOperation methodOperation) { var parameter = context.GetMethodParameter(methodOperation.ParameterName); if (parameter.IsOptional && parameter.HasDefaultValue) { return(parameter.DefaultValue); } else { throw new InvalidOperationException($"Parameter {parameter.Name} of a method {methodOperation.MethodSignature} does not have a default value."); } } else { throw new InvalidOperationException($"DefaultParameterValue is only supported for constructor and method injection."); } }