PostSharpAPI ReferencePost­Sharp.​Patterns.​ContractsNot­Empty­Attribute
Open sandboxFocus

NotEmptyAttribute Class

Custom attribute that, when added to a field, property or parameter, throws an ArgumentNullException if the target is assigned a null or empty value. The custom attributes can be added to locations of type String (where empty means zero characters), or ICollection, ICollection<T> or IReadOnlyCollection<T> (where empty means zero items).

Inheritance
NotEmptyAttribute
Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Common.dll
Syntax
[HasConstraint]
public sealed class NotEmptyAttribute : LocationContractAttribute, ILocationLevelAspect, IAspect
Remarks

Error message is identified by NotEmptyErrorMessage.

Constructors

Name Description
NotEmptyAttribute()

Initializes a new NotEmptyAttribute.

Methods

Name Description
GetErrorMessage()

Gets unformatted error message as defined by the instance.

ValidateValueCollection(ICollection, String, LocationKind, LocationValidationContext)
ValidateValueCollection<T>(ICollection<T>, String, LocationKind, LocationValidationContext)
ValidateValueCollection<T>(IReadOnlyCollection<T>, String, LocationKind, LocationValidationContext)
ValidateValueDynamic(Object, String, LocationKind, LocationValidationContext)

Validates a weakly-typed (boxed) value, typically the value of a dependency property or an attached property.

ValidateValueString(String, String, LocationKind, LocationValidationContext)