ArgumentHelper Class
Provides helper methods for asserting arguments.
Namespace:
AdvantageCMS.Core.Common.SitemapGeneratorAssembly: AdvantageCMS.Core (in AdvantageCMS.Core.dll)
Remarks
This class provides helper methods for asserting the validity of arguments. It can be used to reduce the number of laborious if, throw sequences in your code.
The AssertNotNull<(Of <<'(T>)>>)(T, String) method can be used to ensure that arguments are not nullNothingnullptra null reference (Nothing in Visual Basic). The AssertEnumMember overloads can be used to assert the validity of enumeration arguments.
Examples
C#
public void DisplayDetails(string name) { ArgumentHelper.AssertNotNull(name, "name"); //now we know that name is not null ... }
Examples
C#
public void DisplayInformation(DayOfWeek day) { ArgumentHelper.AssertEnumMember(day); //now we know that day is a valid member of DayOfWeek ... }
Examples
C#
public void DisplayInformation(DayOfWeek day) { ArgumentHelper.AssertEnumMember(day, DayOfWeek.Monday, DayOfWeek.Thursday); //now we know that day is either Monday or Thursday ... }
Examples
C#
public void GetInformation(BindingFlags bindingFlags) { ArgumentHelper.AssertEnumMember(bindingFlags, BindingFlags.Public, BindingFlags.NonPublic); //now we know that bindingFlags is either Public, NonPublic or both ... }
Examples
C#
public void GetInformation(BindingFlags bindingFlags) { ArgumentHelper.AssertEnumMember(bindingFlags, BindingFlags.Public, BindingFlags.NonPublic, BindingFlags.None); //now we know that bindingFlags is either Public, NonPublic, both or neither ... }