ParamGate application parameter handling library

Built-in attributes

The following attributes are available out of the box:
  • ExpectedParameter
  • OptionalParameter
  • FilesystemParameter

The Expected and Optional parameter attributes share the same properties but have different purposes with regards to marking properties. As mentioned before, marking a property with ExpectedParameter will make the associated parameter a required one. If its not found in the input parameter list, an error will be thrown. The OptionalParameter is also optional but allows one to specify other information for the optional parameter. The FilesystemParameter gives one some extra help when working with files or directories. It can help to see if the given path is valid and/or if it exists. You may combine the custom and FilesystemParameter attributes with the expected and optional parameter attributes on the same property but you obviously cannot have both optional and expected parameter attributes on the same property.

The Expected and Optional parameter attributes allows one to specify 2 things: a custom property name and whether the property is default or not. Please note that one cannot have more than one default property. The parameter name property allows one to specify a different name for the input parameter than the name the associated property currently holds.

The FilesystemParameter attribute has 2 properties:
  • VerifyExists - Verifies that the file or directory does in fact exist on the filesystem
  • IsDirectory - This is false by default. It tells the attribute to expect a file or a directory as it can be difficult to differentiate between files and directories in some cases as one gets extension-less files.

What about error handling? The expected and optional parameter attributes will throw ParamGateExceptions only if there is parameter configuration errors. Currently they do not validate any parameter values. The FilesystemParameter attribute, however doesn't check any parameter configuration but does parameter value validation. If the validation fails, it will throw a ParameterValidationException, DirectoryNotFoundException or FileNotFoundException.

Last edited Sep 2, 2011 at 6:24 PM by dandrejvv, version 1


No comments yet.