public void IsValidTIlterTypeAllCore_fileterTypesにデフォルトコンストラクターがない型が含まれる場合はfalseが返る() { var result = FilterSupport.IsValidFilterTypeAllCore( new Type[] { typeof(Filter1), typeof(Filter3), typeof(Filter2) }); result.Should().BeFalse(); }
public void ThrowIfInvalidFileterTypeAllWith_fileterTypesにデフォルトコンストラクターがない型が含まれる場合はfalseが返る() { Action act = () => FilterSupport.ThrowIfInvalidFilterTypeAllWith( new Type[] { typeof(Filter1), typeof(Filter3), typeof(Filter2) }); act.Should().Throw <ArgumentException>(); }
public void IsValidTIlterTypeAllCore_fileterTypesが全てIFilterを継承してデフォルトコンストラクターがある型の場合はtrueが返る() { var result = FilterSupport.IsValidFilterTypeAllCore( new Type[] { typeof(Filter1), typeof(Filter2) }); result.Should().BeTrue(); }
public void IsValidTIlterTypeAllCore_fileterTypesにIFilterを継承していない型が含まれる場合はfalseが返る() { var result = FilterSupport.IsValidFilterTypeAllCore( new Type[] { typeof(Filter1), typeof(string), typeof(Filter2) }); result.Should().BeFalse(); }
public void IsValidTIlterTypeAllCore_fileterTypesにnullが含まれる場合はfalseが返る() { var result = FilterSupport.IsValidFilterTypeAllCore( new Type[] { typeof(Filter1), null, typeof(Filter2) }); result.Should().BeFalse(); }
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); }
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()); }
private static FilterSupport GetFilterSupport(ICollection itemFilter, ICollection targetFilter) { FilterSupport supported = FilterSupport.Supported; int num = 0; int num2 = 0; foreach (ToolboxItemFilterAttribute attribute in itemFilter) { if (supported == FilterSupport.NotSupported) { break; } if (attribute.FilterType == ToolboxItemFilterType.Require) { num++; foreach (object obj2 in targetFilter) { ToolboxItemFilterAttribute attribute2 = obj2 as ToolboxItemFilterAttribute; if ((attribute2 != null) && attribute.Match(attribute2)) { num2++; break; } } } else if (attribute.FilterType == ToolboxItemFilterType.Prevent) { foreach (object obj3 in targetFilter) { ToolboxItemFilterAttribute attribute3 = obj3 as ToolboxItemFilterAttribute; if ((attribute3 != null) && attribute.Match(attribute3)) { supported = FilterSupport.NotSupported; break; } } } else if ((supported != FilterSupport.Custom) && (attribute.FilterType == ToolboxItemFilterType.Custom)) { if (attribute.FilterString.Length == 0) { supported = FilterSupport.Custom; } else { foreach (ToolboxItemFilterAttribute attribute4 in targetFilter) { if (attribute.FilterString.Equals(attribute4.FilterString)) { supported = FilterSupport.Custom; break; } } } } } if (((supported != FilterSupport.NotSupported) && (num > 0)) && (num2 == 0)) { supported = FilterSupport.NotSupported; } if (supported != FilterSupport.NotSupported) { num = 0; num2 = 0; foreach (ToolboxItemFilterAttribute attribute5 in targetFilter) { if (supported == FilterSupport.NotSupported) { break; } if (attribute5.FilterType == ToolboxItemFilterType.Require) { num++; foreach (ToolboxItemFilterAttribute attribute6 in itemFilter) { if (attribute5.Match(attribute6)) { num2++; break; } } } else if (attribute5.FilterType == ToolboxItemFilterType.Prevent) { foreach (ToolboxItemFilterAttribute attribute7 in itemFilter) { if (attribute5.Match(attribute7)) { supported = FilterSupport.NotSupported; break; } } } else if ((supported != FilterSupport.Custom) && (attribute5.FilterType == ToolboxItemFilterType.Custom)) { if (attribute5.FilterString.Length == 0) { supported = FilterSupport.Custom; } else { foreach (ToolboxItemFilterAttribute attribute8 in itemFilter) { if (attribute5.FilterString.Equals(attribute8.FilterString)) { supported = FilterSupport.Custom; break; } } } } } if (((supported != FilterSupport.NotSupported) && (num > 0)) && (num2 == 0)) { supported = FilterSupport.NotSupported; } } return(supported); }
public void ThrowIfInvalidFileterTypeAllWith_fileterTypesが全てIFilterを継承してデフォルトコンストラクターがある型の場合はtrueが返る() { FilterSupport.ThrowIfInvalidFilterTypeAllWith( new Type[] { typeof(Filter1), typeof(Filter2) }); }
public void ThrowIfInvalidFileterTypeAllWith_fileterTypesがnullの場合は例外が発生する() { Action act = () => FilterSupport.ThrowIfInvalidFilterTypeAllWith(null); act.Should().Throw <ArgumentNullException>(); }
public void IsValidTIlterTypeAllCore_fileterTypesがnullの場合は例外が発生する() { Action act = () => FilterSupport.IsValidFilterTypeAllCore(null); act.Should().Throw <ArgumentNullException>(); }