/// <summary> /// Initializes a new instance of the <see cref="PathMemberSelectionRule" /> class. /// </summary> /// <param name="memberPath">The member path used to find matching members.</param> /// <param name="selectionMode">The selection mode to apply.</param> /// <param name="name">The name of the rule.</param> /// <param name="description">The description of the rule.</param> public PathMemberSelectionRule( String memberPath, MemberSelectionMode selectionMode, String name = null, String description = null ) : base(name, description) { memberPath.ThrowIfNull( nameof( memberPath ) ); _memberPath = memberPath; _selectionMode = selectionMode; }
/// <summary> /// Initializes a new instance of the <see cref="ExpressionMemberSelectionRule" /> class. /// </summary> /// <exception cref="ArgumentNullException">predicate can not be null.</exception> /// <param name="predicate">The predicate used to determine if a member matches the rule.</param> /// <param name="selectionMode">The selection mode to apply.</param> /// <param name="name">The name of the rule.</param> /// <param name="description">The description of the rule.</param> public ExpressionMemberSelectionRule( Func<IMemberInformation, Boolean> predicate, MemberSelectionMode selectionMode, String name = null, String description = null ) : base(name, description) { predicate.ThrowIfNull( nameof( predicate ) ); _predicate = predicate; _selectionMode = selectionMode; }
/// <summary> /// Initializes a new instance of the <see cref="PathMemberSelectionRule" /> class. /// </summary> /// <param name="memberPath">The member path used to find matching members.</param> /// <param name="selectionMode">The selection mode to apply.</param> /// <param name="name">The name of the rule.</param> /// <param name="description">The description of the rule.</param> public PathMemberSelectionRule([NotNull] String memberPath, MemberSelectionMode selectionMode, String name = null, String description = null) : base(name, description) { memberPath.ThrowIfNull(nameof(memberPath)); _memberPath = memberPath; _selectionMode = selectionMode; }
/// <summary> /// Initializes a new instance of the <see cref="TypeMemberSelectionRule" /> class. /// </summary> /// <param name="type">The type to compare with the type of given members.</param> /// <param name="selectionMode">The selection mode to apply.</param> /// <param name="compareMode">The compare mode to apply.</param> /// <param name="name">The name of the rule.</param> /// <param name="description">The description of the rule.</param> public TypeMemberSelectionRule( Type type, MemberSelectionMode selectionMode, CompareMode compareMode, String name = null, String description = null ) : base(name, description) { type.ThrowIfNull( nameof( type ) ); _type = type; _selectionMode = selectionMode; _compareMode = compareMode; }
/// <summary> /// Initializes a new instance of the <see cref="TypeMemberSelectionRule" /> class. /// </summary> /// <param name="type">The type to compare with the type of given members.</param> /// <param name="selectionMode">The selection mode to apply.</param> /// <param name="compareMode">The compare mode to apply.</param> /// <param name="name">The name of the rule.</param> /// <param name="description">The description of the rule.</param> public TypeMemberSelectionRule([NotNull] Type type, MemberSelectionMode selectionMode, CompareMode compareMode, String name = null, String description = null) : base(name, description) { type.ThrowIfNull(nameof(type)); _type = type; _selectionMode = selectionMode; _compareMode = compareMode; }
/// <summary> /// Includes all members matching the specified options. /// </summary> /// <exception cref="ArgumentNullException">configurationFunc can not be null.</exception> /// <param name="configurationFunc">Function used to configure the exclude.</param> /// <returns>Returns the modified create instance options.</returns> public ICreateInstanceOptions <T> Including(Func <IIncludeExcludeOptions <T>, IIncludeExcludeOptions <T> > configurationFunc) { configurationFunc.ThrowIfNull(nameof(configurationFunc)); _currentMemberSelectionTarget = MemberSelectionRuleTarget.Member; _currentMemberSelectionMode = MemberSelectionMode.Include; configurationFunc(this); return(this); }
/// <summary> /// Initializes a new instance of the <see cref="ExpressionMemberSelectionRule" /> class. /// </summary> /// <exception cref="ArgumentNullException">predicate can not be null.</exception> /// <param name="predicate">The predicate used to determine if a member matches the rule.</param> /// <param name="selectionMode">The selection mode to apply.</param> /// <param name="name">The name of the rule.</param> /// <param name="description">The description of the rule.</param> public ExpressionMemberSelectionRule([NotNull] Func <IMemberInformation, Boolean> predicate, MemberSelectionMode selectionMode, String name = null, String description = null) : base(name, description) { predicate.ThrowIfNull(nameof(predicate)); _predicate = predicate; _selectionMode = selectionMode; }
/// <summary> /// Factory will NOT be used to create values for members matching the specified options. /// </summary> /// <exception cref="ArgumentNullException">configurationFunc can not be null.</exception> /// <param name="configurationFunc">Function used to configure the factory.</param> /// <returns>Returns the modified create instance options.</returns> public IFactoryOptionsConstistent <T> NotFor(Func <IIncludeExcludeOptions <T>, IIncludeExcludeOptions <T> > configurationFunc) { configurationFunc.ThrowIfNull(nameof(configurationFunc)); //Check if target is factory. if (_currentMemberSelectionTarget != MemberSelectionRuleTarget.Factory) { throw new InvalidOperationException("Cannot add rule to factory without specifying a factory first."); } _currentMemberSelectionMode = MemberSelectionMode.Exclude; configurationFunc(this); return(this); }
/// <summary> /// Initializes a new instance of the <see cref="AllMemberSelectionRule" /> class. /// </summary> /// <param name="selectionMode">The selection mode to apply.</param> /// <param name="name">The name of the rule.</param> /// <param name="description">The description of the rule.</param> public AllMemberSelectionRule(MemberSelectionMode selectionMode, String name = null, String description = null) : base(name, description) => _selectionMode = selectionMode;
/// <summary> /// Initializes a new instance of the <see cref="AllMemberSelectionRule" /> class. /// </summary> /// <param name="selectionMode">The selection mode to apply.</param> /// <param name="name">The name of the rule.</param> /// <param name="description">The description of the rule.</param> public AllMemberSelectionRule( MemberSelectionMode selectionMode, String name = null, String description = null ) : base(name, description) { _selectionMode = selectionMode; }