Click or drag to resize

Preconditions Class

Set of tools to check various preconditions during the code execution.
Inheritance Hierarchy
SystemObject
  KSPDev.ProcessingUtilsPreconditions

Namespace:  KSPDev.ProcessingUtils
Assembly:  KSPDev_Utils.1.2 (in KSPDev_Utils.1.2.dll) Version: 1.2 for KSP v1.6+
Syntax
C#
public static class Preconditions
Request Example View Source

The Preconditions type exposes the following members.

Methods
  NameDescription
Public methodStatic memberConfValueExists
Throws if value form a config node is null or empty string.
Public methodStatic memberHasSize
Throws if collection has not the expected number of elements.
Public methodStatic memberMakeContextError(Object, String)
Makes error text with respect to the context.
Public methodStatic memberMakeContextError(Object, String, Object)
Makes error text with respect to the context.
Public methodStatic memberMinElements
Throws if collection has less elements than required.
Public methodStatic memberNotNull
Throws if value is null.
Public methodStatic memberNotNullOrEmpty
Throws if string is null or empty.
Public methodStatic memberOneOfT
Throws if enum value is not in the expected set.
Top
Remarks
This class offers single line checkers for the case when a critical "go"/"no go" decision needs to be made. Instead of flooding your code with if/throw conditions, simply call a precondition check. If the condition met, then execution continues. Otherwise, an exception with a clear message is thrown.
See Also