Example #1
0
        /// <summary>
        /// Checks the properties named in the RequiredProperties property of the specified
        /// IHasRequiredProperties object ensuring that each has been set. This method will
        /// throw an error if required properties have not been set.
        /// </summary>
        /// <param name="target">The IHasRequiredProperties implementation to check.</param>
        private static void CheckRequiredProperties(IHasRequiredProperties target, Type configType)
        {
            foreach (string property in target.RequiredProperties)
            {
                Type         targetType = target.GetType();
                PropertyInfo prop       = targetType.GetProperty(property);
                if (prop == null)
                {
                    throw new InvalidIHasRequiredPropertiesImplementationException(targetType, property);
                }

                string propVal = (string)prop.GetValue(target, null);

                if (string.IsNullOrEmpty(propVal))
                {
                    throw new RequiredPropertyNotSetException(configType, prop);
                }
            }
        }
Example #2
0
 /// <summary>
 /// Checks the properties named in the RequiredProperties property of the specified
 /// IHasRequiredProperties object ensuring that each has been set. This method will
 /// throw an error if any required property is null or an empty string.
 /// </summary>
 /// <param name="toBeValidated">The IHasRequiredProperties implementation to check.</param>
 public static void RequiredProperties(IHasRequiredProperties toBeValidated)
 {
     DefaultConfiguration.CheckRequiredProperties(toBeValidated);
 }
Example #3
0
 /// <summary>
 /// Checks the properties named in the RequiredProperties property of the specified
 /// IHasRequiredProperties object ensuring that each has been set. This method will
 /// throw an error if any required property is null or an empty string.
 /// </summary>
 /// <param name="target">The IHasRequiredProperties implementation to check.</param>
 public static void CheckRequiredProperties(IHasRequiredProperties target)
 {
     CheckRequiredProperties(target, target.GetType());
 }