예제 #1
0
    public void ThrowIfInvalidFileterTypeAllWith_fileterTypesにデフォルトコンストラクターがない型が含まれる場合はfalseが返る()
    {
        Action act = () => FilterSupport.ThrowIfInvalidFilterTypeAllWith(
            new Type[] { typeof(Filter1), typeof(Filter3), typeof(Filter2) });

        act.Should().Throw <ArgumentException>();
    }
예제 #2
0
    public AsServiceAttribute(string path, params Type[] filterTypes)
    {
        if (string.IsNullOrWhiteSpace(path))
        {
            throw new ArgumentException(SR.Argument_CanNotNullOrWhitespace(nameof(path)));
        }

        Path = path;

        if (filterTypes is null)
        {
            throw new ArgumentNullException(nameof(filterTypes));
        }
        FilterSupport.ThrowIfInvalidFilterTypeAllWith(filterTypes);

        FilterTypes = new ReadOnlyCollection <Type>(filterTypes);
    }
예제 #3
0
    public static IEnumerable <MediatorServiceDescription> Create(Type serviceType, params Type[] filterTypes)
    {
        if (serviceType is null)
        {
            throw new ArgumentNullException(nameof(serviceType));
        }
        FilterSupport.ThrowIfInvalidFilterTypeAllWith(filterTypes);

        if (!CanServicalize(serviceType))
        {
            throw new ArgumentException(SR.Argument_CanNotServicalize(nameof(serviceType)));
        }
        var attrs = serviceType.GetAttributes <AsServiceAttribute>(true);

        return(attrs.Select(attr =>
        {
            var attrFilters = attr.FilterTypes;
            var filters = filterTypes.Concat(attrFilters).ToList();
            return new MediatorServiceDescription(attr.Path, serviceType, filters);
        }).ToList());
    }
예제 #4
0
 public void ThrowIfInvalidFileterTypeAllWith_fileterTypesが全てIFilterを継承してデフォルトコンストラクターがある型の場合はtrueが返る()
 {
     FilterSupport.ThrowIfInvalidFilterTypeAllWith(
         new Type[] { typeof(Filter1), typeof(Filter2) });
 }
예제 #5
0
    public void ThrowIfInvalidFileterTypeAllWith_fileterTypesがnullの場合は例外が発生する()
    {
        Action act = () => FilterSupport.ThrowIfInvalidFilterTypeAllWith(null);

        act.Should().Throw <ArgumentNullException>();
    }