Exemple #1
0
        /// <summary>
        /// Initialize a new instance of the generic Ensure class using the supplied
        /// value as the value to insepct.
        /// </summary>
        /// <typeparam name="T">The type of the inepcted object value.</typeparam>
        /// <param name="obj">The object value to inspect.</param>
        /// <param name="strategy">Determines if the Ensure instance should load the current Stack.</param>
        /// <returns>The Ensure instance for fluent interface usage.</returns>
        public static IConfigurableEnsure <T> That <T>(T obj, SourceInfoLoadStrategy strategy)
        {
            var si = SourceInfo.Empty;

            if (strategy != Validation.SourceInfoLoadStrategy.Skip)
            {
                var lazy = strategy == Validation.SourceInfoLoadStrategy.LazyLoad;
                si = SourceInfo.FromStack(new StackTrace(1), lazy: lazy);
            }

            return(new Ensure <T>(obj, si));
        }