public CapabilitiesAssertionSpec(string parameterName,
                                  Type parameterType,
                                  object parameterValue,
                                  RequireCapabilityAttribute capabilityAttribute,
                                  string actionName)
 {
     ParameterName       = parameterName ?? throw new ArgumentNullException(nameof(parameterName));
     ParameterType       = parameterType ?? throw new ArgumentNullException(nameof(parameterType));
     ParameterValue      = parameterValue;
     CapabilityAttribute = capabilityAttribute ?? throw new ArgumentNullException(nameof(capabilityAttribute));
     ActionName          = actionName ?? throw new ArgumentNullException(nameof(actionName));
 }
示例#2
0
        Type GetCapabilityType(RequireCapabilityAttribute capabilityAttribute)
        {
            var capabilityType = capabilityAttribute.RequiredCapability.GetType();

            if (!capabilityType.IsEnum)
            {
                throw new ArgumentException($"The capability indicated by {nameof(capabilityAttribute)}.{nameof(RequireCapabilityAttribute.RequiredCapability)} " +
                                            $"must derive from {nameof(Enum)}, but type {capabilityType.Name} does not.",
                                            nameof(capabilityAttribute));
            }

            return(capabilityType);
        }